Struct Wave

Source
pub struct Wave { /* private fields */ }
Expand description

Wave, audio wave data

Implementations§

Source§

impl Wave

Source

pub fn frame_count(&self) -> u32

Total number of frames (considering channels)

Source

pub fn sample_rate(&self) -> u32

Frequency (samples per second)

Source

pub fn sample_size(&self) -> u32

Bit depth (bits per sample): 8, 16, 32 (24 not supported)

Source

pub fn channels(&self) -> u32

Number of channels (1-mono, 2-stereo, …)

Source

pub fn from_file(file_name: &str) -> Option<Self>

Load wave data from file

Source

pub fn from_memory(file_data: &[u8], format: AudioFormat) -> Option<Self>

Load wave from memory buffer

Source

pub fn export(&self, file_name: &str) -> bool

Export wave data to file, returns true on success

Source

pub fn export_as_code(&self, file_name: &str) -> bool

Export wave sample data to code (.h), returns true on success

Source

pub fn crop(&mut self, init_sample: u32, final_sample: u32)

Crop a wave to defined samples range

Source

pub fn convert_to_format( &mut self, sample_rate: u32, sample_size: u32, channels: u32, )

Convert wave data to desired format

Source

pub fn load_samples(&self) -> Vec<f32>

Load samples data from wave as a 32bit float data array

Source

pub fn as_raw(&self) -> &Wave

Get the ‘raw’ ffi type Take caution when cloning so it doesn’t outlive the original

Source

pub fn as_raw_mut(&mut self) -> &mut Wave

Get the ‘raw’ ffi type Take caution when cloning so it doesn’t outlive the original

Source

pub unsafe fn from_raw(raw: Wave) -> Self

Convert a ‘raw’ ffi object to a safe wrapper

§Safety
  • The raw object must be correctly initialized
  • The raw object should be unique. Otherwise, make sure its clones don’t outlive the newly created object.

Trait Implementations§

Source§

impl Clone for Wave

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Wave

Source§

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

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

impl Drop for Wave

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Wave

§

impl RefUnwindSafe for Wave

§

impl !Send for Wave

§

impl !Sync for Wave

§

impl Unpin for Wave

§

impl UnwindSafe for Wave

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.