-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linux : Virtual device creation and routing microphone audio via a python script #2
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
533b640
Progress update, wire.py and a sample audio file
arushsharma24 2f8637e
add dynopii.sh and others
arushsharma24 6ce1554
update progress.txt
arushsharma24 9236b21
delete irrelevant files
arushsharma24 3677a4c
update .gitignore for the folder initial/ in linux/ for temporary wor…
arushsharma24 619e3dd
Main commit : finalised dynopii.py, added close.sh
arushsharma24 f7e9600
update README
arushsharma24 c59265a
included close.sh into dynopii.py python script using subprocess
arushsharma24 598ddad
convert all shell scripts to python (tested and ok), and update readme
arushsharma24 fc2fe7f
Changes as requested in PR review included
arushsharma24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#Temporary work files | ||
linux/initial | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
### Step 1: | ||
Run the script with the command: | ||
`$ python3 dynopii.py` | ||
|
||
### Step 2: (only for first time use) | ||
In the "Playback" tab of the pavucontrol window that opens, and make sure that the playback device for the running "ALSA plug-in[aplay]: ALSA Playback _on_" is 'dynopii'. | ||
|
||
# | ||
To close this, stop the script using `Ctrl-C` and it will also delete the virtual device module and stop the playback. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import subprocess | ||
import audioop | ||
|
||
try: | ||
|
||
print('#' * 80) | ||
print('Initiating dynopii virtual audio cable ... ') | ||
loadcmd = ['pacmd', 'load-module', 'module-null-sink', 'sink_name=dynopii_sink', 'sink_properties=device.description=dynopii'] | ||
subprocess.Popen(loadcmd) | ||
subprocess.Popen('pavucontrol') | ||
|
||
cmd0 = ['arecord', '-f', 'cd', '-'] | ||
p0 = subprocess.Popen(cmd0, stdout=subprocess.PIPE) | ||
|
||
''' | ||
This stdout of p0 is basically the data we get from arecord, and the data that we can manipulate on the fly and then | ||
feed to the stdin of the next process p1. | ||
If you will work on this, you'll have to replace the stdin=p0.stdout of the following process p1 with your manipulated data. | ||
''' | ||
|
||
cmd1 = ['aplay', '-f', 'cd', '-'] | ||
p1 = subprocess.Popen(cmd1, stdin=p0.stdout) | ||
print('') | ||
print('To quit this program and close your virtual device, press Ctrl-C') | ||
print('') | ||
print('#' * 80) | ||
input() | ||
|
||
except EOFError: | ||
print('EOF Error') | ||
|
||
except KeyboardInterrupt: | ||
print() | ||
print('Closing the virtual audio cable ....') | ||
print('Unloading null-sinks ...') | ||
print('Stopping playback ...') | ||
|
||
uncmd0 = ['pactl', 'list', 'short', 'modules'] | ||
uncmd1 = ['grep', 'sink_name=dynopii'] | ||
uncmd2 = [ 'cut', '-f1' ] | ||
uncmd3 = [ 'xargs', '-L1', 'pactl', 'unload-module' ] | ||
|
||
unp0 = subprocess.Popen(uncmd0, stdout=subprocess.PIPE) | ||
unp1 = subprocess.Popen(uncmd1, stdin=unp0.stdout, stdout=subprocess.PIPE) | ||
unp2 = subprocess.Popen(uncmd2, stdin=unp1.stdout, stdout=subprocess.PIPE) | ||
unp3 = subprocess.Popen(uncmd3, stdin=unp2.stdout) | ||
|
||
killcmd = ['pkill', 'arecord'] #kill arecord (hence killing ALSA playback since aplay simultaneously stops receiving input via the pipe) | ||
closefin = subprocess.Popen(killcmd) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove