summaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
authorNebuleon <2391500+Nebuleon@users.noreply.github.com>2023-07-27 19:14:34 -0400
committerGitHub <noreply@github.com>2023-07-27 16:14:34 -0700
commit96789a7cb01b6ac3b6cf46a8dec650ac19c823c0 (patch)
treef0e4bb5bcbd25c959f525e45bd2b1672c0439644 /quantum
parent727b1d159771898888e1e710c4641aa2e447051b (diff)
Unify MIDI note calculation with the audio feature's algorithm (#21588)
Diffstat (limited to 'quantum')
-rw-r--r--quantum/midi/qmk_midi.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/quantum/midi/qmk_midi.c b/quantum/midi/qmk_midi.c
index 43ebd72937..6b8831fb58 100644
--- a/quantum/midi/qmk_midi.c
+++ b/quantum/midi/qmk_midi.c
@@ -108,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;
}
}