Struct rich_sdl2_rust::audio::buffer::AudioBuffer
source · pub struct AudioBuffer<T> { /* private fields */ }
Expand description
An audio buffer with a format, sample rates, numbers of channels and a buffer.
Implementations§
source§impl<T> AudioBuffer<T>
impl<T> AudioBuffer<T>
sourcepub fn new(
format: AudioFormat,
samples: u32,
channels: u8,
buffer: Vec<T>
) -> Self
pub fn new( format: AudioFormat, samples: u32, channels: u8, buffer: Vec<T> ) -> Self
Constructs an audio buffer from arguments. The size of type which stored by buffer must equal to the format bit size.
§Panics
Panics if the size of type T
does not equal to the format bit size.
sourcepub fn format(&self) -> &AudioFormat
pub fn format(&self) -> &AudioFormat
Returns the format of the audio buffer.
sourcepub fn convert<U: Default + Clone>(
self,
format: AudioFormat,
samples: u32,
channels: u8
) -> Result<AudioBuffer<U>>
pub fn convert<U: Default + Clone>( self, format: AudioFormat, samples: u32, channels: u8 ) -> Result<AudioBuffer<U>>
Convert into another AudioBuffer
with different format, sample rate or channels.
§Errors
Returns Err
if failed to convert into a specific format.
sourcepub fn convert_in<U: Default + Clone>(
self,
other: &mut AudioBuffer<U>
) -> Result<()>
pub fn convert_in<U: Default + Clone>( self, other: &mut AudioBuffer<U> ) -> Result<()>
Convert and write into another existing AudioBuffer
.
§Errors
Returns Err
if failed to convert between self
and other
.
Trait Implementations§
source§impl<T: Clone> Clone for AudioBuffer<T>
impl<T: Clone> Clone for AudioBuffer<T>
source§fn clone(&self) -> AudioBuffer<T>
fn clone(&self) -> AudioBuffer<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<T> RefUnwindSafe for AudioBuffer<T>where
T: RefUnwindSafe,
impl<T> Send for AudioBuffer<T>where
T: Send,
impl<T> Sync for AudioBuffer<T>where
T: Sync,
impl<T> Unpin for AudioBuffer<T>where
T: Unpin,
impl<T> UnwindSafe for AudioBuffer<T>where
T: UnwindSafe,
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