1

I want to record sound using an electret microphone and ADC(MCP3002), with Raspberry Pi 2 model B.

  1. 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?

  2. 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 Mar 19 '16 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 Mar 19 '16 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 Mar 19 '16 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/24463431 – PaulF8080 Oct 19 '16 at 7:46
1
  1. yes, no problem
  2. yes, but make sure to check a pull-up 4k resistor on data line and power on SPI interface line.
  • 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 Mar 19 '16 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 simple – Alexey Vesnin Mar 19 '16 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 Mar 20 '16 at 15:28
  • send me an output of uname -a – Alexey Vesnin Mar 20 '16 at 15:37
  • The output is: Linux raspberrypi 4.1.19-v7+ #858 SMP Tue Mar 15 15:56:00 GMT 2016 armv7l GNU/Linux – alon Mar 20 '16 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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