Skip to main content

AudioRequest

Enum AudioRequest 

Source
#[non_exhaustive]
pub enum AudioRequest<V> {
Show 14 variants PlaySound { cue: String, volume: f32, }, StartSound { id: SoundId, cue: String, volume: f32, }, StopSound { id: SoundId, }, SoundVolume { id: SoundId, volume: f32, }, PauseSounds, ResumeSounds,
#[non_exhaustive]
PlayMusic { cue: String, switch: Option<MusicSwitch>, }, StopMusic,
#[non_exhaustive]
StopMusicWith { fade_ms: u32, }, PlayVoice { line: LineId, variant: V, }, StopVoice, PreloadVoices { lines: Vec<(LineId, V)>, },
#[non_exhaustive]
AddSound { cue: String, samples: SharedSamples, }, RemoveSound { cue: String, },
}
Expand description

Something a screen wants heard. Cue ids are the ones in the game’s audio manifest (AudioManifest).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

PlaySound

Play a sound cue once, at volume (0–1) times the cue’s own volume.

Fields

§cue: String

The sound cue.

§volume: f32

A multiplier on the cue’s volume, 0–1.

§

StartSound

Play a sound cue until StopSound of its id (looped if the cue says so, else once), at volume (0–1) times the cue’s own volume.

Fields

§id: SoundId

Its handle.

§cue: String

The sound cue.

§volume: f32

A multiplier on the cue’s volume, 0–1.

§

StopSound

Stop the sound started as id, at once.

Fields

§id: SoundId

Its handle.

§

SoundVolume

Set the volume of the sound started as id.

Fields

§id: SoundId

Its handle.

§volume: f32

The new multiplier on the cue’s volume, 0–1.

§

PauseSounds

Pause every sound started with a handle that is playing now (AudioQueue::pause_sounds); one started after it plays. Sound cues played once, the music and the voice go on.

§

ResumeSounds

Resume the sounds PauseSounds paused.

§

#[non_exhaustive]
PlayMusic

Switch to a music cue. Asking for the track already playing does nothing. Build it with AudioRequest::play_music (ADR-0039).

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§cue: String

The music cue.

§switch: Option<MusicSwitch>

How the track playing gives way to it; None for the audio manifest’s default (AudioManifest::music_switch).

§

StopMusic

Fade the music out over the audio manifest’s default fade-out (MusicSwitch’s out_ms).

§

#[non_exhaustive]
StopMusicWith

Fade the music out over fade_ms, for this stop only: the time from full gain to silence, so a track at half gain takes half of it; 0 stops at once. Build it with AudioRequest::stop_music_with (ADR-0039).

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§fade_ms: u32

Milliseconds a fade from full gain to silence takes.

§

PlayVoice

Say a dialogue line: play its voice clip once, stopping the voice that is playing (one voice at a time).

Fields

§line: LineId

The line.

§variant: V

Which of the line’s clips.

§

StopVoice

Stop the voice that is playing, if any.

§

PreloadVoices

The clips a scene will ask for, in script order, so the platform can load the next few ahead of each PlayVoice. Replaces the list sent before.

Fields

§lines: Vec<(LineId, V)>

The clips, in the order they are expected.

§

#[non_exhaustive]
AddSound

Make samples the sound cue cue from now on, as a cue of the manifest is: PlaySound and StartSound play it at its own volume, full, once. A cue added before is replaced. Only AudioQueue::add_sound makes one, within its limits.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§cue: String

The sound cue.

§samples: SharedSamples

Its samples, shared with whatever plays them.

§

RemoveSound

Forget the sound cue cue that AddSound made, stopping what plays it.

Fields

§cue: String

The sound cue.

Implementations§

Source§

impl<V> AudioRequest<V>

Source

pub fn play_music(cue: impl Into<String>, switch: Option<MusicSwitch>) -> Self

A PlayMusic of cue, switching with switch (None: the manifest’s default).

Source

pub fn stop_music_with(fade_ms: u32) -> Self

A StopMusicWith: the music fades out over fade_ms (0: at once), whatever the manifest’s default.

Source

pub fn cue(&self) -> Option<&str>

The cue this request plays, if any: a sound played or started, or a track. A sound added or removed is played by none.

Trait Implementations§

Source§

impl<V: Clone> Clone for AudioRequest<V>

Source§

fn clone(&self) -> AudioRequest<V>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<V: Debug> Debug for AudioRequest<V>

Source§

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

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

impl<V: PartialEq> PartialEq for AudioRequest<V>

Source§

fn eq(&self, other: &AudioRequest<V>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<V: PartialEq> StructuralPartialEq for AudioRequest<V>

Auto Trait Implementations§

§

impl<V> Freeze for AudioRequest<V>
where V: Freeze,

§

impl<V> RefUnwindSafe for AudioRequest<V>
where V: RefUnwindSafe,

§

impl<V> Send for AudioRequest<V>
where V: Send,

§

impl<V> Sync for AudioRequest<V>
where V: Sync,

§

impl<V> Unpin for AudioRequest<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for AudioRequest<V>
where V: UnsafeUnpin,

§

impl<V> UnwindSafe for AudioRequest<V>
where V: UnwindSafe,

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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