I am looking to use the GPIO on a Raspberry Pi to get data from an ADC for audio signal processing.
For the purposes of this forum, my project is to produce a spectrum analyzer which will display the audio spectrum of some music playing on a projector through HDMI. This is to be used as visuals for a music event at university.
The first idea I had was to use an ATMega-328 (arduino mcu) to collect audio samples using the analog inputs, and send the data to the R-Pi using the digital io pins.
I believe that unless I program the ATMega-328 using machine code (asm), the performance will be poor. For example, I understand that using digitalWrite()
, peak performance is about 230 Hz, as these functions are not implemented efficiently in the arduino libraries. http://www.codeproject.com/Articles/732646/Fast-digital-I-O-for-Arduino
Okay so this link has alternative libraries, but performance isn't as high as 44100 Hz. Realistically, I would like to achieve about 8 kHz sample rate, at 10 bits per sample.
In addition, the maximum sample rate of the ADC in the ATMega-328 (which is a 10 bit ADC, or will work as one with a precision reference) is about 10 kHz.
I then thought that an I2C device might provide increased performance. This device can sample 100 kHz.
The performance of the R-Pi's io should be greater than 1 MHz, but not higher than about 22 MHz. This should be adequate to carry the required data.
I then read about I2S devices on wikipedia, and understand that the R-Pi has only I2S output, as the pins for I2S input are not connected. (So that was a dead end?)
My question comes down to:
1: Are there any alternatives or better methods I have not considered? Which method would you recommend for this application?
2: Are there any improvements I can make to the second method described (using an external ADC with I2C) to increase performance, baring in mind that FFT's are computationally intensive, and there might not be much time for computing them, even at 900 MHz / 1 GHz clock speed on the R-PI.
Also I am a Physics student, so I know sort of what I'm doing, but I don't have much training in electronics.
I considered using something like the Wolfson Audio board but I understand that it is difficult to setup and use. I am not confident that I would be able to write a program to collect 1024 audio samples and process them using this board. This is where question 3 comes in: Has anyone used this board for a project, and would it be suitable for something like what I am trying to do?
Obviously these questions are quite open-ended. If you want a closed question, then that can be "how do I go about implementing this project that I want to build."