From ed89f64962d5de120db26f140c8e027991ab2797 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sat, 15 Jul 2017 15:28:53 +0200 Subject: Decreased window size and increased framerate The samller windows size has a few effects: 1. the frequency calculation will be less accurate, because less iterations of the binary search will be effective. 2. 'mixed signals', measures at the start or end of a note where half the signal is one thing and the other half is something else will have less impact, since they will be on the screen for less time. The higher frame rate also looks really nice. --- src/audio.rs | 2 +- src/gui.rs | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/audio.rs b/src/audio.rs index ffaa6ff..98ba84e 100644 --- a/src/audio.rs +++ b/src/audio.rs @@ -4,7 +4,7 @@ use portaudio as pa; use std::sync::mpsc::*; pub const SAMPLE_RATE: f32 = 44100.0; -pub const FRAMES: usize = 1024; +pub const FRAMES: usize = 512; pub fn init() -> Result { pa::PortAudio::new() diff --git a/src/gui.rs b/src/gui.rs index a75e573..d66c685 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -10,7 +10,7 @@ use std::io::Write; use std::thread; use std::sync::mpsc::*; -const FPS: u32 = 30; +const FPS: u32 = 60; struct RustyUi { dropdown: gtk::ComboBoxText, @@ -251,7 +251,12 @@ fn setup_oscilloscope_drawing_area_callbacks(state: Rc if let Ok(cross_thread_state) = cross_thread_state.read() { let ref signal = cross_thread_state.signal; let width = canvas.get_allocated_width() as f64; - let len = 512.0; //Set as a constant so signal won't change size based on zero point. + + // Set as a constant so signal won't change size based on + // zero point, but don't take the window size exactly + // since some will be cropped off the beginning. + let len = ::audio::FRAMES as f64 * 0.8; + let height = canvas.get_allocated_height() as f64; let mid_height = height / 2.0; let max = 1.0; -- cgit v1.2.3