[alsa-devel] Increasing maximum sampling frequency?

Cameron Stone camerons.lists at cse.unsw.edu.au
Thu May 28 03:47:34 CEST 2009


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?

I tried hacking aplay.c so arecord would accept command line requests up
to 256k, but it seems the alsa driver is also limiting the frequency to
a maximum of 192k. However, the files generated by arecord *do* have the
right number of samples in them.

$ arecord -v -Dplughw:1,0 test.wav -d 1 -r 256
Recording WAVE 'test.wav' : Unsigned 8 bit, Rate 256000 Hz, Mono
Plug PCM: Linear conversion PCM (S8)
Its setup is:
  stream       : CAPTURE
  access       : RW_INTERLEAVED
  format       : U8
  subformat    : STD
  channels     : 1
  rate         : 256000
  exact rate   : 256000 (256000/1)
  msbits       : 8
  buffer_size  : 128000
  period_size  : 32000
  period_time  : 125000
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 32000
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 128000
  silence_threshold: 0
  silence_size : 0
  boundary     : 2097152000
Slave: Hardware PCM card 1 '8-Mic AVR Adaptor' device 0 subdevice 0
Its setup is:
  stream       : CAPTURE
  access       : MMAP_INTERLEAVED
  format       : S8
  subformat    : STD
  channels     : 1
  rate         : 256000
  exact rate   : 256000 (256000/1)
  msbits       : 8
  buffer_size  : 128000
  period_size  : 32000
  period_time  : 125000
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 32000
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 128000
  silence_threshold: 0
  silence_size : 0
  boundary     : 2097152000
$ 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)
         please, try the plug plugin (-Dplug:default)
$ ls -l test.wav
-rw-r--r-- 1 camerons camerons 256044 2009-05-28 11:29 test.wav
$ file test.wav
test.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 8 bit,
mono 256000 Hz
$




More information about the Alsa-devel mailing list