Hi forum,
for a guitar to midi project I took a guitar neck, and cut the frets so I can place diodes between them and have a readout of voltage depending on where I press the string.
With a voltage divider I can limit the voltage to a maximum of 5v.
I already built this and it works pretty good and gives me different voltages depending on where I fret the string.
There was a guitar synth in the 80ies that used the same principle.
So now I have to interpret this voltage to a correct pitch for the converter to recognize the notes I play.
The circuit puts out a linear voltage so I would have to map a voltage range to a certain pitch.
E.G. voltage 456mV-634mV -> 440Hz
There are 12 notes on one string. I will have an arduino for every string.
for the note loudness I will develop a circuit that converts the amplitude of the played string to the volume of the tone.
I heard there is a tone library that might help.
Any help is greatly appreciated.
I am very willing to share I progress on this if anyone is interested.
That's a good idea to look for a range voltage and then "snap" to the frequency Or, you can calculate a frequency and then convert to the closest actual note.
If the voltage divider is non-linear (so the voltage is proportional to frequency) you can map() the voltage to frequency for the tone() function.
If it's linear, relative to the position on the fretboard you can't directly use map() and you'd probably need a look-up table. (i.e. Half-way up the fretboard isn't half the frequency in Hz.)
tone() might be a "good start" but, it generates boring square waves with no variation in intensity or tonality. (It will sound like a musical greeting card.) The "regular" Arduino doesn't have a DAC (no true analog output) so it's very-limited unless you add a DAC. Even then processing is limited.
If it was me, I'd make it a MIDI device that sends MIDI messages to your computer. Then you can use standard MIDI software and virtual instruments to generate the actual sound.
I don't know how modern MIDI instruments are made (usually keyboards) but if you want to build the sound-generating part (instead of using your computer) this is the "hard part" and it would take more than a "standard" Arduino.
P.S.
From what I've read, virtual guitar isn't as good as the real thing, but there are ship-loads of virtual instruments so there should be plenty of variety and you can probably find one you like. And, it's not as important if you have full-band or a full virtual band/orchestra) with the guitar as part of a mix. Plus you can use ANY virtual instrument so it doesn't even have to sound like a guitar!
Hey thanks for the info!
I'm not trying to emulate a guitar sound, as I know that a normal guitar comes a lot closer to that
My goal is to be able to play MIDI-sounds a guitarist that doesn't know how to play keyboard.
So the actual sound generation is not the issue. But rather an interface that controls a sound generator.
As I know very little about programming I thought the easiest way (for me) is to make a conversion that plays a certain note which pitch can be recognized by the sound module.
I know that the proper way would be to generate a midi signal (note on, pitch velocity note off) But my knowledge of this is far not enough.
The voltage between the frets is linear. So I can't just convert the voltage to pitch. Thus the idea of the mapping of the voltage to note frequencies.
Ok, so you have a MIDI device as the sound producing module.
Must the produced sound also include the loudness? I believe the tone library only deals with simple square waves, which sound ugly and have exactly one loudness. To vary the loudness, you need more electronics in your circuit which produces the tone for your synth to recognise. Another thing is that you probably want to be able to play several strings at the same time, a six tone polyphony. The guitar synths from the 80's I think could only recognise one tone at a time. It takes modern machine learning to recognise several tones from complex sound.
As people have suggested, do it with MIDI. Forget the frequencies. Read the voltage, look into your lookup table to get the corresponding midi note. Read the loudness if you get that circuit working, too. Now you have the midi note number and velocity. And you can create a note on event. Compare to generating a tone for a guitar synth to recognise, the MIDI approach is way easier. You don't even need a special synth. Your ordinary computer will do for a starter. And you only need one Arduino, not six. It will have time to poll each string at a time.
I don't really see this as a project you accomplish just using the knowledge you have. Do you have all the knowledge about musical note frequencies, about reading the amplitude of a vibrating string, about producing a sound signal with a frequency and an amplitude, about mixing 6 sound signals? These are not rocket science, but MIDI isn't either. To me, the best projects are the ones, where I use some 25% knowledge I have and 75% knowledge I have to acquire.
Yes you can, if you use the map function you can get a fret number out of it. Then all you do is to add the fret number to the MIDI note value of the open string and you get the MIDI note of what you want to play.
Why? This is something you can do with just one Arduino. I assume that each fret is segmented , that is there is a break in the fret between each string. If not it will all short out when more than one string is held down at the same time.
No it wont, it doesn't work like MIDI notes.
That will not work very well as sound modules can't always detect a strings frequency exactly. Getting that to work is harder than the whole project put together.
Hey thanks for your input!
The frets are segmented. Looks kinda weird but it actually can still be played like a normal guitar, only string bending doesn't work anymore.
The circuit is a currentlimiter so no matter where I press down the current is 20mA (can be fine tuned) so the voltage drop is always the same or very close.
For the amplitude I will use a circuit that converts the AC signal from the pickup to a dc voltage. If this works with one string I will build a small pickup for every string individually.
So I have 6 analog voltages to be read for the fretnumber and 6 analog voltages for the note velocity for each string.
The biggest problem for me is to combine these values to create an MIDI note on event. The pitch is always detected, and when a string is played a note on event needs to be released. Later a note off event.
Lucky I told you how to do it in post #8
If there is anything you don't understand about it then please ask.
Do you mean a note on MIDI message needs to be sent? You should do.
The note off MIDI message needs to be sent when your read head no longer detects any vibrations, or when they die down to some threshold level. Changing this threshold value will change the resonance of the Guitar, you could have this on a knob if you like.
You already have a pickup for each string in your 6 string pickup, all you have to do is to wire them up individually.
The guitar looks very cool! But looking at that, I started to think about a different approach. What if we use 18 pins (Arduino Mega or something similar). 6 pins go to the strings, 12 pins go to the frets. Each string pin is set to high at its turn, while the rest of the string pins are low. All 12 fret pins are scanned and the highest fret with high signal is the tone of the string. This goes on constantly in a loop or in a timed interrupt. A separate routine checks the pickups from each string to detect note on and note off.
Hey thanks for the idea.
But the problem with accessing each fret with a separate wire is that 72 wires would need to go to the frets. (The segments times 6)
All frets need to be divided otherwise they will short each other out when depressed.
The voltage method allows for individual readout without having to access every segment.
No. If I connect each string to its own output pin and each fret to its input pin, I can set string 1 high and all other strings low. Then I read each fret. If one fret is high, that fret is pressed with string 1. If several frets are high, only the highest matter. All this is for string 1. Then I set string 1 to low and string 2 to high. And check each fret again. I don't need to cut the frets in 6.
What do I not get here? When I press 3rd fret on 5th string, the string touches 3rd fret and 2nd fret. The string vibrates between 3rd fret and the bridge and I hear C3. It's irrelevant if it touches 2nd fret, it might touch 1st fret, too. When I set the pin of string 5 high and all other string pins low and scan all fret pins, I get high on fret 2 and 3 and maybe on 1. Only #3 matters. I set the tone C3 for string 5. As soon as I detect a pluck on string 5, I fire a note on with C3.
Then I set pin on string 5 low and pin on string 6 high and read again all frets. If all are low, string 6 is free and expecting E2, if plucked. Then I start all over again with string 1.
Numbers refer to pins. When playing a C major I'd scan 2nd string puttingn pin 3 high. Fret 1 would go high. All in red. But since string 4 is pressed at fret 2, the voltage leaks from fret 1 to fret 2 through the 4th string and further from fret 2 to fret 3 through 5th string. All in amber. So the red and amber show which frets go high when string 2 is scanned.