diff options
author | Justin Worthe <justin.worthe@gmail.com> | 2017-01-17 20:27:08 +0200 |
---|---|---|
committer | Justin Worthe <justin.worthe@gmail.com> | 2017-01-17 20:27:08 +0200 |
commit | b4f87e573f2ba4acc01af49e0887779d75bcd08d (patch) | |
tree | cfa277f95f225d6992ff00a456aa7e12c58d0236 /src/gui.rs | |
parent | 5f68c90c23d0301b80f44ea2d910e931557eea8d (diff) |
It's alive!
Implemented passable frequency detection using auto-correlation.
It's still a bit finicky, and not super accurate. It could probably be
made more accurate by doing interpolation after choosing an appropriate
peak to find the maximum point more accurately. The correlation itself
does also oscillates uniformly after all.
Diffstat (limited to 'src/gui.rs')
-rw-r--r-- | src/gui.rs | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -112,9 +112,10 @@ fn connect_dropdown_choose_microphone(mic_sender: Sender<Vec<f64>>, state: Rc<Re fn start_processing_audio(mic_receiver: Receiver<Vec<f64>>, pitch_sender: Sender<String>, freq_sender: Sender<Vec<::transforms::FrequencyBucket>>) { thread::spawn(move || { for samples in mic_receiver { - let frequency_domain = ::transforms::fft(samples, 44100.0); + let frequency_domain = ::transforms::fft(&samples, 44100.0); freq_sender.send(frequency_domain.clone()).ok(); - let fundamental = ::transforms::find_fundamental_frequency(&frequency_domain); + + let fundamental = ::transforms::find_fundamental_frequency_correlation(&samples, 44100.0); let pitch = match fundamental { Some(fundamental) => ::transforms::hz_to_pitch(fundamental), None => "".to_string() |