Sinks are for output, sources are for input. To stream source to sink a loopback must be created. More shall you find there.
Our output sink will be named recording
.
pacmd load-module module-null-sink sink_name=recording sink_properties=device.description=recording
Step 2. Create output sink that will forward data to recording
and the default sink -- your headphones (using speakers is not a good idea because they will be recorded by microphone for the second time)
First we have to locate our output sink:
pacmd list-sinks | egrep '^\s+name: .*'
For me it prints:
name: <alsa_output.pci-0000_00_1f.3.analog-stereo>
name: <bluez_sink.4C_87_5D_07_5B_C4.a2dp_sink>
So I choose bluez_sink.4C_87_5D_07_5B_C4.a2dp_sink
as my output sink because its my headphones (the other represents my speakers).
Now we can combine it with our new recording
sink into combined
sink:
pacmd load-module module-combine-sink sink_name=combined sink_properties=device.description=combined slaves=recording,bluez_sink.4C_87_5D_07_5B_C4.a2dp_sink
Protip: If you ommit this step you may record multiple apps without microphone.
First we have to locate our microphone as a source:
pacmd list-sources | egrep '^\s+name: .*' | grep input
For me it produced:
name: <alsa_input.pci-0000_00_1f.3.analog-stereo>
So alsa_input.pci-0000_00_1f.3.analog-stereo
represents my microphone.
Now we attach it to redording
sink:
pacmd load-module module-loopback source=alsa_input.pci-0000_00_1f.3.analog-stereo sink=recording latency_msec=1
Step 4. Channel applications through the combined
sink to record them (this step can be done after step 5. -- you can change what apps you record without stopping recording)
Open pavucontrol
, go to Playback
tab and change sink to combined
. Hint: the application won't appear there unless it is producing sound.
With the above setup, you can start and stop recording at any time. To record recording
sink, use:
parecord --channels=2 -d recording.monitor output.wav
It will save recording to output.wav
file. To stop recording press Crtl-C
(kill the parecord with SIGINT).
Protip: You can change recorded applications while recording by controlling which ones output to combined
sink as was shown in step 4.
❤️