diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2017-07-15 15:28:53 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2017-07-15 15:28:53 +0200 |
commit | ed89f64962d5de120db26f140c8e027991ab2797 (patch) | |
tree | 9248f01037c7e68e9742207464ffcb15b6057cab /src | |
parent | 4dd91d7fc35685f4ad4c909ba72a03f21185283d (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/audio.rs | 2 | ||||
-rw-r--r-- | src/gui.rs | 9 |
2 files changed, 8 insertions, 3 deletions
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, pa::Error> { pa::PortAudio::new() @@ -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<RefCell<ApplicationState> 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; |