Struct StaticSoundSettings

Source
#[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
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§

Source§

impl StaticSoundSettings

Source

pub fn new() -> StaticSoundSettings

Creates a new StaticSoundSettings with the default settings.

Source

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

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

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

Sets whether the sound should be played in reverse.

Source

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

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

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

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

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

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

Source§

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
Source§

impl Debug for StaticSoundSettings

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for StaticSoundSettings

Source§

fn default() -> StaticSoundSettings

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

impl PartialEq for StaticSoundSettings

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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

impl Copy for StaticSoundSettings

Source§

impl StructuralPartialEq for StaticSoundSettings

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

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

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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
Source§

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

Source§

fn to_sample_(self) -> U

Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

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

Source§

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

Source§

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

Source§

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