Virtual audio connections under Linux Ubuntu. Can be done using both Pulseaudio and ALSA servers.
You probably need to do audio piping to record an audio output or to use SDR tools which only support audio input. You don't have to use a real cable to wire the sound card output into line in. The software approach is better. There is more than one way to do this in Linux. We'll look into Pulseaudio and ALSA, the sound servers used by Ubuntu. Depending on what application you use, you may need to configure the virtual connection on one or the other server.
Pulseaudio
It's very simple to configure. Nothing to install. Give it a try by running in a terminal:pacmd load-module module-null-sink sink_name=Virtual_Sink sink_properties=device.description=Virtual_SinkYou should see no error after running this command. Do not run it as root. If you open Sound Settings, a new output device should have appeared, named Virtual_Sink.
To test this, open and application that outputs sound and select Virtual_Sink. If you use an application with Pulseaudio support but with no way of selecting the sound card, you can set it to output sound through the Virtual_Sink in the Sound Settings. Simply click on Virtual_Sink. Unfortunately, this sets the virtual sink as default output device for all applications.
Select the virtual sink in Sound Settings |
Select Monitor as input source |
Before trying a different approach, if this worked for you, you should know that this setup is not permanent. All it takes is to restart Pulseaudio and the Virtual_Sink is lost. To make it permanent, open the configuration file (sudo gedit /etc/pulse/default.pa) and add the following line:
load-module module-null-sink sink_name=Virtual_Sink sink_properties=device.description=Virtual_SinkSave and close. You can restart Pulseaudio. The Virtual Sink is still there.
ALSA
ALSA makes use of a virtual loopback module. It can be loaded with modprobe:sudo modprobe snd_aloopThe new device has 8 I/O ports (a.k.a. subdevices). You can view them using aplay -l command. Example output:
card 1: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM] Subdevices: 7/8 Subdevice #0: subdevice #0 Subdevice #1: subdevice #1 Subdevice #2: subdevice #2 Subdevice #3: subdevice #3 Subdevice #4: subdevice #4 Subdevice #5: subdevice #5 Subdevice #6: subdevice #6 Subdevice #7: subdevice #7 card 1: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM] Subdevices: 8/8 Subdevice #0: subdevice #0 Subdevice #1: subdevice #1 Subdevice #2: subdevice #2 Subdevice #3: subdevice #3 Subdevice #4: subdevice #4 Subdevice #5: subdevice #5 Subdevice #6: subdevice #6 Subdevice #7: subdevice #7In this example you can see that the virtual devices are hw:1,0 and hw:1,1. From here, things get simple: one application outputs sound to hw:1,0 and the other records that sound from hw:1,1. I guess the other way round works too. It should be noted that the parameters of the sound are controlled by the first application that opens one of the loopback devices.
Although Pulseaudio can connect to ALSA devices, I had no luck on getting sound from loopback input. Yet it worked from the monitor of loopback.
Sound output setting example |
Neither this setup is permanent. The module snd_aloop must be loaded at boot time by adding it in /etc/modules file.
genial... depuis le temps que je cherchais une solution via ubuntu et mon sdr
ReplyDeleteremerciement
I like it!
ReplyDeleteAudacity should be using the standard device names which you can view on the terminal using either aplay -L or arecord -L
ReplyDeleteI'm using your recipe for streaming music from Ubuntu/Linux to Twitter App on an Android x86_64 under Virtualbox. So I can stream music via Twitter Spaces from now on. Thank you!
ReplyDeleteWell, it seems there are unlimited uses of this method :))
DeleteI am running Ubuntu Budgie and I get No PulseAudio daemon running, or not running as session daemon.
ReplyDeleteHow can I fix this?
Maybe try ALSA method.
Delete