use crate::{track::TrackId, tween::Tween, LoopBehavior, PlaybackRate, StartTime, Volume};
#[derive(Debug, Clone, Copy, PartialEq)]
#[non_exhaustive]
pub struct StaticSoundSettings {
pub start_time: StartTime,
pub start_position: f64,
pub volume: Volume,
pub playback_rate: PlaybackRate,
pub panning: f64,
pub reverse: bool,
pub loop_behavior: Option<LoopBehavior>,
pub track: TrackId,
pub fade_in_tween: Option<Tween>,
}
impl StaticSoundSettings {
pub fn new() -> Self {
Self {
start_time: StartTime::default(),
start_position: 0.0,
volume: Volume::Amplitude(1.0),
playback_rate: PlaybackRate::Factor(1.0),
panning: 0.5,
reverse: false,
loop_behavior: None,
track: TrackId::Main,
fade_in_tween: None,
}
}
pub fn start_time(self, start_time: impl Into<StartTime>) -> Self {
Self {
start_time: start_time.into(),
..self
}
}
pub fn start_position(self, start_position: f64) -> Self {
Self {
start_position,
..self
}
}
pub fn volume(self, volume: impl Into<Volume>) -> Self {
Self {
volume: volume.into(),
..self
}
}
pub fn playback_rate(self, playback_rate: impl Into<PlaybackRate>) -> Self {
Self {
playback_rate: playback_rate.into(),
..self
}
}
pub fn panning(self, panning: f64) -> Self {
Self { panning, ..self }
}
pub fn reverse(self, reverse: bool) -> Self {
Self { reverse, ..self }
}
pub fn loop_behavior(self, loop_behavior: impl Into<Option<LoopBehavior>>) -> Self {
Self {
loop_behavior: loop_behavior.into(),
..self
}
}
pub fn track(self, track: impl Into<TrackId>) -> Self {
Self {
track: track.into(),
..self
}
}
pub fn fade_in_tween(self, fade_in_tween: impl Into<Option<Tween>>) -> Self {
Self {
fade_in_tween: fade_in_tween.into(),
..self
}
}
}
impl Default for StaticSoundSettings {
fn default() -> Self {
Self::new()
}
}