I want to record sound using an electret microphone and ADC(MCP3002), with Raspberry Pi 2 model B.
Can I sample audio using the SPI interface on the Pi? I am using one microphone, and I need to get at least 20k samples per second. Can the Pi handle such speed?
My goal is to do that with 10 microphones simultaneously. Can I do that this way?
-
Re 1) Do the samples need to be accurately spaced in time? If so how accurately? Re 2) Do the samples for each microphone have to be made at the same instant in time?joan– joan2016年03月19日 18:11:17 +00:00Commented Mar 19, 2016 at 18:11
-
The samples need to be at the same time, in a way that I will achieve the physical effect of phased array. I know I can't do it exactly at the same time, but i want to reduce it as far as I can. I can deal with a very small error.alon– alon2016年03月19日 23:40:03 +00:00Commented Mar 19, 2016 at 23:40
-
You can sample all microphones at exactly the same time using bit banged SPI. I have only used 5 ADCs myself but the principal should apply to 10 ADC. Have a look at raspberrypi.org/forums/viewtopic.php?f=44&t=71089. I suspect that technique has the best chance of working on the Pi.joan– joan2016年03月19日 23:45:40 +00:00Commented Mar 19, 2016 at 23:45
-
I saw a project where they used digital MEMs microphones for the array. The mics have the ADC built in and use the standard audio i2s interface. ncbi.nlm.nih.gov/pubmed/24463431PaulF8080– PaulF80802016年10月19日 07:46:07 +00:00Commented Oct 19, 2016 at 7:46
1 Answer 1
- yes, no problem
- yes, but make sure to check a pull-up 4k resistor on data line and power on SPI interface line.
answered Mar 19, 2016 at 15:32
-
Thank you! I am still having a problem: I tried to sample one microphone, and checked the sampling rate. The highest rate I was able to acheive was 35Khz, but for 10 microphones I will need approximately 20Khz * 10 = 200Khz. Does my result reasanable for the raspberry? what can I do to improve my rate? My code is written In C, and I used the wiringPi library.alon– alon2016年03月19日 23:24:18 +00:00Commented Mar 19, 2016 at 23:24
-
@alon first, try it and just measure a speed. Second - if the first test fails/unsatisfies - use the latest stable kernel from kernel.org with HZ=1000 <-- it is se via
make menuconfig
, speaking simpleAlexey Vesnin– Alexey Vesnin2016年03月19日 23:31:25 +00:00Commented Mar 19, 2016 at 23:31 -
I changed timer frequency to 1000hz, but still the highests sampling rate I get is 35Khz. Do you have any other ideas?alon– alon2016年03月20日 15:28:00 +00:00Commented Mar 20, 2016 at 15:28
-
send me an output of
uname -a
Alexey Vesnin– Alexey Vesnin2016年03月20日 15:37:42 +00:00Commented Mar 20, 2016 at 15:37 -
The output is: Linux raspberrypi 4.1.19-v7+ #858 SMP Tue Mar 15 15:56:00 GMT 2016 armv7l GNU/Linuxalon– alon2016年03月20日 15:46:14 +00:00Commented Mar 20, 2016 at 15:46