Struct web_audio_api::alloc::ChannelData [−][src]
Single channel audio samples, basically wraps a Rc<[f32; BUFFER_SIZE]>
ChannelData has copy-on-write semantics, so it is cheap to clone.
Implementations
impl ChannelData
[src]
pub fn is_silent(&self) -> bool
[src]
O(1)
check if this buffer is equal to the ‘silence buffer’
If this function returns false, it is still possible for all samples to be zero.
pub fn add(&mut self, other: &Self)
[src]
Sum two channels
pub fn silence(&self) -> Self
[src]
Methods from Deref<Target = [f32; 128]>
pub fn as_slice(&self) -> &[T]
[src]
array_methods
)Returns a slice containing the entire array. Equivalent to &s[..]
.
pub fn as_mut_slice(&mut self) -> &mut [T]
[src]
array_methods
)Returns a mutable slice containing the entire array. Equivalent to
&mut s[..]
.
pub fn each_ref(&self) -> [&T; N]
[src]
array_methods
)Borrows each element and returns an array of references with the same
size as self
.
Example
#![feature(array_methods)] let floats = [3.1, 2.7, -1.0]; let float_refs: [&f64; 3] = floats.each_ref(); assert_eq!(float_refs, [&3.1, &2.7, &-1.0]);
This method is particularly useful if combined with other methods, like
map
. This way, you can avoid moving the original
array if its elements are not Copy
.
#![feature(array_methods, array_map)] let strings = ["Ferris".to_string(), "♥".to_string(), "Rust".to_string()]; let is_ascii = strings.each_ref().map(|s| s.is_ascii()); assert_eq!(is_ascii, [true, false, true]); // We can still access the original array: it has not been moved. assert_eq!(strings.len(), 3);
pub fn each_mut(&mut self) -> [&mut T; N]
[src]
array_methods
)Borrows each element mutably and returns an array of mutable references
with the same size as self
.
Example
#![feature(array_methods)] let mut floats = [3.1, 2.7, -1.0]; let float_refs: [&mut f64; 3] = floats.each_mut(); *float_refs[0] = 0.0; assert_eq!(float_refs, [&mut 0.0, &mut 2.7, &mut -1.0]); assert_eq!(floats, [0.0, 2.7, -1.0]);
Trait Implementations
impl Clone for ChannelData
[src]
fn clone(&self) -> ChannelData
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Deref for ChannelData
[src]
type Target = [f32; 128]
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl DerefMut for ChannelData
[src]
impl Drop for ChannelData
[src]
Auto Trait Implementations
impl !RefUnwindSafe for ChannelData
impl !Send for ChannelData
impl !Sync for ChannelData
impl Unpin for ChannelData
impl !UnwindSafe for ChannelData
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,