1

Working on an Arduino + Raspberry Pi project and hoping that this question fits into this category. I'm recording audio using a MEMS microphone on the Arduino and transmitting it over to the Pi to store in a playable file (WAV).

What I currently have setup is TCP transmission from the Arduino to the RaspPi. This part is fine and dandy for the purpose of seeing the data transmission that I am looking for.

Where my issue lies, is the audio data being recorded on the Arduino. At the moment, I see data from my analogRead() function displaying like the following:

2035
2046
2030
2031
2044
2038
2034
2031
2034
2019
2028
2030
2024
2032
2028

My question is, what does this mean? How would I translate this, preferably on the Pi, as usable data that I can store in a WAV file?

Any libraries or hints/clues that can steer me in the right direction would be great.

  • That's probably not going to work, or at least not well especially if you need to record at decent quality or for more than a fraction of a second without skipping. Network interfaces introduce substantial packetization latency, and the Arduino doesn't really have enough memory to store data until it can be sent, plus its ADC is fairly marginal for audio quality sampling to begin with. If you want to stick the with Arduino you may do better with high baud rate serial since that is streaming rather than buffered, but really an Arduino is not the right choice here. – Chris Stratton Oct 6 '15 at 5:40
1

Why use the arduino, when you can use the Pi directly? I would get a high quality ADC, connect the mic to it, and then make the Pi write the value from the ADC directly to file. The arduino simply isn't fast enough for good quality audio recording - the ADC is 10-bit, 9.6 khz. At best you could get a stereo 8-bit 8khz wav file. With a good ADC on the Pi, you would be able to go up to stereo, 16-bit(maybe even 24-bit), 44.1 khz. Also, the Arduino would be massively slowed down by sending the data, so the actual sample rate would be much lower.

-1

It's difficult to answer this without seeing any code, but I will take a wild guess and assume you are not using any sort of FFT processing on the input. You could try looking into this library. Alternately, people seem to have good luck with this one too.

  • 1
    This is not a meaningful answer to the question asked. There is no reason to do an FFT as the goal is a .wav file, ie, linear PCM data in the time domain. Nor is an Arduino fast enough to do a continuous FFT of audio without throwing away the vast majority of the collected information - so even if a frequency domain representation (or alternately filtering in the frequency domain and transformation back) were desired, it would appropriately be done on the pi, not the Arduino. – Chris Stratton Nov 6 '15 at 2:14

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.