pub struct TrackConfig {
pub muted: AtomicBool,
pub soloed: AtomicBool,
pub armed: AtomicBool,
pub midi_active: AtomicBool,
pub volume: AtomicU32,
}Expand description
Audio-thread-safe track configuration.
Written by the UI thread, read by the audio thread — all fields are atomic so no locks are needed.
Fields§
§muted: AtomicBool§soloed: AtomicBool§armed: AtomicBool§midi_active: AtomicBoolWhether this track is currently selected for MIDI input. Only one track should be selected at a time.
volume: AtomicU32Fader position as a linear gain, stored as f32 bits in an AtomicU32.
Written by the UI thread, read once per buffer by the audio thread.
Constrained to TrackConfig::MIN_VOLUME..=TrackConfig::MAX_VOLUME
by TrackConfig::set_volume, which is the only way to write it.
Implementations§
Source§impl TrackConfig
impl TrackConfig
Sourcepub const MIN_VOLUME: f32 = 0.0
pub const MIN_VOLUME: f32 = 0.0
Bottom of the fader: silence.
Sourcepub const UNITY_VOLUME: f32 = 1.0
pub const UNITY_VOLUME: f32 = 1.0
Unity gain — the track reaches the master bus at the level the instrument produced it.
Sourcepub const MAX_VOLUME: f32 = 2.0
pub const MAX_VOLUME: f32 = 2.0
Top of the fader, +6 dB.
Makeup gain above unity, not decoration. The instruments are trimmed so that ordinary playing peaks near −12 dBFS, which leaves room for several tracks to sum; a user who is playing one quiet pad on its own needs somewhere to get that back, and the alternative is the operating system’s volume control, which raises everything else on the machine too. The master limiter is what makes the top of the range safe.
Sourcepub const DEFAULT_VOLUME: f32 = 0.75
pub const DEFAULT_VOLUME: f32 = 0.75
Where a new track’s fader starts, −2.5 dB.
Below unity so that adding a second and third track does not immediately need the limiter, and so the fader has visible travel in both directions before it is touched.
pub fn new() -> Self
pub fn get_volume(&self) -> f32
Sourcepub fn set_volume(&self, v: f32)
pub fn set_volume(&self, v: f32)
Set the fader position, clamped to the fader’s travel.
The clamp is here rather than at the call sites because this value is read on the audio thread and multiplied into every sample of the track: a caller that computes a position wrongly would otherwise turn a UI arithmetic slip into a full-scale burst. A NaN is not a fader position at all, so it is ignored rather than stored — storing it would multiply the track to NaN, which the master limiter turns into silence, and a silent track with no visible cause is worse than a dropped keystroke.