use crate::{
Decibels, Panning, PlaybackRate, StartTime, Tween, Value,
sound::{IntoOptionalRegion, PlaybackPosition, Region},
};
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct StaticSoundSettings {
pub start_time: StartTime,
pub start_position: PlaybackPosition,
pub loop_region: Option<Region>,
pub reverse: bool,
pub volume: Value<Decibels>,
pub playback_rate: Value<PlaybackRate>,
pub panning: Value<Panning>,
pub fade_in_tween: Option<Tween>,
}
impl StaticSoundSettings {
#[must_use]
pub fn new() -> Self {
Self {
start_time: StartTime::default(),
start_position: PlaybackPosition::Seconds(0.0),
reverse: false,
loop_region: None,
volume: Value::Fixed(Decibels::IDENTITY),
playback_rate: Value::Fixed(PlaybackRate(1.0)),
panning: Value::Fixed(Panning::CENTER),
fade_in_tween: None,
}
}
#[must_use = "This method consumes self and returns a modified StaticSoundSettings, so the return value should be used"]
pub fn start_time(self, start_time: impl Into<StartTime>) -> Self {
Self {
start_time: start_time.into(),
..self
}
}
#[must_use = "This method consumes self and returns a modified StaticSoundSettings, so the return value should be used"]
pub fn start_position(self, start_position: impl Into<PlaybackPosition>) -> Self {
Self {
start_position: start_position.into(),
..self
}
}
#[must_use = "This method consumes self and returns a modified StaticSoundSettings, so the return value should be used"]
pub fn reverse(self, reverse: bool) -> Self {
Self { reverse, ..self }
}
#[must_use = "This method consumes self and returns a modified StaticSoundSettings, so the return value should be used"]
pub fn loop_region(self, loop_region: impl IntoOptionalRegion) -> Self {
Self {
loop_region: loop_region.into_optional_region(),
..self
}
}
#[must_use = "This method consumes self and returns a modified StaticSoundSettings, so the return value should be used"]
pub fn volume(self, volume: impl Into<Value<Decibels>>) -> Self {
Self {
volume: volume.into(),
..self
}
}
#[must_use = "This method consumes self and returns a modified StaticSoundSettings, so the return value should be used"]
pub fn playback_rate(self, playback_rate: impl Into<Value<PlaybackRate>>) -> Self {
Self {
playback_rate: playback_rate.into(),
..self
}
}
#[must_use = "This method consumes self and returns a modified StaticSoundSettings, so the return value should be used"]
pub fn panning(self, panning: impl Into<Value<Panning>>) -> Self {
Self {
panning: panning.into(),
..self
}
}
#[must_use = "This method consumes self and returns a modified StaticSoundSettings, so the return value should be used"]
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()
}
}