3

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 .

Aashwin Gaur
  • 41
  • 1
  • 4

1 Answers1

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):


    if(p.get_device_info_by_host_api_device_index(0,i).get
    ('maxInputChannels')):
            print "Input Device id ", i, " - ", 
            p.get_device_info_by_host_api_device_index(0, 
            i).get('name')
Aashwin Gaur
  • 41
  • 1
  • 4