User avatar
Rob Meades
Posts: 17
Joined: Tue Nov 05, 2013 9:12 pm
Location: Saffron Walden, UK
Contact: Website

ALSA microphone volume configuration

Wed Jan 31, 2018 1:42 pm

Following the instructions here I have successfully connected an I2S microphone (ICS43432) to my Raspberry Pi B+ running the lite version of Stretch 4.9.59-v7 (controlled via SSH). However, whatever I do (following the posts here, here and here) I cannot get volume boost to work. Can anyone tell me what I'm doing wrong?

arecord -l shows:

Code: Select all

**** List of CAPTURE Hardware Devices ****
card 1: memsmic [mems-mic], device 0: bcm2835-i2s-ics43432-hifi ics43432-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I know that the device is working because I can record audio with:

Code: Select all

arecord -Dhw:1 -c2 -r16000 -fS32_LE -twav -d10 -Vstereo test_hw.wav

However as predicted, the audio volume is way too low, so I have edited ~/.asoundrc to include the following:

Code: Select all

pcm.mic_hw {
    type hw
    card memsmic
    channels 2
    format S32_LE
}
pcm.mic_mm {
    type mmap_emul
    slave.pcm mic_hw
}
pcm.mic_sv {
    type softvol
    slave.pcm mic_mm
    control {
        name "Boost Capture Volume"
        card memsmic
    }
    min_dB -3.0
    max_dB 50.0
}

...and then run alsamixer to set the Boost Capture Volume to around 30 dB. I can then run:

Code: Select all

arecord -Dmic_sv -c2 -r16000 -fS32_LE -twav -d10 -Vstereo test_mic_sv.wav

...however I get no audio, all the data bytes in the recorded .wav file are zero. If I run:

Code: Select all

arecord -Dmic_mm -c2 -r16000 -fS32_LE -twav -d10 -Vstereo test_mic_mm.wav

...then that does capture audio but, of course, with the very low volume.

Can anyone tell me what I am doing wrong with the Capture Volume boost section of my ALSA configuration file?

FYI, /var/lib/alsa/asound.state contains the lines:

Code: Select all

state.memsmic {
        control.1 {
                iface MIXER
                name 'Boost Capture Volume'
                value.0 167
                value.1 167
                comment {
                        access 'read write user'
                        type INTEGER
                        count 2
                        range '0 - 255'
                        tlv '0000000100000008fffffed400000014'
                        dbmin -300
                        dbmax 4800
                        dbvalue.0 3040
                        dbvalue.1 3040
                }
        }
}

...so I believe that alsamixer is setting the capture volume boost to 30.4 dB as intended.
Rob Meades
http://www.meades.org

HiassofT
Posts: 226
Joined: Fri Jun 30, 2017 10:07 pm
Location: Salzburg, Austria
Contact: Website

Re: ALSA microphone volume configuration

Thu Feb 01, 2018 12:58 pm

Testing softvol with the following .asoundrc worked fine with my Cirrus Logic audio card:

Code: Select all

pcm.softvol {
    type            softvol
    slave.pcm       "plughw:RPiCirrus"
    control.name    "Softmaster"
    control.card    RPiCirrus

    min_dB      -10.0
    max_dB      50.0
}

You don't need mmap_emul (bcm2835-i2s supports mmap) and restricting channel/format usually isn't necessary either. plughw, the default alsa device, can take care about format/rate conversion, if you don't need/want that you can also use hw:... as the slave.

If you replace the two "RPiCirrus" occurences with "memsmic" you should have a working setup.

so long,

Hias

User avatar
Rob Meades
Posts: 17
Joined: Tue Nov 05, 2013 9:12 pm
Location: Saffron Walden, UK
Contact: Website

Re: ALSA microphone volume configuration

Thu Feb 01, 2018 8:34 pm

That's excellent, many thanks. FYI the critical change was removing the mmap part. i.e. the minimal change I needed was:

Code: Select all

pcm.mic_hw {
    type hw
    card memsmic
    channels 2
    format S32_LE
}
pcm.mic_sv {
    type softvol
    slave.pcm mic_hw
    control {
        name "Boost Capture Volume"
        card memsmic
    }
    min_dB -3.0
    max_dB 50.0
}

...which results in a working capture volume control. But most of the rest is also not required and I can hear clearly now :-).
Rob Meades
http://www.meades.org

Return to “Raspbian”