Hi,
I'm trying to convert midi notes to hertz. I didn't do very well in my maths GCSE, and my coding is remedial.
The equation I'm using is here:
modusponem.com/53/midi2hertz/
Frequency(MidiNote) = 2^((MidiNote-69)/12)*440
I'm using this code to check my maths is working - and it clearly isn't (it produces results that are rounded - showing to 2 decimal places. Note 69 is 440, which is correct, but lots of other notes are also 440, which is incorrect.)
Thank you!
Tom
void setup() {
Serial.begin(9600);
}
int note;
float hz;
void loop() {
for (note = 0; note <255; note++){
hz = pow (2.0, ((note-69)/12));
Serial.print("note = ");
Serial.print (note);
Serial.print (" hertz =");
Serial.println(hz*440, DEC);
delay(100);
}
}