Help for Virtual Sound Device

Hi,

I am trying to create a virtual sound device with sudo modprobe snd-aloop , but it throws the following error:

modprobe: FATAL: Module snd-aloop not found in directory /lib/modules/4.9.140-tegra

Could you please help how to resolve this issue?

Thank you

Hello!

The snd-aloop driver is not enabled on the L4T kernel by default …

$ zcat /proc/config.gz | grep SND_ALOOP
# CONFIG_SND_ALOOP is not set

So to enable this you need to download the kernel sources, update the kernel configuration and rebuild the kernel. There are instructions in the following document on how to download and rebuild the kernel sources …

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide%2Fkernel_custom.html%23

The default kernel configuration for Jetson is located in the file arch/arm64/configs/tegra_defconfig in the kernel source tree and so you should be able to append the following line to the end of the file to build the module …

CONFIG_SND_ALOOP=m

I have just checked and this driver should be enabled by default in future releases and so in the future it should be present by default.

Regards,
Jon

The kernel module built on NX natively with the steps below. needs to be downloaded and renamed to snd-aloop.ko snd-aloop.ko.txt (400.3 KB)

wget https://developer.download.nvidia.com/embedded/L4T/r32_Release_v4.3/sources/T186/public_sources.tbz2
tar -xjf public_sources.tbz2
 cd Linux_for_Tegra/
cd source/
cd public/
tar -xjf kernel_src.tbz2
mkdir ~/dev/out
TEGRA_KERNEL_OUT=~/dev/out
 cd kernel/
cd kernel-4.9/
make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig
nano ~/dev/Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/configs/tegra_defconfig
#adding the line from the post above##
make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j 6
KERNEL_MODULES_OUT=~/dev/out/modules
sudo make modules_install ARCH=arm64 O=$TEGRA_KERNEL_OUT INSTALL_MOD_PATH=$KERNEL_MODULES_OUT

In orderto be able to load the module with not just insmod, but also modprobe it is required to put the file in corresponding folder and create the file with the content below:

/lib/modprobe.d/snd-aloop.conf

install snd-aloop insmod /lib/modules/4.9.140-tegra/snd-aloop.ko

so after reboot it will be possible to load the module with
sudo modprobe snd-aloop

Another issue is how to introduce a delay with snd-aloop,
given there is a need e.g. to add 3 seconds delay on a virtual microphone device?
shall gstreamer be used for the purpose? arecord to arecord pipeline?

arecord -Dhw:<card_num>,<device_num> -c <channel_number> –f <format> -r <sample_rate> | aplay -Dhw:<card_num>,<device_num>

The above redirects to output device, source https://stackoverflow.com/questions/43319199/how-to-loop-back-the-microphone-entry-directly-to-speakers-on-linux/43319706
The following does’t seem to work either.

gst-launch-1.0 alsasrc ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 min-threshold-time=5000000000 ! alsasink device="hw:3,0" sync=false async=true

How to map the hardware microphone on hw:2,0 to the virtual microphone on hw:3,0 so that a few seconds latency is introduced and so .e.g google hangouts could use the loopback virtual microphone with introduced latency? The complication is that default scenarios would seem to redirect audio source to audio output; However as web browser app in the defined use case needs to take input from virtual microphone with introduced delay it seem to require further customization of the media pipeline.
ref: https://askubuntu.com/questions/895216/how-to-route-pulse-audio-device-into-alsa-loopback-virtual-microphone

Thank you @jonathanh,

Could you please help how to add some delay to microphone output same as @Andrey1984 mentions?
I need to stream the audio from my microphone to the virtual sound loopback and set the virtual sound device as default on a Hangouts meeting with ~2 sec sound delay

snd-aloop after being loaded into the kernel creates the following card structure:

 ls /proc/asound/card3
cable#0  cable#1  id  pcm0c  pcm0p  pcm1c  pcm1p

pcmc stands for capture device and pcmp stands for play device

sudo modprobe snd-aloop
$ pacmd load-module module-alsa-sink device=hw:3,1

probably somewhere at this point the virtual microphone loopback might have started working? but how to introduce the delay?

pacmd list-sources | grep -e 'index:' -e device.string -e 'name:'
    index: 0
	name: <alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo.monitor>
		device.string = "2"
  * index: 1
	name: <alsa_input.usb-Logitech_Logitech_USB_Headset-00.analog-mono>
		device.string = "hw:2"
    index: 2
	name: <alsa_output.platform-sound.analog-stereo.monitor>
		device.string = "1"
    index: 3
	name: <alsa_input.platform-sound.analog-stereo>
		device.string = "front:1"
    index: 4
	name: <alsa_output.platform-snd_aloop.0.analog-stereo.monitor>
		device.string = "3"
    index: 5
	name: <alsa_input.platform-snd_aloop.0.analog-stereo>
		device.string = "front:3"
    index: 6
	name: <alsa_output.hw_3_1.monitor>

setting default device

pacmd "set-default-source alsa_input.platform-snd_aloop.0.analog-stereo"

 $ pacmd list-sources | grep -e 'index:' -e device.string -e 'name:'
    index: 0
	name: <alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo.monitor>
		device.string = "2"
    index: 1
	name: <alsa_input.usb-Logitech_Logitech_USB_Headset-00.analog-mono>
		device.string = "hw:2"
    index: 2
	name: <alsa_output.platform-sound.analog-stereo.monitor>
		device.string = "1"
    index: 3
	name: <alsa_input.platform-sound.analog-stereo>
		device.string = "front:1"
    index: 4
	name: <alsa_output.platform-snd_aloop.0.analog-stereo.monitor>
		device.string = "3"
  * index: 5
	name: <alsa_input.platform-snd_aloop.0.analog-stereo>
		device.string = "front:3"

So first I start at NX

./test-launch 'videotestsrc ! nvvidconv ! nvv4l2h264enc ! h264parse ! queue ! rtph264pay name=pay0 pt=96 alsasrc buffer-time=32000 latency-time=16000 ! voaacenc ! queue ! rtpmp4apay pt=97 name=pay1'


doesn’t seem geting audio if using default device - virtual input;

ref :
https://sourceforge.net/p/alsa/support-requests/264/
https://freenode.logbot.info/pulseaudio