0

I'm attempting to change the default sample rate when recording audio with arecord.

Currently, when running arecord test.wav the rate is 8000 Hz:

arecord test.wav Recording WAVE 'test.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono 

I can change the sample rate using the rate flag --rate 44100:

arecord --format S16_LE --rate 44100 test.wav Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono 

But when I change the rate in asound.conf, it has no effect on recording (rate stays at 8000 Hz). Am I missing something?

My asound.conf:

# The IPC key of dmix or dsnoop plugin must be unique # If 555555 or 666666 is used by other processes, use another one # use samplerate to resample as speexdsp resample is bad defaults.pcm.rate_converter "samplerate" pcm.!default { type asym playback.pcm "playback" capture.pcm "capture" } pcm.playback { type plug slave.pcm "dmixed" } pcm.capture { type plug slave.pcm "array" } pcm.dmixed { type dmix slave.pcm "hw:wm8960soundcard" ipc_key 555555 } pcm.array { type dsnoop slave { pcm "hw:1,0" format S16_LE rate 44100 channels 1 } ipc_key 666666 } 

Ouput of arecord -L

null Discard all samples (playback) or generate zero samples (capture) jack JACK Audio Connection Kit pulse PulseAudio Sound Server default eci eco usbstream:CARD=Headphones bcm2835 Headphones USB Stream Output sysdefault:CARD=wm8960soundcard wm8960-soundcard, bcm2835-i2s-wm8960-hifi wm8960-hifi-0 Default Audio Device dmix:CARD=wm8960soundcard,DEV=0 wm8960-soundcard, bcm2835-i2s-wm8960-hifi wm8960-hifi-0 Direct sample mixing device dsnoop:CARD=wm8960soundcard,DEV=0 wm8960-soundcard, bcm2835-i2s-wm8960-hifi wm8960-hifi-0 Direct sample snooping device hw:CARD=wm8960soundcard,DEV=0 wm8960-soundcard, bcm2835-i2s-wm8960-hifi wm8960-hifi-0 Direct hardware device without any conversions plughw:CARD=wm8960soundcard,DEV=0 wm8960-soundcard, bcm2835-i2s-wm8960-hifi wm8960-hifi-0 Hardware device with all software conversions usbstream:CARD=wm8960soundcard wm8960-soundcard USB Stream Output 

Addition

How to change the default arecord sample rate when using PJUSA(PJSIP):

PJUSA initializes ALSA at launch:

11:56:12.951 alsa_dev.c ..ALSA driver found 32 devices 11:56:12.951 alsa_dev.c ..ALSA initialized 

alsa_dev.c is located at pjproject/pjmedia/src/pjmedia-audiodev/alsa_dev.c

The default sample rate is set in line 270:

/* Set the default sample rate */ adi->default_samples_per_sec = 8000; 

Just change the value to the desired sample rate (microphone has to be capable of that sample rate).

2
  • Can you please post the output of arecord -L ? Commented Jun 23, 2021 at 14:26
  • Added the output to my inital post. Commented Jun 24, 2021 at 9:26

1 Answer 1

0

Reading the documentation for arecord (see man arecord) it writes,

-r, --rate=#<Hz> Sampling rate in Hertz. The default rate is 8000 Hertz. [...]

So you can see that the rate is not controlled through asound.conf; it's controlled using this command-line flag.

2
  • Thanks! Do you know if there is another way for other apps (e.g. PJUSA; works with ALSA) to manipulate that rate? Commented Jun 24, 2021 at 9:30
  • 1
    Nevermind - just solved this question myself. Thanks for pointing me in the right direction. I will add this additional info to my original post. Commented Jun 24, 2021 at 10:04

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.