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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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§

§

impl StaticSoundSettings

pub fn new() -> StaticSoundSettings

Creates a new StaticSoundSettings with the default settings.

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);

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);

pub fn reverse(self, reverse: bool) -> StaticSoundSettings

Sets whether the sound should be played in reverse.

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);

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);

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);

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);

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);

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§

§

impl Clone for StaticSoundSettings

§

fn clone(&self) -> StaticSoundSettings

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for StaticSoundSettings

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for StaticSoundSettings

§

fn default() -> StaticSoundSettings

Returns the “default value” for a type. Read more
§

impl PartialEq<StaticSoundSettings> for StaticSoundSettings

§

fn eq(&self, other: &StaticSoundSettings) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Copy for StaticSoundSettings

§

impl StructuralPartialEq for StaticSoundSettings

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<F, T> IntoSample<T> for Fwhere T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> ToSample<U> for Twhere U: FromSample<T>,

§

fn to_sample_(self) -> U

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Any for Twhere T: Any,

§

impl<T> CloneAny for Twhere T: Any + Clone,

§

impl<T> Component for Twhere T: Send + Sync + 'static,

§

impl<S, T> Duplex<S> for Twhere T: FromSample<S> + ToSample<S>,

source§

impl<T> SerializableAny for Twhere T: 'static + Any + Clone + Send + Sync,