All of lore.kernel.org
 help / color / mirror / Atom feed
* Getting the actual HW sample rate
@ 2011-09-07 21:24 Raymond Toy
  2011-09-08  8:10 ` Clemens Ladisch
  0 siblings, 1 reply; 6+ messages in thread
From: Raymond Toy @ 2011-09-07 21:24 UTC (permalink / raw)
  To: alsa-devel

I know that
http://www.mail-archive.com/alsa-user@lists.sourceforge.net/msg24794.htmlgives
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Getting the actual HW sample rate
  2011-09-07 21:24 Getting the actual HW sample rate Raymond Toy
@ 2011-09-08  8:10 ` Clemens Ladisch
  2011-09-08 22:26   ` Raymond Toy
  2011-09-12 17:54   ` Raymond Toy
  0 siblings, 2 replies; 6+ messages in thread
From: Clemens Ladisch @ 2011-09-08  8:10 UTC (permalink / raw)
  To: Raymond Toy; +Cc: alsa-devel

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.


Regards,
Clemens

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Getting the actual HW sample rate
  2011-09-08  8:10 ` Clemens Ladisch
@ 2011-09-08 22:26   ` Raymond Toy
  2011-09-12 17:54   ` Raymond Toy
  1 sibling, 0 replies; 6+ messages in thread
From: Raymond Toy @ 2011-09-08 22:26 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Getting the actual HW sample rate
  2011-09-08  8:10 ` Clemens Ladisch
  2011-09-08 22:26   ` Raymond Toy
@ 2011-09-12 17:54   ` Raymond Toy
  2011-09-12 20:29     ` Clemens Ladisch
  1 sibling, 1 reply; 6+ messages in thread
From: Raymond Toy @ 2011-09-12 17:54 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Getting the actual HW sample rate
  2011-09-12 17:54   ` Raymond Toy
@ 2011-09-12 20:29     ` Clemens Ladisch
  2011-09-12 20:59       ` Raymond Toy
  0 siblings, 1 reply; 6+ messages in thread
From: Clemens Ladisch @ 2011-09-12 20:29 UTC (permalink / raw)
  To: Raymond Toy; +Cc: alsa-devel

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Getting the actual HW sample rate
  2011-09-12 20:29     ` Clemens Ladisch
@ 2011-09-12 20:59       ` Raymond Toy
  0 siblings, 0 replies; 6+ messages in thread
From: Raymond Toy @ 2011-09-12 20:59 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel

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 =
> 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.
>

Well, that explains it of course.  Thanks for your help!

Ray

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-09-12 20:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-07 21:24 Getting the actual HW sample rate Raymond Toy
2011-09-08  8:10 ` Clemens Ladisch
2011-09-08 22:26   ` Raymond Toy
2011-09-12 17:54   ` Raymond Toy
2011-09-12 20:29     ` Clemens Ladisch
2011-09-12 20:59       ` Raymond Toy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.