[alsa-devel] how to convert stereo capture to mono stream (hardware incompatibility)
Hi all,
I've already asked my question in the alsa-user list, but as nobody was able to answer, I'm trying here if I have more chance.
I'm using a USB M-Audio fasttrack pro sound card under linux 2.6.24.rt, and I want to plug it into a voice recognition software named Julius.
There is an implementation of alsa in Julius, but I can't make it working with my USB sound card, because when alsa tries to set channel capture to 1, I get an error from alsa. Here is the code :
/* set number of channels */ if ((err = snd_pcm_hw_params_set_channels(handle, hwparams, 1)) < 0) { jlog("Error: adin_alsa: cannot set PCM channel to %d (%s)\n", 1, snd_strerror(err)); return(FALSE); } Which always return FALSE.
The thing is that when I change this line to set stereo channels, Julius recognition engine complains when it runs, and strip lots of audio packets, which seems to broke recognition.
So my question is : how can I by-pass this problem?
I've tried to do it with the .asoundrc file, but it seems that plugin or dmix stuff only works with playback, not recording. Does someone have an idea how to make a recording plugin that accept stereo stream from hardware and output only the left channel?
I didn't understand how stereo stream are written in the audio buffer gave by alsa. Can someone explain me how to separate the two stream once it is written in the buffer?
I really thanks all who would take little attention to my questions, it's been 5 days I'm digging on the web but I only get code working for setreo applications, which doesn't help me so much. And I know I might have an answer if I look into the audacity code, but it seems to me it's like using a bazooka for fishing redfish....
Best Regards, Bruno.
brunal wrote:
There is an implementation of alsa in Julius, but I can't make it working with my USB sound card, because when alsa tries to set channel capture to 1, I get an error from alsa. Here is the code :
/* set number of channels */ if ((err = snd_pcm_hw_params_set_channels(handle, hwparams, 1)) < 0) { jlog("Error: adin_alsa: cannot set PCM channel to %d (%s)\n", 1, snd_strerror(err)); return(FALSE); } Which always return FALSE.
I'd guess this program uses a wrong device name. Make sure that the default device name is "default", which can automatically convert sample formats not supported by the hardware, and not "hw".
HTH Clemens
participants (2)
-
brunal
-
Clemens Ladisch