diff --git a/examples/cpal-info.rs b/examples/cpal-info.rs index 1d895eb..eca5a04 100644 --- a/examples/cpal-info.rs +++ b/examples/cpal-info.rs @@ -4,7 +4,7 @@ use cpal::traits::DeviceTrait; mod example_utils; /// Minimal example to explore the structure of the audio input samples we get -/// from cpal. This example does nothing with the beat detection library. +/// from cpal. This binary does nothing with the beat detection library. fn main() { let input_device = example_utils::select_audio_device(); let supported_configs = input_device diff --git a/examples/cpal-minimal.rs b/examples/cpal-minimal.rs deleted file mode 100644 index ee6cce9..0000000 --- a/examples/cpal-minimal.rs +++ /dev/null @@ -1,57 +0,0 @@ -use cpal::traits::{DeviceTrait, HostTrait, StreamTrait}; -use cpal::{BufferSize, StreamConfig}; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; - -#[path = "_modules/example_utils.rs"] -mod example_utils; - -/// Minimal example to explore the structure of the audio input samples we get -/// from cpal. This example does nothing with the beat detection library. -fn main() { - let host = cpal::default_host(); - let dev = host.default_input_device().unwrap(); - let x = dev.supported_input_configs().unwrap().collect::>(); - dbg!(x); - let cfg = dev.default_input_config().unwrap(); - let cfg = StreamConfig { - channels: 1, - sample_rate: cfg.sample_rate(), - buffer_size: BufferSize::Default, - }; - - let mut max = i16::MIN; - let mut min = i16::MAX; - - let stream = dev - .build_input_stream( - &cfg, - // cpal is powerful enough to let us specify the type of the - // samples, such as `&[i16]` or `&[f32]`. For i16, the value is - // between `i16::MIN..i16::MAX`, for f32, the value is between - // `-1.0..1.0`. Supported formats are in enum `SampleFormat`. - move |samples: &[i16], _info| { - for &sample in samples { - max = core::cmp::max(max, sample); - min = core::cmp::min(min, sample); - println!("{sample:>6}, max={max:>6}, min={min:>6}"); - } - }, - |e| eprintln!("error: {e:?}"), - None, - ) - .unwrap(); - - let stop_recording = Arc::new(AtomicBool::new(false)); - { - let stop_recording = stop_recording.clone(); - ctrlc::set_handler(move || { - stop_recording.store(true, Ordering::SeqCst); - }) - .unwrap(); - } - - stream.play().unwrap(); - while !stop_recording.load(Ordering::SeqCst) {} - stream.pause().unwrap(); -} diff --git a/examples/minimal-live-input.rs b/examples/live-input-minimal.rs similarity index 100% rename from examples/minimal-live-input.rs rename to examples/live-input-minimal.rs diff --git a/examples/minimal-live-input-gui.rs b/examples/live-input-visualize.rs similarity index 95% rename from examples/minimal-live-input-gui.rs rename to examples/live-input-visualize.rs index b31eab3..5016d11 100644 --- a/examples/minimal-live-input-gui.rs +++ b/examples/live-input-visualize.rs @@ -38,8 +38,7 @@ fn main() { panic!("{}", e); }); - // Limit to max ~60 fps update rate - window.limit_update_rate(Some(std::time::Duration::from_secs_f32(1.0 / 60.0))); + window.set_target_fps(60); let handle = { let rgb_buffer = rgb_buffer.clone();