Re: [Alsa-user] Redirecting Mic Input in software (no arecord / aplay involved)
I wrote: However, an even better solution for your problem would be to enable the input monitoring function of your sound card. Okay, monitoring is now supported, with this patch: http://hg.alsa-project.org/alsa-kernel/rev/0fff88f7f05b To enable monitoring from a script, run amixer cset name=Analog Input Monitor Switch on or name=Analog Input Monitor Switch,index=1 for the second analog input. HTH Clemens - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
Re: [Alsa-user] Redirecting Mic Input in software (no arecord / aplay involved)
Thierry Bouchard wrote: Your comment bring me another question though, why would enabling the input monitoring on my sound card have fixed my problem and would have been a better solution? What exactly is input monitoring? Input monitoring means that the recorded data is played back immediately. You are implementing this in software, but doing it in hardware would be much easier (for you) and have less latency. Regards, Clemens - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
[Alsa-user] Redirecting Mic Input in software (no arecord / aplay involved)
Hello, Im trying to capture the Microphone input and redirect it right away into speakers. The problem is that whenever I use snd_pcm_readi and snd_pcm_writei one after each other in my capture loop, the pipe becomes broken on the output side, i.e. every call to snd_pcm_writei fails after it succeeded for like 2 passes. What is weird is that if I use only read or write calls in my capture loop, there is no problem at all. The input device I open is configured like this in the asound.conf file pcm.jcb-in-1 { type hw card 0 device 2 } And this is the output device pcm.CMI8788 { type hw card 0 device 0 } Should I do something special in between the calls to read and write? Should I initialize the devices in any special way to make this possible? Thx for your help! CONFIDENTIALITY CAUTION This e-mail and any attachments may be confidential or legally privileged. If you received this message in error or are not the intended recipient, you should destroy the e-mail message and any attachments or copies, and you are prohibited from retaining, distributing, disclosing or using any information contained herein. Please inform us of the erroneous delivery by return e-mail. Thank you for your cooperation. DOCUMENT CONFIDENTIEL Le présent courriel et tout fichier joint à celui-ci peuvent contenir des renseignements confidentiels ou privilégiés. Si cet envoi ne s'adresse pas à vous ou si vous l'avez reçu par erreur, vous devez l'effacer. Vous ne pouvez conserver, distribuer, communiquer ou utiliser les renseignements qu'il contient. Nous vous prions de nous signaler l'erreur par courriel. Merci de votre collaboration. - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
Re: [Alsa-user] Redirecting Mic Input in software (no arecord / aplay involved)
Thierry Bouchard wrote: Im trying to capture the Microphone input and redirect it right away into speakers. The problem is that whenever I use snd_pcm_readi and snd_pcm_writei one after each other in my capture loop, the pipe becomes broken on the output side, i.e. every call to snd_pcm_writei fails after it succeeded for like 2 passes. In the time that snd_pcm_readi needs to wait for a block of data to become available, the data written by the last snd_pcm_writei call is played by the sound card. Just when snd_pcm_readi returns, the playback buffer has become completely empty, and even the slightest delay in writing the next data to it will result in an underrun. To ensure that the playback buffer contains enough samples to adjust for timing variations, do not start playing when the first block of data is written to it but when the buffer is (almost) completely filled. The buffer fullness at which a playback device is started is called the start threshold. The default value is 1, i.e., after at least one sample has been written to the buffer; you can change it with the snd_pcm_sw_params_start_threshold function. The following is from the implementation of snd_pcm_set_params: snd_pcm_sw_params_t *swparams; snd_pcm_sw_params_alloca(swparams); ... err = snd_pcm_sw_params_current(pcm, swparams); if (err 0) { SNDERR(Unable to determine current swparams for %s: %s, s, snd_strerror(err)); return err; } /* start the transfer when the buffer is almost full: */ /* (buffer_size / avail_min) * avail_min */ err = snd_pcm_sw_params_set_start_threshold(pcm, swparams, (buffer_size / period_size) * period_size); if (err 0) { SNDERR(Unable to set start threshold mode for %s: %s, s, snd_strerror(err)); return err; } /* allow the transfer when at least period_size samples can be processed */ err = snd_pcm_sw_params_set_avail_min(pcm, swparams, period_size); if (err 0) { SNDERR(Unable to set avail min for %s: %s, s, snd_strerror(err)); return err; } /* write the parameters to the playback device */ err = snd_pcm_sw_params(pcm, swparams); if (err 0) { SNDERR(Unable to set sw params for %s: %s, s, snd_strerror(err)); return err; } However, an even better solution for your problem would be to enable the input monitoring function of your sound card. This should be supported by the CMI8788 chip, but it isn't supported by the driver because so far I have not been able to find out how it works. I'll look into it. Regards, Clemens - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user