pitch_table: expand bend to 2048 levels
This commit is contained in:
parent
7a3f62499f
commit
dea29d97fc
|
@ -56,13 +56,13 @@ for i in range(start_pitch, end_pitch):
|
|||
print("};")
|
||||
|
||||
print("")
|
||||
print("// scale factors for bend values from 0 to 255")
|
||||
print("// scale factors for bend values from 0 to 2047")
|
||||
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 PROGMEM float midi_pitch_bend_scale[256] = {")
|
||||
print("constexpr PROGMEM float midi_pitch_bend_scale[2048] = {")
|
||||
|
||||
for i in range(0, 256):
|
||||
factor = pow(2, (8192 - i * 64) / 49152)
|
||||
for i in range(0, 2048):
|
||||
factor = pow(2, (8192 - i * 8) / 49152)
|
||||
print(" " + str(factor) + "f,\t// " + str(i))
|
||||
|
||||
print("};")
|
|
@ -38,8 +38,8 @@ void MotorControl::TickPitchBend(int bend) {
|
|||
if (bend < 0 || bend >= 16384) return;
|
||||
if (tick_period_orig_half_micros == 0) return;
|
||||
|
||||
// Scale the MIDI bend value down to 0 - 255
|
||||
bend = bend / 64;
|
||||
// Scale the MIDI bend value down to 0 - 2047
|
||||
bend = bend / 8;
|
||||
|
||||
tick_period_half_micros = (unsigned long) (((float) tick_period_orig_half_micros) * pgm_read_float_near(midi_pitch_bend_scale + bend * sizeof(float)));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue