[alsa-devel] Getting the actual HW sample rate
I know that http://www.mail-archive.com/alsa-user@lists.sourceforge.net/msg24794.htmlgiv... code to get the available sample rates (among other things). However, my quest is to get the actual HW sample rate. This code is quite helpful. I know that if a sound is already playing, I can look at /proc/asound/card0/pcm0p/sub0/hw_params to see what the HW sample rate is. But is there a way to get this using ALSA?
In my application, we want to know the actual HW rate so that we can do the sample rate conversion ourselves upfront and therefore we want to avoid yet another sample rate conversion when playing out the audio. (The application can synthesize audio and we can select the sample rate for the synthesis.)
Thanks,
Ray
On Thu, Sep 8, 2011 at 1:10 AM, Clemens Ladisch clemens@ladisch.de wrote:
Raymond Toy wrote:
In my application, we want ... to avoid yet another sample rate conversion when playing out the audio.
Add the SND_PCM_NO_AUTO_RESAMPLE flag when calling snd_pcm_open, or use snd_pcm_hw_params_set_rate_resample.
Thanks! This works very nicely with the sample code from the link.
Ray
On Thu, Sep 8, 2011 at 1:10 AM, Clemens Ladisch clemens@ladisch.de wrote:
Raymond Toy wrote:
In my application, we want ... to avoid yet another sample rate conversion when playing out the audio.
Add the SND_PCM_NO_AUTO_RESAMPLE flag when calling snd_pcm_open, or use snd_pcm_hw_params_set_rate_resample.
Some further experimentation with this has confused me. I changed the sample code to call snd_pcm_hw_params_set_rate_resample with resample = 0.
When I run the code without an .asoundrc (defaulting to pulse audio, I think), I get sample rrates : 1-192000.
Is that right?
Ray
Raymond Toy wrote:
On Thu, Sep 8, 2011 at 1:10 AM, Clemens Ladisch <clemens@ladisch.de mailto:clemens@ladisch.de> wrote:
Add the SND_PCM_NO_AUTO_RESAMPLE flag when calling snd_pcm_open, or use snd_pcm_hw_params_set_rate_resample.
Some further experimentation with this has confused me. I changed the sample code to call snd_pcm_hw_params_set_rate_resample with resample = 0.
When I run the code without an .asoundrc (defaulting to pulse audio, I think), I get sample rrates : 1-192000.
The pulse plugin does not support this flag.
Regards, Clemens
On Mon, Sep 12, 2011 at 1:29 PM, Clemens Ladisch clemens@ladisch.de wrote:
Raymond Toy wrote:
On Thu, Sep 8, 2011 at 1:10 AM, Clemens Ladisch <clemens@ladisch.de mailto:clemens@ladisch.de> wrote:
Add the SND_PCM_NO_AUTO_RESAMPLE flag when calling snd_pcm_open, or
use
snd_pcm_hw_params_set_rate_resample.
Some further experimentation with this has confused me. I changed the sample code to call snd_pcm_hw_params_set_rate_resample with resample =
When I run the code without an .asoundrc (defaulting to pulse audio, I think), I get sample rrates : 1-192000.
The pulse plugin does not support this flag.
Well, that explains it of course. Thanks for your help!
Ray
participants (2)
-
Clemens Ladisch
-
Raymond Toy