pub struct Sample<Api: Api = Default>(/* private fields */);Implementations§
Source§impl<Api: Default + Api> Sample<Api>
impl<Api: Default + Api> Sample<Api>
Sourcepub fn new_with_size(bytes: c_int) -> Result<Self, Error>
pub fn new_with_size(bytes: c_int) -> Result<Self, Error>
Allocates and returns a new Sample with a buffer large enough to load a file of length bytes.
Equivalent to sys::ffi::playdate_sound_sample::newSampleBuffer
Sourcepub fn new_for_file<P: AsRef<Path>>(path: P) -> Result<Self, ApiError>
pub fn new_for_file<P: AsRef<Path>>(path: P) -> Result<Self, ApiError>
Retrieves size of file and allocate with that size.
Does not load a file.
Sourcepub fn new_from_file<P: AsRef<Path>>(path: P) -> Result<Self, ApiError>
pub fn new_from_file<P: AsRef<Path>>(path: P) -> Result<Self, ApiError>
Loads the file into the self.
Equivalent to sys::ffi::playdate_sound_sample::load
Sourcepub fn new_from_data<'t>(
data: &'t mut [u8],
format: SoundFormat,
sample_rate: u32,
) -> Result<SampleWithData<'t, Api>, Error>
pub fn new_from_data<'t>( data: &'t mut [u8], format: SoundFormat, sample_rate: u32, ) -> Result<SampleWithData<'t, Api>, Error>
Returns a new Sample referencing the given audio data.
The sample keeps a reference to the data instead of copying it,
so the data must remain valid while the sample is active.
Equivalent to sys::ffi::playdate_sound_sample::newSampleFromData
Source§impl<Api: Api> Sample<Api>
impl<Api: Api> Sample<Api>
Sourcepub fn new_with_size_with(api: Api, bytes: c_int) -> Result<Self, Error>
pub fn new_with_size_with(api: Api, bytes: c_int) -> Result<Self, Error>
Allocates and returns a new Sample with a buffer large enough to load a file of length bytes.
Equivalent to sys::ffi::playdate_sound_sample::newSampleBuffer
Sourcepub fn new_for_file_with<P: AsRef<Path>>(
api: Api,
path: P,
) -> Result<Self, ApiError>
pub fn new_for_file_with<P: AsRef<Path>>( api: Api, path: P, ) -> Result<Self, ApiError>
Retrieves size of file and allocate with that size.
Does not load a file.
Sourcepub fn new_from_file_with<P: AsRef<Path>>(
api: Api,
path: P,
) -> Result<Self, ApiError>
pub fn new_from_file_with<P: AsRef<Path>>( api: Api, path: P, ) -> Result<Self, ApiError>
Loads the file into the self.
Equivalent to sys::ffi::playdate_sound_sample::load
Sourcepub fn new_from_data_with<'t>(
api: Api,
data: &'t mut [u8],
format: SoundFormat,
sample_rate: u32,
) -> Result<SampleWithData<'t, Api>, Error>
pub fn new_from_data_with<'t>( api: Api, data: &'t mut [u8], format: SoundFormat, sample_rate: u32, ) -> Result<SampleWithData<'t, Api>, Error>
Returns a new Sample referencing the given audio data.
The sample keeps a reference to the data instead of copying it,
so the data must remain valid while the sample is active.
Equivalent to sys::ffi::playdate_sound_sample::newSampleFromData
Source§impl<Api: Api> Sample<Api>
impl<Api: Api> Sample<Api>
Sourcepub fn length(&self) -> c_float
pub fn length(&self) -> c_float
Returns the length, in seconds.
Equivalent to sys::ffi::playdate_sound_sample::getLength
Sourcepub fn get_data<'t>(&'t self) -> SampleData<'t>
pub fn get_data<'t>(&'t self) -> SampleData<'t>
Equivalent to sys::ffi::playdate_sound_sample::getData
Trait Implementations§
Source§impl<Api: Api> AsRef<Sample<Api>> for SampleWithData<'_, Api>
impl<Api: Api> AsRef<Sample<Api>> for SampleWithData<'_, Api>
Auto Trait Implementations§
impl<Api> Freeze for Sample<Api>where
Api: Freeze,
impl<Api> RefUnwindSafe for Sample<Api>where
Api: RefUnwindSafe,
impl<Api = Default> !Send for Sample<Api>
impl<Api = Default> !Sync for Sample<Api>
impl<Api> Unpin for Sample<Api>where
Api: Unpin,
impl<Api> UnwindSafe for Sample<Api>where
Api: UnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
§impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.