So i have managed to get input from a microphone using I2S interface following this link . https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/raspberry-pi-wiring-and-test

if i use the following command to record audio and then playback.. the volume level is pretty high: arecord -D dmic_sv -c2 -r 48000 -f S32_LE -t wav -V mono -v recording.wav

Note: the Alsamixer mic volume is 100% . and the i2s driver installed doesnt come with a volume control feature. Hence I use a soft_vol config in the ~/.asoundrc for the volume ctrl of the mic .

The problem begins here . I am using the pyaudio module for python to record the stream . It gets recorded all fine But the volume is too low . Is there a way to turn it up a bit .

  • Can you please be more specific here? Do you wanna tune a microphone input gain or do you wanna tune the volume output?
    – user91822
    Oct 15, 2018 at 12:36
  • I want to tune the input gain . Basically i need a pyaudio call which can manipulate slave devices as well . Oct 15, 2018 at 13:34
  • i know i can increase the microphone input volume level by editing the ~/.asound file using soft_val . But when i do this a virtual slave device called dmic_sv is created with the high input gain . The pyaudio API provides a call to open the audio stream using the index number of the device .And so when i input the index number , the original device without the input gain settings opens up . Oct 15, 2018 at 13:55

1 Answer 1


Ok I found the solution. First edit the ~/.asound file (If its not there , create it).Add the following

pcm.dmic_hw {
type hw
card sndrpisimplecar    
channels 2
format S32_LE

pcm.dmic_sv {
type softvol
slave.pcm dmic_hw
control {
    name "Boost Capture Volume"
    card sndrpisimplecar
    min_dB -3.0
    max_dB 30.0

As you can see this virtual slave device is named dmic_sv Make a note of that . Now create a test file with the following python code . It will list the indexes of all the soundcard connected devices including the virtual ones . (Tried and tested on Raspberry Pi 3B+).

import pyaudio
p = pyaudio.PyAudio()
info = p.get_host_api_info_by_index(0)
numdevices = info.get('deviceCount')

for i in range(0, numdevices):

            print "Input Device id ", i, " - ", 
  • if by chance the software device doesn't show up add the contents of ~/.asound to /usr/share/alsa/alsa.conf Oct 15, 2018 at 14:25
  • If you fixed the problem, mark this answer as correct when you can please. Jan 19, 2020 at 9:04
  • Note that after adding the config to the file, you need to use the device once before it will show up in alsamixer Feb 5, 2022 at 3:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.