How to use the MVC (volume control) with the Adafruit I2S Microphone

I have the Adafruit Microphone working, but I’m not able to get the MVC Volume control to work.

This document describes how it works, but apparently I’m doing something wrong.

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide%2Fasoc_driver.17.2.html%23wwpID0E0SH0HA

Reset Mixer Controls
$alsactl init tegrasndt210ref

Verify that I2S4 is mapped to ADMAIF1
amixer -c tegrasndt210ref sget "ADMAIF1 Mux" amixer -c tegrasndt210ref sget “I2S4 Mux”

Make sure that the 'MVC1 Channels" is set to 0 so that it acts on all 8-channels.
amixer -c tegrasndt210ref sget ‘MVC1 Channels’

I use the following to verify that the audio is working from the Mic.
$ arecord -D hw:tegrasnd210ref,0 -r 44100 -f S32_LE -c 1 -d 10 test.wav

It does, but it’s really quiet.

The following wasn’t successful in connecting up MVC1 to the audio input, and adjusting the volume of it.

$amixer -c tegrasndt210ref cset name=‘I2S4 Mux’ MVC1
$amixer -c tegrasndt210ref cset name=‘MVC1 Mux’ ADMAIF1
$amixer -c tegrasndt210ref cset name=‘MVC1 Vol’ 12000

Where I use the same arecord command line to test it, and the above doesn’t change the volume regardless of whether I use a volume of 0 (max attenuation) or 16,000 (max gain)

I think I have the MVC configured incorrectly.

I think it needs to be connected like this
amixer -c tegrasndt210ref cset name=“MVC1 Mux” I2S4
amixer -c tegrasndt210ref cset name=“ADMAIF1 Mux” MVC1

Edit: It does adjust the gain, but it introduces other issues and sounds horrible.

Hello!

Does it sound bad even without the MVC in the path?

I gave this a try with my Nano and the Adafruit I2S MEMS Mic [0] and it sounds fine. I did not hear any distortion/noise. Note I was capturing the audio and playing back on my desktop.

I assume that you are using the latest L4T/Jetpack release.

Regards,
Jon

[0] https://www.adafruit.com/product/3421

Without the MVC in the path it’s not any worse than a similar microphone attached via an analog audio to USB dongle. The I2C Mic is roughly equivalent to that when no gain is used on either.

When I tried the above configuration (after I realized I had hooked up the MVC incorrectly in the initial post) I was having two problems.

The first problem was that when I would record using an MVC volume of 14,000 it wouldn’t play back as expected with aplay. I knew it was sort of working because initially it was louder, but then the 2kHz tone I recorded would drop out. This morning I copied the files to my PC, and they played back as expected within Audacity. So apparently it was something with aplay.

The second problem was the spectrograph software I was trying out would show the microphone signal going down with greater gain values. Like it would start off slightly negative, and then go down. I haven’t been able to get this SW to work with the I2S Mic, but it works great with the USB attached Microphone. On the I2S without the MVC it seems to almost work (but, only in the 16bit audio mode which isn’t ideal for the I2S Mic). Almost in that if I made a loud noise then the FFT will start to work just for the duration of the loud noise. Hence why I needed the MVC, but it doesn’t seem to work with it.

Here is a link to the spectrograph python app
https://github.com/flothesof/pyqtgraph-spectrographer

Here is a link to the recorded files
https://drive.google.com/file/d/1cVmAj6s8owm9IwZieMlrIG0JLGi_RymK/view?usp=sharing

Hello!

Was that with aplay on the PC or Nano which was not working? I used aplay to play the file on my PC and it was working OK.

I should also point out that the MVC has two modes of operation; linear and poly. By default it uses linear but you can also try the poly mode by …

amixer -c tegrasndt210ref cset name="MVC1 Curve Type" Poly

For the poly mode the vol can be set between 0 and 100. However, not sure if this will make any difference but could be worth a try.

I believe that the mics are only 32-bit. I don’t see a way to configure for 16-bit output. However, it is possible to convert from 16-bit to 32-bit if needed. Does the USB mic use 16-bit or 32-bit samples? How many channels does the USB mic output?

Regards,
Jon

aplay on the nano wasn’t working correctly with the clipped 32bit wav files.

The USB Mic is 16bits, and I believe its a single channel.

The I2S Mic is 24bits (18 which are usable, and the rest are just zeros), but it’s my understanding that you can use 16bit transfers and simply give up the least significant bits.

I tested 16bit and 32bit with arecord and couldn’t tell the difference volume wise. I do recall running into an issue where 16bit mode wasn’t working at all in the beginning, and I had to use 32bit. It works now so I don’t know what changed.

My next step with it is to force/verify a clock of 4.096MHz as I need sensitivity between 10Khz, and 20Khz.

What was the playback device? USB speaker? HDMI? Something else?

I guess it would probably work. I2S is always 2 channels at the interface level but if you are only capturing one channel, then it would probably not matter if the other contains the LSBs of the first as this is being discarded anyway.

Regards,
Jon