Sound

Struct Sound 

Source
pub struct Sound(/* private fields */);
Expand description

A sound object.

This is a wrapper around the dos_like_sys::sound_t struct.

Implementations§

Source§

impl Sound

Source

pub fn load_wav(path: impl AsRef<str>) -> Result<Sound, FileError>

Loads a new sound from a file.

This is equivalent to the module’s load_wav function.

Source

pub fn create_sound(channels: u32, sample_rate: u32, samples: &[u16]) -> Sound

Creates a new sound from a buffer.

Note that this copies the samples internally, so there is effectively no lifetime dependency with the buffer.

Only 1 or 2 channels are supported. The sample rate is a number in Hz, between 1000 and 44100. The number of samples should also not be zero.

§Panic

Panics if the given parameters are invalid for a sound.

Source

pub fn play(&self, channel: u8, loop_: bool, volume: u8)

Plays this sound.

Trait Implementations§

Source§

impl Debug for Sound

Source§

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

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

impl Send for Sound

Auto Trait Implementations§

§

impl Freeze for Sound

§

impl RefUnwindSafe for Sound

§

impl !Sync for Sound

§

impl Unpin for Sound

§

impl UnwindSafe for Sound

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.