audio examples not working under linux

At least for me, with Audio device: Intel Corporation 82801G and ubuntu 7.10, the audio examples doesn’t work. The error is:

RtApiAlsa: error setting sample rate (22050) on device (hw:Intel,0): Invalid argument.

Changing the sample rate to 44100 works without problem

yeah I have the same issues on my ubuntu install, I wonder if isn’t that alsa is very inflexible about sample rates. it’s seems to me that 22050 should be an acceptable rate, and I am surprised that it doesn’t work… perhaps there is something about alsa we need to know / implement that allows for certain types of sample rates… for some folks it just works, out of the box, and I wonder why that is.

  • zach

22050 does work for me on Ubuntu 7.04 and Intel ICH6 with SigmaTel STAC9750 chip.

I think it has more to do with how rtAudio handles sample rates. My suggestion is to try the latest rtAudio (4.0.3) and see if it solves the problem (I put this on the wiki btw zach)…
This will break the API though, so you’ll have to tinker a bit.

it seems it’s not an error, looking at the device properties:

$ cat /proc/asound/card0/codec#0

Codec: SigmaTel CXD9872RD/K
Address: 0
Vendor Id: 0x83847661
Subsystem Id: 0x104d0c00
Revision Id: 0x104201
Default PCM:
rates [0x7e0]: 44100 48000 88200 96000 176400 192000
bits [0xe]: 16 20 24

And looking in the web the technical specs for the last intel devices (ICH7 family) it seems right. Hasn’t tried it under windows but if it works perhaps the driver generates the missing samples till 44100

If I’m not mistaken I think the latest rtAudio will do a better job of choosing the next best available sample rate, so that you don’t get an “error setting sample rate”.

In the rtAudio bug fix list:
http://www.music.mcgill.ca/~gary/rtaudio/bugs.html
rtAudio version 4.0 uses snd_pcm_hw_params_set_rate_near()

According to the Alsa docs, in one of the playback examples they quote:

After that, we set the sample rate of our stream, in Hz. Note that the functions we use is called snd_pcm_hw_params_set_rate_near, meaning the actual sample rate set may not match the sample rate we specify. For this reason the function takes a pointer to an unsigned integer, so it can change the value of our rate variable to reflect the actual rate set. There’s also a function snd_pcm_hw_params_set_rate, which doesn’t take a pointer, and will try to set the sample rate to the exact rate you specify. It’s likely that this will fail on different sound devices though.