2

I need some pointers where to start with the following:

From any application that plays audio using ALSA to the connected speaker I'd like to grab the samples and do some audio processing. I am not in control of the player and I'd like to be able to process the audio from any source. Basically it will be an UV-meter, perhaps later with FFT (all just on the command line). Additionally I'd like my app to be self-contained.

In my research I've found:

  • There is a loopback kernel module.
  • You can do fancy stuff with the configuration file.
  • There is the ability to create plugins.

Using the kernel module and altering the configuration file introduces some dependencies of my application to the configuration of the system.
And creating a plugin I give up control over the app and cannot start/terminate it whenever I want.

This is not satisfactory to me so I'd like to know if there is a way to either:

  • create a loopback device programmatically
  • or is there any other way to read from the pcm playback device other applications are writing to.
kwasmich
  • 121
  • 4

1 Answers1

1

You can use the pulseaudio for linux where you can very easily create a loopback device .There ia a pactl command -it will help you create a null sink and you can loopback from it .

something like this //this would create a null sink with specified channel conf

pactl load-module module-null-sink sink_name=sink6ch format=s16le rate=48000 channels=6 channel_map=front-left,front-right,front-center,lfe,rear-left,rear-right

//make it default

pactl set-default-sink sink6ch

you can use its monitor device to read about the monitor devices of pulse audio