Question

been doing some research for a project and wondering how I am able to stream the raw data from my alsa device to a python/C++/java application. I have been messing around with alsaaudio, the python interface, but can only do this with microphone. I am hoping to just capture all data coming through the card (from applications like vlc etc.)

Anyone help on this one?

Was it helpful?

Solution

There is hardware that can reroute its output back to some capture device, but most sound devices do not support this.

You could load the snd-aloop driver and create a virtual device using the multi plugin to route the output to both the actual device and the loopback device, but it is likely that the sample clocks of the two devices will diverge if they are running for too long.

I would recommend to create a virtual device using the file plugin to copy the data to your application through a pipe. Put something like the following into /etc/asound.conf or into your ~/.asoundrc:

pcm.mydevice {
    type plug
    slave.pcm {
        type file
        slave.pcm "hw:0,0"   # or whatever your actual output device is
        file "|/some/where/myapplication"
    }
}

and tell the other applications to use ALSA device mydevice.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top