1
0
Fork 0

Remove 128 note MIDI limit in frequency parser

This is useful when the value->string function can go outside of the
standard 128 note range.
This commit is contained in:
Robbert van der Helm 2022-11-12 01:03:55 +01:00
parent 5330a7d938
commit 59456a2973

View file

@ -157,12 +157,12 @@ pub fn s2v_f32_hz_then_khz() -> Arc<dyn Fn(&str) -> Option<f32> + Send + Sync> {
note_formatter(midi_note_number_str),
cents_str.parse::<i32>(),
) {
let plain_note_freq = util::midi_note_to_freq(midi_note_number.clamp(0, 127) as u8);
let plain_note_freq = util::f32_midi_note_to_freq(midi_note_number as f32);
let cents_multiplier = 2.0f32.powf(cents as f32 / 100.0);
return Some(plain_note_freq * cents_multiplier);
}
} else if let Some(midi_note_number) = note_formatter(string) {
return Some(util::midi_note_to_freq(midi_note_number.clamp(0, 127) as u8));
return Some(util::f32_midi_note_to_freq(midi_note_number as f32));
}
// Otherwise we'll accept values in either Hz (with or without unit) or kHz