summaryrefslogtreecommitdiff
path: root/quantum/midi/qmk_midi.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/midi/qmk_midi.c')
-rw-r--r--quantum/midi/qmk_midi.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/quantum/midi/qmk_midi.c b/quantum/midi/qmk_midi.c
index f6a5d92281..6b8831fb58 100644
--- a/quantum/midi/qmk_midi.c
+++ b/quantum/midi/qmk_midi.c
@@ -5,6 +5,11 @@
#include "usb_descriptor.h"
#include "process_midi.h"
+#ifdef AUDIO_ENABLE
+# include "audio.h"
+# include <math.h>
+#endif
+
/*******************************************************************************
* MIDI
******************************************************************************/
@@ -103,10 +108,10 @@ static void fallthrough_callback(MidiDevice* device, uint16_t cnt, uint8_t byte0
if (cnt == 3) {
switch (byte0 & 0xF0) {
case MIDI_NOTEON:
- play_note(((double)261.6) * pow(2.0, -4.0) * pow(2.0, (byte1 & 0x7F) / 12.0), (byte2 & 0x7F) / 8);
+ play_note(440.0f * powf(2.0f, ((byte1 & 0x7F) - 57) / 12.0f), (byte2 & 0x7F) / 8);
break;
case MIDI_NOTEOFF:
- stop_note(((double)261.6) * pow(2.0, -4.0) * pow(2.0, (byte1 & 0x7F) / 12.0));
+ stop_note(440.0f * powf(2.0f, ((byte1 & 0x7F) - 57) / 12.0f));
break;
}
}