Created
May 14, 2020 19:24
-
-
Save pta2002/5e035bd006af85fdfdd3793ac52cfd0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mut pitch_detector = Arc::new(Mutex::new( | |
Pitch::new( | |
PitchMode::Yinfft, | |
16384, | |
client.buffer_size().try_into().unwrap(), | |
client.sample_rate().try_into().unwrap(), | |
) | |
.expect("Failed to initialize pitch detector"), | |
)); | |
let process_callback = move |client: &jack::Client, ps: &jack::ProcessScope| { | |
println!("Got {} frames!", ps.n_frames()); | |
let audio_input = input_port.as_slice(ps); | |
let mut detector = pitch_detector.lock().unwrap(); | |
println!("Freq: {}", detector.do_result(audio_input).unwrap_or(0.0)); | |
jack::Control::Continue | |
}; | |
let process = jack::ClosureProcessHandler::new(process_callback); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment