diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2017-07-11 20:10:03 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2017-07-11 20:10:03 +0200 |
commit | 19ad6abf0933d3e3e5b1b3fa693676c47bb07be9 (patch) | |
tree | e1151388e7bd43cb34fb9f763f6c2ed42042dc20 | |
parent | dac54d0e4345e52ce18a802b0ee22e6bb8696f9a (diff) |
Updated silence level and made no pitch's error show a 'perfect' pitch background
-rw-r--r-- | src/gui.rs | 41 | ||||
-rw-r--r-- | src/transforms.rs | 2 |
2 files changed, 25 insertions, 18 deletions
@@ -225,23 +225,30 @@ fn setup_pitch_error_indicator_callbacks(state: Rc<RefCell<ApplicationState>>, 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<f32>) -> Vec<f32> { pub fn find_fundamental_frequency_correlation(signal: &Vec<f32>, sample_rate: f32) -> Option<f32> { 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; } |