1
0
Fork 0

Fix v2s_i32_note_formatter() for negative numbers

Otherwise this would wrap around or panic in debug builds.
This commit is contained in:
Robbert van der Helm 2022-11-12 01:21:18 +01:00
parent 59456a2973
commit c3cd2fb0dd

View file

@ -194,7 +194,7 @@ pub fn s2v_i32_power_of_two() -> Arc<dyn Fn(&str) -> Option<i32> + Send + Sync>
/// C4 and 69 is A4 (nice).
pub fn v2s_i32_note_formatter() -> Arc<dyn Fn(i32) -> String + Send + Sync> {
Arc::new(move |value| {
let note_name = util::NOTES[value as usize % 12];
let note_name = util::NOTES[value.rem_euclid(12) as usize];
let octave = (value / 12) - 1;
format!("{note_name}{octave}")
})