Question

I want to make a shell script to record the sound of a program and to direct it as an microphone entry on linux.

For instance, I'm listening a music on youtube, and I want that music to be send to my skype's conversation instead of my voice.

Last but not least, I know how to do it using pavucontrol, I have to go to "Recording" and to switch the "Record stream from", but I want to do the exact same thing from the command line, and not using a gui.

I tried this:

pactl load-module module-loopback source=1 sink=2

(where 1 is my desktop sound, 2 is Analog Stereo Duplex (but it also includes the normal sound on top of my input....) and it doesn't work as expected. I don't know what to do.

Thanks

Was it helpful?

Solution

module-loopback can only be used to short-circuit sources to sinks. (i.e. mic to speaker.) The switch you found in pavucontrol can be accessed from the command line via

 pactl move-source-output <source output> <source>

You can get the source output ID via

pactl list source-outputs

while a program is recording, and a list of sources using

pactl list sources

You can also supply the source by name, e.g. combined.monitor.

I just tried it with mplayer and audacity and noticed two pitfalls:

  • If the monitor is stereo and your default source is mono, applications might not like being rerouted. You can use module-remap-source to work around that: Remap the monitor to one mono channel and move the source output to the newly created remapped source.
  • You might need to unmute the monitor device in pavucontrol before this works. From the command line this can be done using pactl set-source-mute. (See man pactl)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top