summaryrefslogtreecommitdiff
path: root/src/transforms.rs
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@gmail.com>2017-01-17 21:08:36 +0200
committerJustin Worthe <justin.worthe@gmail.com>2017-01-17 21:08:36 +0200
commit12d372a646370d01c7f2e0038d98bf04b45c2bed (patch)
treec8a557187af7ca10407b3c8f5d17efe5aee25b55 /src/transforms.rs
parentb4f87e573f2ba4acc01af49e0887779d75bcd08d (diff)
Added drawing area for correlation, but hid all graphs
The current method of sending all that data with channels turns out to be terrible for performance. On the other hand, I need to get the data to the GTK main thread if I want to do anything with it. So I have a conundrum.
Diffstat (limited to 'src/transforms.rs')
-rw-r--r--src/transforms.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/transforms.rs b/src/transforms.rs
index d84692f..9eee406 100644
--- a/src/transforms.rs
+++ b/src/transforms.rs
@@ -48,7 +48,7 @@ pub fn find_fundamental_frequency(frequency_domain: &Vec<FrequencyBucket>) -> Op
Some(max_bucket.ave_freq())
}
-pub fn find_fundamental_frequency_correlation(input: &Vec<f64>, sample_rate: f64) -> Option<f64> {
+pub fn correlation(input: &Vec<f64>) -> Vec<f64> {
let mut correlation = Vec::with_capacity(input.len());
for offset in 0..input.len() {
let mut c = 0.0;
@@ -58,6 +58,11 @@ pub fn find_fundamental_frequency_correlation(input: &Vec<f64>, sample_rate: f64
}
correlation.push(c);
}
+ correlation
+}
+
+pub fn find_fundamental_frequency_correlation(input: &Vec<f64>, sample_rate: f64) -> Option<f64> {
+ let mut correlation = correlation(&input);
//at offset = 0, we have union, so we want to remove that peak
for offset in 1..correlation.len() {