From 19ad6abf0933d3e3e5b1b3fa693676c47bb07be9 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Tue, 11 Jul 2017 20:10:03 +0200 Subject: Updated silence level and made no pitch's error show a 'perfect' pitch background --- src/gui.rs | 41 ++++++++++++++++++++++++----------------- src/transforms.rs | 2 +- 2 files changed, 25 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/gui.rs b/src/gui.rs index 16921d4..f298790 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -225,23 +225,30 @@ fn setup_pitch_error_indicator_callbacks(state: Rc>, c let line_indicator_height = 20.0; let color_indicator_height = canvas.get_allocated_height() as f64 - line_indicator_height; - if let Ok(Some(error)) = cross_thread_state.read().map(|state| state.error) { - let error_line_x = midpoint + error as f64 * midpoint / 50.0; - context.new_path(); - context.move_to(error_line_x, 0.0); - context.line_to(error_line_x, line_indicator_height); - context.stroke(); - - - //flat on the left - context.set_source_rgb(0.0, 0.0, if error < 0.0 {-error as f64/50.0} else {0.0}); - context.rectangle(0.0, line_indicator_height, midpoint, color_indicator_height+line_indicator_height); - context.fill(); - - //sharp on the right - context.set_source_rgb(if error > 0.0 {error as f64/50.0} else {0.0}, 0.0, 0.0); - context.rectangle(midpoint, line_indicator_height, width, color_indicator_height+line_indicator_height); - context.fill(); + match cross_thread_state.read().map(|state| state.error) { + Ok(Some(error)) => { + let error_line_x = midpoint + error as f64 * midpoint / 50.0; + context.new_path(); + context.move_to(error_line_x, 0.0); + context.line_to(error_line_x, line_indicator_height); + context.stroke(); + + + //flat on the left + context.set_source_rgb(0.0, 0.0, if error < 0.0 {-error as f64/50.0} else {0.0}); + context.rectangle(0.0, line_indicator_height, midpoint, color_indicator_height+line_indicator_height); + context.fill(); + + //sharp on the right + context.set_source_rgb(if error > 0.0 {error as f64/50.0} else {0.0}, 0.0, 0.0); + context.rectangle(midpoint, line_indicator_height, width, color_indicator_height+line_indicator_height); + context.fill(); + }, + _ => { + context.set_source_rgb(0.0, 0.0, 0.0); + context.rectangle(0.0, line_indicator_height, width, color_indicator_height+line_indicator_height); + context.fill(); + } } gtk::Inhibit(false) diff --git a/src/transforms.rs b/src/transforms.rs index c4a5b5c..43522da 100644 --- a/src/transforms.rs +++ b/src/transforms.rs @@ -15,7 +15,7 @@ pub fn correlation(signal: &Vec) -> Vec { pub fn find_fundamental_frequency_correlation(signal: &Vec, sample_rate: f32) -> Option { let normalized_signal = remove_mean_offset(&signal); - if normalized_signal.iter().all(|&x| x.abs() < 0.1) { + if normalized_signal.iter().all(|&x| x.abs() < 0.05) { // silence return None; } -- cgit v1.2.3