Go Down

### Topic: Guitar signal processing (Read 1 time)previous topic - next topic

#### OlivierG

##### Jun 01, 2011, 04:30 am
I would like to use the Arduino to process my guitar signal, for example (already tried apparently) convert its signal into a MIDI signal. I have successfully input some MIDI notes to my computer using the Arduino, that part was pretty easy. But I can tell that audio signal processing is another story entirely...

First off, what would be the best way to amplify the signal to a working voltage? Op-amp? Transistors? Can anyone point me to a circuit that would do the trick?

Then I suppose I would have to offset the input voltage somewhat so that instead of having for example a -1V / +1V amplitude I'd have a +1V / +3V amplitude since the Arduino cannot process negative voltages?

After that how to analyse the frequency and extract the main frequency of the signal? It seems like an FFT might require too much processing power for the Arduino. Would I be better off just buying a frequency to voltage converter? How would that chip cope with, say, concurrent signals, like if I play a chord? Would I need one per string?

Any pointers would be greatly appreciated! Thanks!

#### GeniusPro

#1
##### Jun 03, 2011, 04:57 am
Try this schematic:  Find any small NPN transistor, a 100K to about 470K resistor (220K), a capacitor >= 1uF to 47uF (polarized capacitor at 10V min rating is ok), a 4.7K resistor, (1/4 or 1/8 watt  ok for both resistors).
Connect one side of the around 220K ohm resistor to the collector of the NPN transitor.
Connect one side of the 4.7K resistor to +5 V.
Connect the other side of the about 220k resistor to the base of the NPN transistor and to the + connection of the capacitor.
Connect the other side of the 4.7K resistor to the collector of the NPN transistor and to the input Arduino pin.
Connect the negative lead of the capacitor to the guitar output, the shield of the connector/cable to the analog Arduimo circuit ground.

This circuit should give you a amplified and yet clipped and optimally distorted signal to an analog input Arduino pin, which is nice, so you just can count the time in milliseconds or microseconds between sequential peaks (maximal A/D readings) of guitar signal voltages after A/D conversion. This will give you the period (1/Freq) of the frequency (tone) of the most dominant vibration of one or more strings. Then, use this frequency to generate MIDI tones. Code to analyze the A/D results and discard short(harmonics) or seemingly random pulse width readings(Plucking the string). But use the time readings between consistent larger duration peaks...this will give you the period of the tone played.

Start a timer at the detection of the first peak near +5V, stop the timer at the detection of the second maximal peak. Take 5 or more samples. Discard readings too short or long relative to the actual tone ranges. Take several readings and use comparisons to find which periods that make up the majority of the samples, those readings to use are those that match somewhat closely...this is the statistical true period of the tone played. Only a few A/D readings should quickly give you the tone period info you need.

#### Grumpy_Mike

#2
##### Jun 03, 2011, 01:50 pm
Quote
After that how to analyse the frequency and extract the main frequency of the signal

And that as they say is the rub. It is almost impossible to do and is actually impossible to do well. Even with a processor much more capable than the arduino it is impossible to obtain perfect results. Just look at the number of successful commercial units there are.
The main problem is detecting what octave you are in with al, the harmonics and a simple FFT is not going to cut it. All this is for one string, if you want to do all six at the same time forget it.
Sorry but this is much much harder than you think

Go Up