Skip to content

Commit a653c4b

Browse files
committed
midi note conversion
1 parent 379dbd3 commit a653c4b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/AudioTools/MusicalNotes.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@ class MusicalNotes {
191191
}
192192

193193
/// Determine frequency of MIDI note
194-
float midiNoteToFrequency(uint8_t x) {
195-
int a = 440; //frequency of A (coomon value is 440Hz)
196-
return (a / 32) * pow(2, ((x - 9) / 12));
194+
float midiNoteToFrequency(int x) {
195+
float a = 440; //frequency of A (coomon value is 440Hz)
196+
return (a / 32) * pow(2, ((x - 9) / 12.0));
197197
}
198198

199199
/// Provide MIDI note for frequency
200-
uint8_t frequencyToMidiNote(float freq) {
201-
return log(freq/440.0)/log(2) * 12 + 69;
200+
int frequencyToMidiNote(float freq) {
201+
return log(freq/440.0)/log(2) * 12.0 + 69.0;
202202
}
203203

204204
protected:

0 commit comments

Comments
 (0)