pub struct PlaybackParams {
pub volume: f32,
pub rate: f32,
pub pan: f32,
pub bus: AudioBus,
}Expand description
How one voice should sound.
Build with the chained setters — PlaybackParams::new().volume(0.4).pan(-0.3)
reads like the named arguments a Compose call site would use.
Fields§
§volume: f32Linear gain. 1.0 is the clip’s recorded level.
rate: f32Playback rate, which shifts pitch with it. 1.0 is the recorded pitch,
2.0 is an octave up.
pan: f32Stereo position from -1.0 (hard left) through 0.0 to 1.0.
bus: AudioBusThe mix bus this voice belongs to.
Implementations§
Source§impl PlaybackParams
impl PlaybackParams
Sourcepub const DEFAULT: PlaybackParams
pub const DEFAULT: PlaybackParams
The neutral parameters: unity gain, recorded pitch, centred, effects bus.
Sourcepub const MAX_VOLUME: f32 = 4.0
pub const MAX_VOLUME: f32 = 4.0
The loudest gain a backend honours, leaving room to amplify a quiet clip.
Sourcepub const fn new() -> PlaybackParams
pub const fn new() -> PlaybackParams
The neutral parameters. Same as PlaybackParams::DEFAULT.
Sourcepub fn volume(self, volume: f32) -> PlaybackParams
pub fn volume(self, volume: f32) -> PlaybackParams
Sets the linear gain.
Sourcepub fn rate(self, rate: f32) -> PlaybackParams
pub fn rate(self, rate: f32) -> PlaybackParams
Sets the playback rate (and with it the pitch).
Sourcepub fn pan(self, pan: f32) -> PlaybackParams
pub fn pan(self, pan: f32) -> PlaybackParams
Sets the stereo position.
Sourcepub fn bus(self, bus: AudioBus) -> PlaybackParams
pub fn bus(self, bus: AudioBus) -> PlaybackParams
Sets the mix bus.
Sourcepub fn pitch_semitones(self, semitones: f32) -> PlaybackParams
pub fn pitch_semitones(self, semitones: f32) -> PlaybackParams
Sets the rate from a pitch offset in equal-tempered semitones.
A rising combo counter reads better as pitch_semitones(combo as f32)
than as a hand-computed ratio.
Sourcepub fn sanitized(self) -> PlaybackParams
pub fn sanitized(self) -> PlaybackParams
Clamps every field into the range backends honour and scrubs NaN.
Backends call this before handing parameters to the audio thread, which
is why a NaN rate from app arithmetic cannot wedge a voice.
Trait Implementations§
Source§impl Clone for PlaybackParams
impl Clone for PlaybackParams
Source§fn clone(&self) -> PlaybackParams
fn clone(&self) -> PlaybackParams
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more