Skip to content

Instantly share code, notes, and snippets.

@pta2002
Created May 14, 2020 19:24
Show Gist options
  • Save pta2002/5e035bd006af85fdfdd3793ac52cfd0e to your computer and use it in GitHub Desktop.
Save pta2002/5e035bd006af85fdfdd3793ac52cfd0e to your computer and use it in GitHub Desktop.
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