firewheel_core/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]
2
3pub mod atomic_float;
4pub mod channel_config;
5pub mod clock;
6pub mod collector;
7pub mod diff;
8pub mod dsp;
9pub mod event;
10pub mod log;
11pub mod mask;
12pub mod node;
13pub mod param;
14pub mod sample_resource;
15pub mod vector;
16
17use core::num::NonZeroU32;
18
19extern crate self as firewheel_core;
20
21/// Information about a running audio stream.
22#[derive(Debug, Clone, PartialEq)]
23pub struct StreamInfo {
24 /// The sample rate of the audio stream.
25 pub sample_rate: NonZeroU32,
26 /// The reciprocal of the sample rate.
27 ///
28 /// This is provided for convenience since dividing by the sample rate is such a
29 /// common operation.
30 ///
31 /// Note to users implementing a custom `AudioBackend`: The context will overwrite
32 /// this value, so just set this to the default value.
33 pub sample_rate_recip: f64,
34 /// The sample rate of the previous stream. (If this is the first stream, then this
35 /// will just be a copy of [`StreamInfo::sample_rate`]).
36 ///
37 /// Note to users implementing a custom `AudioBackend`: The context will overwrite
38 /// this value, so just set this to the default value.
39 pub prev_sample_rate: NonZeroU32,
40 /// The maximum number of frames that can appear in a single process cyle.
41 pub max_block_frames: NonZeroU32,
42 /// The number of input audio channels in the stream.
43 pub num_stream_in_channels: u32,
44 /// The number of output audio channels in the stream.
45 pub num_stream_out_channels: u32,
46 /// The latency of the input to output stream in seconds.
47 pub input_to_output_latency_seconds: f64,
48 /// The number of frames used in the shared declicker DSP.
49 ///
50 /// Note to users implementing a custom `AudioBackend`: The context will overwrite
51 /// this value, so just set this to the default value.
52 pub declick_frames: NonZeroU32,
53}
54
55impl Default for StreamInfo {
56 fn default() -> Self {
57 Self {
58 sample_rate: NonZeroU32::new(44100).unwrap(),
59 sample_rate_recip: 44100.0f64.recip(),
60 prev_sample_rate: NonZeroU32::new(44100).unwrap(),
61 max_block_frames: NonZeroU32::new(1024).unwrap(),
62 num_stream_in_channels: 0,
63 num_stream_out_channels: 2,
64 input_to_output_latency_seconds: 0.0,
65 declick_frames: NonZeroU32::MIN,
66 }
67 }
68}