Skip to main content

Speaker

Struct Speaker 

Source
pub struct Speaker<S: Sdk> { /* private fields */ }
Expand description

The SDK’s speaker.

Implementations§

Source§

impl<S: Sdk> Speaker<S>

Source

pub fn new(sdk: S) -> Self

The speaker on sdk, with its sample players made.

Trait Implementations§

Source§

impl<S: Sdk> Backend for Speaker<S>

Source§

fn load_sound( &mut self, _bytes: &[u8], ) -> impl Future<Output = Result<Clip<S>, String>>

The SDK loads a sound by its path (load_sound_file): it is baked to a format only pdc writes, and no bytes come here.

Source§

fn add_sound(&mut self, samples: &SharedSamples) -> Result<Clip<S>, String>

A sample the SDK makes from a copy of the samples, at their own rate.

Source§

fn remove_sound(&mut self, sound: Clip<S>)

Stops the sample players on it, lets go of it, and frees it.

Source§

type Sound = Clip<S>

A decoded sound or track.
Source§

type Loading = Option<Result<Clip<S>, String>>

A music track or voice clip being loaded.
Source§

type Playing = Playing<S>

One playback of a sound, which stops alone.
Source§

fn load_sound_file( &mut self, file: &str, _files: &Files<'_>, ) -> impl Future<Output = Result<Clip<S>, String>>

Readies the sound file file of the manifest. By default it reads the file with files and decodes it with load_sound; a device that loads a sound from its own path says so here.
Source§

fn load_music(&mut self, path: &str) -> Self::Loading

Starts loading and decoding the music or voice file at path.
Source§

fn poll_music( &mut self, loading: &mut Self::Loading, ) -> Option<Result<Clip<S>, String>>

The track, once loading has finished (called once per frame).
Source§

fn length(&self, sound: &Clip<S>) -> Option<f64>

How long sound plays, in seconds, if that is known: it is for an OGG file loaded with load_music.
Source§

fn play(&mut self, sound: &Clip<S>, volume: f32, looped: bool) -> Playing<S>

Plays sound from the start at volume (0–1): this playback.
Source§

fn set_volume(&mut self, sound: &Clip<S>, volume: f32)

Changes the volume of sound wherever it plays.
Source§

fn stop(&mut self, sound: &Clip<S>)

Stops sound.
Source§

fn set_playing_volume(&mut self, playing: &Playing<S>, volume: f32)

Changes the volume of playing alone.
Source§

fn stop_playing(&mut self, playing: Playing<S>)

Stops playing alone: other copies of its sound play on.
Source§

fn pause(&mut self, playing: &Playing<S>) -> Result<(), Unsupported>

Stops playing so that resume goes on from where it was. Without it the player mutes the sound, which runs on silently.
Source§

fn resume(&mut self, playing: &Playing<S>) -> Result<(), Unsupported>

Goes on with playing from where pause stopped it.
Source§

fn set_rate(&mut self, sound: &Clip<S>, rate: u32) -> Result<(), Unsupported>

Sets how fast sound plays from its next play, in 16.16 fixed point (RATE_ONE plays it as recorded). Without it the sound plays at 1.0.
Source§

fn warn(&mut self, line: &str)

Says a problem of the player’s in the backend’s log, by default nowhere.
Source§

fn hold_output(&mut self, on: bool)

The system suspends the game (on) or has resumed it: a backend whose output can stop stops it here, after the player has held what sounds.
Source§

impl<S: Debug + Sdk> Debug for Speaker<S>
where S::Sample: Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Freeze for Speaker<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for Speaker<S>

§

impl<S> Send for Speaker<S>
where S: Send, <S as Sdk>::Sample: Send, <S as Sdk>::SamplePlayer: Send,

§

impl<S> Sync for Speaker<S>
where S: Sync, <S as Sdk>::Sample: Sync, <S as Sdk>::SamplePlayer: Sync,

§

impl<S> Unpin for Speaker<S>
where S: Unpin, <S as Sdk>::Sample: Unpin, <S as Sdk>::SamplePlayer: Unpin,

§

impl<S> UnsafeUnpin for Speaker<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for Speaker<S>

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