Struct rust_raylib::audio::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 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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.