lcharpen2
Posts: 5
Joined: Tue Apr 05, 2016 2:54 pm

Re: Add an I2S mic using device tree & simple-audio-card

Wed Apr 05, 2017 9:54 am

Hello

Based on this project, I want to integrate the I2S SPH0645LM4H MIC on my raspberry PI 3.
I tried many things but there's only noise coming from the MIC. I made the test with another MIC (ICS43434) and it's working.
Based on this, I suppose something is wrong in the code...

Here is my configuration:

Code: Select all

#define SPH0645LM4H_RATE_MIN 16000 /* Hz, from data sheet */
#define SPH0645LM4H_RATE_MAX 64000  /* Hz, from data sheet */

//this is 32 with 8 last bits always to 0
#define SPH0645LM4H_FORMATS (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE)

static struct snd_soc_dai_driver sph0645lm4h_dai = {
	.name = "sph0645lm4h-hifi",
	.capture = {
		.stream_name = "Capture",
		.channels_min = 1,
		.channels_max = 2,    //should be empty
		.rate_min = SPH0645LM4H_RATE_MIN,
		.rate_max = SPH0645LM4H_RATE_MAX,
		.rates = SNDRV_PCM_RATE_CONTINUOUS,
		.formats = SPH0645LM4H_FORMATS,
    //.sig_bits = 24,
	},
};
Then, to record

Code: Select all

arecord -Dplughw:1 -c2 -r48000 -fS16_LE -twav -d10 -Vstereo test2.wav
I changed fS16_LE to fS24_LE to fS32_LE without success.

Any idea of what's going wrong in my case?

Thanks for your help

robertguy09
Posts: 5
Joined: Thu Mar 30, 2017 9:05 pm

Re: Add an I2S mic using device tree & simple-audio-card

Thu Apr 06, 2017 5:21 am

Still can't get the mics to work, but I found another weird issue that I hope will help narrow my problem down.

When I set the SEL pin to 3.3v and do a recording, the left channel on the recording peaks at 99%.
When I set the SEL pin to gnd and do a recording, the left channel on the record stays at 25%.

Can anyone think of a reason why this would be?

I am trying it with these Adafruit I2S mics.
https://www.adafruit.com/products/3421

robertguy09
Posts: 5
Joined: Thu Mar 30, 2017 9:05 pm

Re: Add an I2S mic using device tree & simple-audio-card

Tue Apr 11, 2017 6:24 pm

I think I figured out the problem. The clock needs to be ~2-4 MHz.

I am not sure what the Pi's clock is set to, but I tested it with the audio library on a Teensy 3.2 and had the exact same problem I had on the Pi (SEL to gnd, left constantly 25%. SEL to 3.3V, left peak at 99%). With the Teensy, the clock is 1.41MHz. So that leads me to conclude the clock was the issue.

I got some ICS43432 mics and everything is working fine with them. Only the SPH0645LM4H are giving me a problem.

Anyone know what the clock is set to on the Pi?
Also, anyway to set the clock for I2S? I couldn't find where it was set from looking through the C file.

gregeric
Posts: 1511
Joined: Mon Nov 28, 2011 10:08 am

Re: Add an I2S mic using device tree & simple-audio-card

Wed Apr 12, 2017 12:03 am

One difference I can see on looking at the datasheets is that the Knowles mic appears to output its data one half a bit clock earlier, 180° out of phase (starting on a CLK high, not low like the Invensys mic). I only have Invensys ICS43432 mics, so cannot do any further comparisons.

robertguy09
Posts: 5
Joined: Thu Mar 30, 2017 9:05 pm

Re: Add an I2S mic using device tree & simple-audio-card

Thu Apr 20, 2017 12:00 am

Has anyone gotten this setup to work with Amazon's Alexa voice services?

Danielya
Posts: 15
Joined: Thu May 04, 2017 12:25 pm

Re: Add an I2S mic using device tree & simple-audio-card

Mon May 15, 2017 8:42 am

Composit wrote:The project is about an intercom solution. So record and playback should be on simoultaneously.

I can load both dtoverlays - looks like this:

Code: Select all

pi@raspberrypi:~ $ sudo dtoverlay -l
Overlays (in load order):
0:  i2s-soundcard  alsaname=mems-mic
1:  hifiberry-dac
But there is always just one entry in /proc/asound/cards

Code: Select all

pi@raspberrypi:~ $ cat /proc/asound/cards
 0 [memsmic        ]: mems-mic - mems-mic
                      mems-mic
depending on the order the dtoverlays are loaded.

So I wonder how to tell Raspi to allow both sound devices at the same time.
It looks as if both devices are loaded as card 0.

Mixing 2 soundcards should be quite simple according to this description - if the two sound cards get registered by Pi:
https://bbs.archlinux.org/viewtopic.php?id=125913

Maybe I should open a new topic since this is no longer a mic problem ;)

Hello there,
I'm facing exactly the same problem mentioned above.
I can only either define my speaker's dtoverlay or the mic's dtoverlay, but not both.

Has someone found a solution to that issue? How to set a new, combined overlay for both?
Thanks.

gregeric
Posts: 1511
Joined: Mon Nov 28, 2011 10:08 am

Re: Add an I2S mic using device tree & simple-audio-card

Mon May 15, 2017 9:13 pm

Google's Voice HAT (ICS43432 mics + MAX98357 DAC) ignores the ICS43432 codec & employs its own machine & codec drivers.

Maybe you could use that as a template, but it would be nice to figure out how to use simple-audio-card & device tree in lieu.

nicoq
Posts: 1
Joined: Thu Apr 13, 2017 3:41 pm

Re: Add an I2S mic using device tree & simple-audio-card

Wed May 31, 2017 11:29 pm

For those who want to use I2S both in Capture and Playback, you'll find everything you need there:
viewtopic.php?p=1001577#p1001577

I tried it with a SPH0645 microphone and JusBoom Hat on Rpi Zero W and all is working !

tmratwork
Posts: 3
Joined: Sun Dec 10, 2017 7:06 am

unable to boost record volume

Sun Dec 10, 2017 7:18 am

i can record in stereo with the following command:

Code: Select all

arecord -Dhw:1 -c2 -r48000 -fS32_LE -twav -d10 -Vstereo test.wav
i followed the tutorial to boost (control) recording volume by updating the .asoundrc file.

when i run the following command, nothing records. same mics, same wiring. command above records static plus my voice. command below records static only.

Code: Select all

$ arecord -Dmic_sv -c2 -r48000 -fS32_LE -twav -d10 -Vstereo test2.wav
Recording WAVE 'test2.wav' : Signed 32 bit Little Endian, Rate 48000 Hz, Stereo
pi@raspberrypi:~ $ 
any ideas?

my .asoundrc file:

Code: Select all

pcm.!default {
        type hw
        card 0
}

ctl.!default {
        type hw
        card 0
}
pcm.mic_hw{
        type hw
        card memsmic
        channels 2
        format S32_LE
}
pcm.mic_mm{
        type mmap_emul
}
pcm.mic_hw{
        type hw
        card memsmic
        channels 2
        format S32_LE
}
pcm.mic_mm{
        type mmap_emul
        slave.pcm mic_hw
}
pcm.mic_rt{
        type route
        slave.pcm mic_mm
        ttable.0.0 1
        ttable.0.1 0
        ttable.1.0 1
        ttable.1.1 0
}
in audacity, mic_hw records, but audacity will not start recording if i select mic_mm, mic_rt, or mic_sv.

tmratwork
Posts: 3
Joined: Sun Dec 10, 2017 7:06 am

boosting record volume

Mon Dec 25, 2017 10:14 pm

i updated .asoundrc to include:

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
}
pcm.mic_mono{
	type multi
	slaves.a.pcm mic_sv
	slaves.a.channels 2
	bindings.0.slave.a
	bindings.a.channel 0
}
then i activated the mixer:

Code: Select all

arecord -Dmic_sv -c2 -r48000 -fS32_LE -twav -d10 -Vstereo test.wav
but when i record using -Dmic_sv nothing records. when i record using -Dhw the stereo recording works, but record volume very low.

any hints? has something changed to break the previous way of boosting mems mic record volume?

ruswest
Posts: 1
Joined: Sun Feb 25, 2018 7:00 pm

Re: Add an I2S mic using device tree & simple-audio-card

Sun Feb 25, 2018 7:13 pm

I have model B of version 2, and microphone ICS43434. Is it possible to configure the P5 connector for recording?

Return to “Interfacing (DSI, CSI, I2C, etc.)”

Who is online

Users browsing this forum: No registered users and 11 guests