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
impl Sound
Sourcepub fn load_wav(path: impl AsRef<str>) -> Result<Sound, FileError>
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.
Sourcepub fn create_sound(channels: u32, sample_rate: u32, samples: &[u16]) -> Sound
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.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more