firewheel_core/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2
3#[cfg(not(feature = "std"))]
4use bevy_platform::prelude::String;
5
6pub mod atomic_float;
7pub mod channel_config;
8pub mod clock;
9pub mod collector;
10pub mod diff;
11pub mod dsp;
12pub mod event;
13pub mod log;
14pub mod node;
15pub mod param;
16pub mod sample_resource;
17pub mod vector;
18
19mod connected_mask;
20mod silence_mask;
21
22use core::num::NonZeroU32;
23
24pub use connected_mask::ConnectedMask;
25pub use silence_mask::SilenceMask;
26
27extern crate self as firewheel_core;
28
29/// Information about a running audio stream.
30#[derive(Debug, Clone, PartialEq)]
31pub struct StreamInfo {
32    pub sample_rate: NonZeroU32,
33    /// The reciprocal of the sample rate.
34    pub sample_rate_recip: f64,
35    /// The sample rate of the previous stream. (If this is the first stream, then this
36    /// will just be a copy of [`StreamInfo::sample_rate`]).
37    pub prev_sample_rate: NonZeroU32,
38    pub max_block_frames: NonZeroU32,
39    pub num_stream_in_channels: u32,
40    pub num_stream_out_channels: u32,
41    /// The latency of the input to output stream in seconds.
42    pub input_to_output_latency_seconds: f64,
43    pub declick_frames: NonZeroU32,
44    /// The name of the input audio device.
45    pub input_device_name: Option<String>,
46    /// The name of the output audio device.
47    pub output_device_name: Option<String>,
48}
49
50impl Default for StreamInfo {
51    fn default() -> Self {
52        Self {
53            sample_rate: NonZeroU32::new(44100).unwrap(),
54            sample_rate_recip: 44100.0f64.recip(),
55            prev_sample_rate: NonZeroU32::new(44100).unwrap(),
56            max_block_frames: NonZeroU32::new(1024).unwrap(),
57            num_stream_in_channels: 0,
58            num_stream_out_channels: 2,
59            input_to_output_latency_seconds: 0.0,
60            declick_frames: NonZeroU32::MIN,
61            input_device_name: None,
62            output_device_name: None,
63        }
64    }
65}
66
67#[cfg(feature = "symphonium")]
68pub use sample_resource::{load_audio_file, load_audio_file_from_source};