diff --git a/gen_pitch_table.py b/gen_pitch_table.py index 208fe98..5e46329 100644 --- a/gen_pitch_table.py +++ b/gen_pitch_table.py @@ -39,6 +39,7 @@ def pitch_to_name(pitch): return pitch_names[(pitch - pitch_A0) % 12] + str(int((pitch - pitch_C1) / 12) + 1) print("#pragma once") +print("#include ") print("") print("constexpr unsigned int midi_pitch_offset = " + str(start_pitch) + ";") print("constexpr unsigned int midi_pitch_max = " + str(end_pitch) + ";") @@ -58,7 +59,7 @@ print("") print("// scale factors for bend values from 0 to 255") print("// We don't support the full 16385 levels of MIDI bend") print("// MIDI bend values have to be converted first to the nearest supported one") -print("constexpr float midi_pitch_bend_scale[256] = {") +print("constexpr PROGMEM float midi_pitch_bend_scale[256] = {") for i in range(0, 256): factor = pow(2, (8192 - i * 64) / 49152) diff --git a/motor_control.cpp b/motor_control.cpp index 26ed1ea..7dc0843 100644 --- a/motor_control.cpp +++ b/motor_control.cpp @@ -41,7 +41,7 @@ void MotorControl::TickPitchBend(int bend) { // Scale the MIDI bend value down to 0 - 255 bend = bend / 64; - tick_period_half_micros = (unsigned long) (((float) tick_period_orig_half_micros) * midi_pitch_bend_scale[bend]); + tick_period_half_micros = (unsigned long) (((float) tick_period_orig_half_micros) * pgm_read_float_near(midi_pitch_bend_scale + bend * sizeof(float))); } void MotorControl::TickOff() {