#[non_exhaustive]pub struct StaticSoundSettings {
pub start_time: StartTime,
pub playback_region: Region,
pub loop_region: Option<Region>,
pub reverse: bool,
pub volume: Value<Volume>,
pub playback_rate: Value<PlaybackRate>,
pub panning: Value<f64>,
pub output_destination: OutputDestination,
pub fade_in_tween: Option<Tween>,
}
Expand description
Settings for a static sound.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.start_time: StartTime
When the sound should start playing.
playback_region: Region
The portion of the sound that should be played.
loop_region: Option<Region>
The portion of the sound that should be looped.
reverse: bool
Whether the sound should be played in reverse.
volume: Value<Volume>
The volume of the sound.
playback_rate: Value<PlaybackRate>
The playback rate of the sound.
Changing the playback rate will change both the speed and the pitch of the sound.
panning: Value<f64>
The panning of the sound, where 0 is hard left and 1 is hard right.
output_destination: OutputDestination
The destination that this sound should be routed to.
fade_in_tween: Option<Tween>
An optional fade-in from silence.
Implementations§
Source§impl StaticSoundSettings
impl StaticSoundSettings
Sourcepub fn new() -> StaticSoundSettings
pub fn new() -> StaticSoundSettings
Creates a new StaticSoundSettings
with the default settings.
Sourcepub fn start_time(self, start_time: impl Into<StartTime>) -> StaticSoundSettings
pub fn start_time(self, start_time: impl Into<StartTime>) -> StaticSoundSettings
Sets when the sound should start playing.
§Examples
Configuring a sound to start 4 ticks after a clock’s current time:
use kira::{
manager::{AudioManager, AudioManagerSettings, backend::DefaultBackend},
sound::static_sound::{StaticSoundData, StaticSoundSettings},
clock::ClockSpeed,
};
let mut manager = AudioManager::<DefaultBackend>::new(AudioManagerSettings::default())?;
let clock_handle = manager.add_clock(ClockSpeed::TicksPerMinute(120.0))?;
let settings = StaticSoundSettings::new().start_time(clock_handle.time() + 4);
let sound = StaticSoundData::from_file("sound.ogg", settings);
Sourcepub fn playback_region(
self,
playback_region: impl Into<Region>,
) -> StaticSoundSettings
pub fn playback_region( self, playback_region: impl Into<Region>, ) -> StaticSoundSettings
Sets the portion of the sound that should be played.
§Examples
Configure a sound to play from 3 seconds in to the end:
let settings = StaticSoundSettings::new().playback_region(3.0..);
Configure a sound to play from 2 to 4 seconds:
let settings = StaticSoundSettings::new().playback_region(2.0..4.0);
Sourcepub fn reverse(self, reverse: bool) -> StaticSoundSettings
pub fn reverse(self, reverse: bool) -> StaticSoundSettings
Sets whether the sound should be played in reverse.
Sourcepub fn loop_region(
self,
loop_region: impl IntoOptionalRegion,
) -> StaticSoundSettings
pub fn loop_region( self, loop_region: impl IntoOptionalRegion, ) -> StaticSoundSettings
Sets the portion of the sound that should be looped.
§Examples
Configure a sound to loop the portion from 3 seconds in to the end:
let settings = StaticSoundSettings::new().loop_region(3.0..);
Configure a sound to loop the portion from 2 to 4 seconds:
let settings = StaticSoundSettings::new().loop_region(2.0..4.0);
Sourcepub fn volume(self, volume: impl Into<Value<Volume>>) -> StaticSoundSettings
pub fn volume(self, volume: impl Into<Value<Volume>>) -> StaticSoundSettings
Sets the volume of the sound.
§Examples
Set the volume as a factor:
let settings = StaticSoundSettings::new().volume(0.5);
Set the volume as a gain in decibels:
let settings = StaticSoundSettings::new().volume(kira::Volume::Decibels(-6.0));
Link the volume to a modulator:
use kira::{
manager::{AudioManager, AudioManagerSettings, backend::DefaultBackend},
modulator::tweener::TweenerBuilder,
sound::static_sound::{StaticSoundSettings},
};
let mut manager = AudioManager::<DefaultBackend>::new(AudioManagerSettings::default())?;
let tweener = manager.add_modulator(TweenerBuilder {
initial_value: 0.5,
})?;
let settings = StaticSoundSettings::new().volume(&tweener);
Sourcepub fn playback_rate(
self,
playback_rate: impl Into<Value<PlaybackRate>>,
) -> StaticSoundSettings
pub fn playback_rate( self, playback_rate: impl Into<Value<PlaybackRate>>, ) -> StaticSoundSettings
Sets the playback rate of the sound.
Changing the playback rate will change both the speed and the pitch of the sound.
§Examples
Set the playback rate as a factor:
let settings = StaticSoundSettings::new().playback_rate(0.5);
Set the playback rate as a change in semitones:
use kira::sound::PlaybackRate;
let settings = StaticSoundSettings::new().playback_rate(PlaybackRate::Semitones(-2.0));
Link the playback rate to a modulator:
use kira::{
manager::{AudioManager, AudioManagerSettings, backend::DefaultBackend},
modulator::tweener::TweenerBuilder,
sound::static_sound::{StaticSoundSettings},
};
let mut manager = AudioManager::<DefaultBackend>::new(AudioManagerSettings::default())?;
let tweener = manager.add_modulator(TweenerBuilder {
initial_value: 0.5,
})?;
let settings = StaticSoundSettings::new().playback_rate(&tweener);
Sourcepub fn panning(self, panning: impl Into<Value<f64>>) -> StaticSoundSettings
pub fn panning(self, panning: impl Into<Value<f64>>) -> StaticSoundSettings
Sets the panning of the sound, where 0 is hard left and 1 is hard right.
§Examples
Set the panning to a static value:
let settings = StaticSoundSettings::new().panning(0.25);
Link the panning to a modulator:
use kira::{
manager::{AudioManager, AudioManagerSettings, backend::DefaultBackend},
modulator::tweener::TweenerBuilder,
sound::static_sound::{StaticSoundSettings},
};
let mut manager = AudioManager::<DefaultBackend>::new(AudioManagerSettings::default())?;
let tweener = manager.add_modulator(TweenerBuilder {
initial_value: 0.25,
})?;
let settings = StaticSoundSettings::new().panning(&tweener);
Sourcepub fn output_destination(
self,
output_destination: impl Into<OutputDestination>,
) -> StaticSoundSettings
pub fn output_destination( self, output_destination: impl Into<OutputDestination>, ) -> StaticSoundSettings
Sets the destination that this sound should be routed to.
§Examples
Set the output destination of a sound to a mixer track:
use kira::{
manager::{AudioManager, AudioManagerSettings, backend::DefaultBackend},
track::TrackBuilder,
sound::static_sound::{StaticSoundSettings},
};
let mut manager = AudioManager::<DefaultBackend>::new(AudioManagerSettings::default())?;
let sub_track = manager.add_sub_track(TrackBuilder::new())?;
let settings = StaticSoundSettings::new().output_destination(&sub_track);
Set the output destination of a sound to an emitter in a spatial scene:
use kira::{
manager::{AudioManager, AudioManagerSettings, backend::DefaultBackend},
spatial::{scene::SpatialSceneSettings, emitter::EmitterSettings},
sound::static_sound::{StaticSoundSettings},
};
let mut manager = AudioManager::<DefaultBackend>::new(AudioManagerSettings::default())?;
let mut scene = manager.add_spatial_scene(SpatialSceneSettings::default())?;
let emitter = scene.add_emitter(mint::Vector3 {
x: 0.0,
y: 0.0,
z: 0.0,
}, EmitterSettings::default())?;
let settings = StaticSoundSettings::new().output_destination(&emitter);
Sourcepub fn fade_in_tween(
self,
fade_in_tween: impl Into<Option<Tween>>,
) -> StaticSoundSettings
pub fn fade_in_tween( self, fade_in_tween: impl Into<Option<Tween>>, ) -> StaticSoundSettings
Sets the tween used to fade in the sound from silence.
Trait Implementations§
Source§impl Clone for StaticSoundSettings
impl Clone for StaticSoundSettings
Source§fn clone(&self) -> StaticSoundSettings
fn clone(&self) -> StaticSoundSettings
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for StaticSoundSettings
impl Debug for StaticSoundSettings
Source§impl Default for StaticSoundSettings
impl Default for StaticSoundSettings
Source§fn default() -> StaticSoundSettings
fn default() -> StaticSoundSettings
Source§impl PartialEq for StaticSoundSettings
impl PartialEq for StaticSoundSettings
impl Copy for StaticSoundSettings
impl StructuralPartialEq for StaticSoundSettings
Auto Trait Implementations§
impl Freeze for StaticSoundSettings
impl RefUnwindSafe for StaticSoundSettings
impl Send for StaticSoundSettings
impl Sync for StaticSoundSettings
impl Unpin for StaticSoundSettings
impl UnwindSafe for StaticSoundSettings
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.