Separate audio streams from ALSA driver

272 Views Asked by At

I am using a USB sound card with 16 microphones on my Raspberry Pi (the device is the UMA 16). Currently, I am collecting all 16 channels data and using up to 8 of them by separating their contents programmatically for an application that needs real time audio input, according to a configuration file which specifies which channels to use. Is there any way to use the alsa driver API to provide data from up to 8 microphones specified by the user at runtime so I can avoid the extra 8 mic input?

I'm attaching the .asoundrc file that I wrote for the UMA 16:

pcm_slave.ins {
        pcm "hw:1,0"
        rate 16000
        channels 16
}
pcm.mic0 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 0
        }
}
pcm.mic1 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 1
        }
}
pcm.mic2 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 2
        }
}
pcm.mic3 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 3
        }
}
pcm.mic4 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 4
        }
}
pcm.mic5 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 5
        }
}
pcm.mic6 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 6
        }
}
pcm.mic7 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 7
        }
}
pcm.mic8 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 8
        }
}
pcm.mic9 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 9
        }
}
pcm.mic10 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 10
        }
}
pcm.mic11 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 11
        }
}
pcm.mic12 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 12
        }
}
pcm.mic13 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 13
        }
}
pcm.mic14 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 14
        }
}
pcm.mic15 {
        type plug
        slave.pcm {
                type dsnoop
                ipc_key 12342
                slave ins
                bindings.0 15
        }
}

Edit:

Currently I'm using snd_pcm_open(&handle, deviceName, SND_PCM_STREAM_CAPTURE, 0); to capture audio from the default deviceName. If I was to declare all of my mics as separate devices, would I still be able to get their data in parallel?

0

There are 0 best solutions below