1
0
Fork 0

Fix rounding error in v2s_f32_hz_then_khz_with_note_name

This commit is contained in:
Robbert van der Helm 2023-01-10 01:43:17 +01:00
parent 26422ae8e3
commit b647f24121

View file

@ -146,7 +146,7 @@ pub fn v2s_f32_hz_then_khz_with_note_name(
// This is the inverse of the formula in `f32_midi_note_to_freq`
let fractional_note = util::freq_to_midi_note(value);
let note = fractional_note.round();
let cents = ((fractional_note - note) * 100.0) as i32;
let cents = ((fractional_note - note) * 100.0).round() as i32;
let note_name = util::NOTES[(note as i32).rem_euclid(12) as usize];
let octave = (note as i32 / 12) - 1;