summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2017-09-10 22:00:54 +0200
committerJustin Worthe <justin@worthe-it.co.za>2017-09-10 22:00:54 +0200
commit8cf2f2888cd2b2f48dd0264cf1efe66a46aed2f4 (patch)
treea850500e840046e8ce86349e4d153633c499c5d4 /src
parent9f381cd26fee3926ac0128772e23f6e00681e4e1 (diff)
Removed unnecessary rounding of error
Diffstat (limited to 'src')
-rw-r--r--src/transforms.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/transforms.rs b/src/transforms.rs
index 8c60aad..7d1c829 100644
--- a/src/transforms.rs
+++ b/src/transforms.rs
@@ -1,3 +1,4 @@
+
pub fn remove_mean_offset(signal: &[f32]) -> Vec<f32> {
let mean = signal.iter().sum::<f32>()/signal.len() as f32;
signal.iter().map(|x| x - mean).collect()
@@ -169,7 +170,7 @@ pub fn hz_to_midi_number(hz: f32) -> f32 {
pub fn hz_to_cents_error(hz: f32) -> f32 {
let midi_number = hz_to_midi_number(hz);
- let cents = (midi_number * 100.0).round() % 100.0;
+ let cents = (midi_number % 1.0) * 100.0;
if cents >= 50.0 {
cents - 100.0
}