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