Design advice : ALSA quad sound for car radio app
I am developing a car-radio app in C++ (open source) for raspberry pi; https://github.com/vinthewrench/carradio
I am having some success with the ALSA api and the Signstek USB DAC, but I would like some advice on how to solve a problem related to using 4 speakers.
My code only know about left and right channels at the moment and does snd_pcm_writei calls to the “default” device.
I believe I can just add another USB DAC to give me 4 channels (front and back) but I am unclear on how to write code to talk to all 4. What I suspect is the answer is to create some form of virtual device that mixes the front and back channels and do the snd_pcm_open and calls to that device.
So the question is? What is the proper way to configure ALSA to integrate the front and back channels and let ALSA do all the mixing work.
I am still a bit clueless about how to setup ALSA and it has been a bit of trial and error.
You wanted design advice: Don’t use two different soundcards to drive channels for the same output directly with ALSA. The reason is that each soundcard will have a slightly different master clock, and the clocks for the two channel pairs will drift apart, and after some time (when you expect it least) your app will start to exhibit funny errors.
So either use something that can resample and correct for clock drifts (e.g. Pulseaudio). Or find some USB soundcard that has 4 channels, there are plenty to choose from.
What is the proper way to configure ALSA to integrate the front and back channels and let ALSA do all the mixing work.
If you are masochistic and insist on doing it that way, have a look at the multi plugin, and take note of the additional
plug plugin on top of it.