[alsa-devel] Increasing maximum sampling frequency?

Takashi Iwai tiwai at suse.de
Thu May 28 09:28:57 CEST 2009


At Thu, 28 May 2009 08:52:44 +0200,
Clemens Ladisch wrote:
> 
> Lee Revell wrote:
> > On Wed, May 27, 2009 at 9:47 PM, Cameron Stone
> > <camerons.lists at cse.unsw.edu.au> wrote:
> > > I've got a USB microphone application that I want to sample at 256000 8
> > > bit samples per second so I can listen to bats. I know that my device
> > > can get close to that rate, but alsa seems to restrict sampling rates to
> > > 192kHz.
> > > 
> > > Is it possible to push the maximum sampling frequency higher? If so,
> > > where should I start looking?
> > 
> > For starters, try adding a 256K sample rate to include/sound/pcm.h:
> > and sound/core/pcm_native.c:
> 
> This is not necessary; drivers can define whatever sample rate they
> want.  1,792,000 Hz works just fine with the Bt878 driver.
> 
> > $ arecord -v -Dplughw:1,0 test.wav -d 1 -r 256
> > Recording WAVE 'test.wav' : Unsigned 8 bit, Rate 256000 Hz, Mono
> > ...
> > Slave: Hardware PCM card 1 '8-Mic AVR Adaptor' device 0 subdevice 0
> > Its setup is:
> > ...
> >   rate         : 256000
> 
> This indicates that the record PCM stream _does_ use the correct rate.
> 
> > $ aplay -r 256 test.wav
> > Playing WAVE 'test.wav' : Unsigned 8 bit, Rate 256000 Hz, Mono
> > Warning: rate is not accurate (requested = 256000Hz, got = 192000Hz)
> 
> The automatic sample rate converter never uses a frequency higher than
> 192 kHz.
> 
> This maximum frequency is defined in alsa-lib/include/pcm_plugin.h, but
> you cannot change it without changing LINEAR_DIV and the algorithm in
> alsa-lib/src/pcm_pcm_rate_linear.c.

It's anyway better to user other resampler like pph or samplerate
plugins.  And these have no restriction, I guess.

It'd be nicer if the rate plugin itself provides the min/max rates
optionally.  It shouldn't be hard -- just extend the pcm_rate_info_t
to contain the new info.  A version check would be required to make
the backward compatibility, though.


Takashi


More information about the Alsa-devel mailing list