[][src]Struct fon::Audio

pub struct Audio<S: Sample> { /* fields omitted */ }

Audio buffer (array of audio Samples at sample rate specified in hertz).

Implementations

impl<S: Sample> Audio<S>[src]

pub fn sample(&self, index: usize) -> &S[src]

Get a sample.

Panics

If index is out of bounds

pub fn sample_mut(&mut self, index: usize) -> &mut S[src]

Get a mutable sample.

Panics

If index is out of bounds

pub fn samples(&self) -> &[S][src]

Get a slice of all samples.

pub fn samples_mut(&mut self) -> &mut [S][src]

Get a mutable slice of all samples.

pub fn iter(&self) -> Iter<'_, S>[src]

Returns an iterator over the samples.

pub fn iter_mut(&mut self) -> IterMut<'_, S>[src]

Returns an iterator that allows modifying each sample.

pub fn with_sample(s_rate: u32, len: usize, sample: S) -> Self[src]

Construct an Audio buffer with all samples set to one value.

pub fn with_silence(s_rate: u32, len: usize) -> Self[src]

Construct an Audio buffer with all all samples set to the default value.

pub fn with_audio<SrcS: Sample>(s_rate: u32, src: &Audio<SrcS>) -> Self where
    S::Chan: From<SrcS::Chan>, 
[src]

Construct an Audio buffer with another Audio buffer.

The audio format can be converted with this function.

pub fn with_samples<B: Into<Box<[S]>>>(s_rate: u32, samples: B) -> Self[src]

Construct an Audio buffer with owned sample data. You can get ownership of the pixel data back from the Audio buffer as either a Vec<S> or a Box<[S]> by calling into().

pub fn with_i8_buffer<B>(s_rate: u32, buffer: B) -> Self where
    B: Into<Box<[i8]>>,
    S: Sample<Chan = Ch8>, 
[src]

Construct an Audio buffer from an i8 buffer.

pub fn with_i16_buffer<B>(s_rate: u32, buffer: B) -> Self where
    B: Into<Box<[i16]>>,
    S: Sample<Chan = Ch16>, 
[src]

Construct an Audio buffer from an i16 buffer.

pub fn with_f32_buffer<B>(s_rate: u32, buffer: B) -> Self where
    B: Into<Box<[f32]>>,
    S: Sample<Chan = Ch32>, 
[src]

Construct an Audio buffer from an f32 buffer.

pub fn with_f64_buffer<B>(s_rate: u32, buffer: B) -> Self where
    B: Into<Box<[f64]>>,
    S: Sample<Chan = Ch64>, 
[src]

Construct an Audio buffer from an f64 buffer.

pub fn len(&self) -> usize[src]

Get the length of the Audio buffer.

pub fn is_empty(&self) -> bool[src]

Check if Audio buffer is empty.

pub fn sample_rate(&self) -> u32[src]

Get the sample rate of the Audio buffer.

pub fn blend_sample<O: Blend, R: RangeBounds<usize> + SliceIndex<[S], Output = [S]>>(
    &mut self,
    reg: R,
    sample: S,
    op: O
)
[src]

Blend Audio buffer with a single sample.

pub fn blend_audio<O: Blend, R: RangeBounds<usize> + SliceIndex<[S], Output = [S]>>(
    &mut self,
    reg: R,
    other: &Self,
    op: O
)
[src]

Blend Audio buffer with another Audio buffer.

pub fn copy_silence<R: RangeBounds<usize> + SliceIndex<[S], Output = [S]>>(
    &mut self,
    reg: R
)
[src]

Copy silence into a region of the Audio.

Panics

If range is out of bounds on the Audio buffer.

pub fn copy_sample<R: RangeBounds<usize> + SliceIndex<[S], Output = [S]>>(
    &mut self,
    reg: R,
    sample: S
)
[src]

Copy sample into a region of the Audio.

Panics

If range is out of bounds on the Audio buffer.

pub fn stream<'a, R: RangeBounds<usize> + SliceIndex<[S], Output = [S]> + 'a>(
    &'a self,
    reg: R
) -> impl Stream<S> + 'a
[src]

Create an audio stream over this Audio buffer.

Panics

If range is out of bounds

pub fn drain<'a, R: RangeBounds<usize> + SliceIndex<[S], Output = [S]> + Clone + 'a>(
    &'a mut self,
    reg: R
) -> impl Stream<S> + 'a
[src]

Create a draining audio stream over this Audio buffer.

Panics

If range is out of bounds

pub fn sink<'a, R: 'a + RangeBounds<usize> + SliceIndex<[S], Output = [S]>>(
    &'a mut self,
    reg: R
) -> impl Sink<S> + 'a
[src]

Create an audio sink to overwrite this Audio buffer.

Panics

If range is out of bounds

pub fn extend<M: Stream<S>>(&mut self, stream: &mut M)[src]

Extend the audio buffer with all of the audio from a stream.

Don't call this with an infinite stream! This is the only way to collect a stream without knowing the size ahead of time.

Trait Implementations

impl<S: Debug + Sample> Debug for Audio<S>[src]

impl<S: Sample> From<Audio<S>> for Box<[S]>[src]

pub fn from(audio: Audio<S>) -> Self[src]

Get internal pixel data as boxed slice.

impl<S: Sample> From<Audio<S>> for Vec<S>[src]

pub fn from(audio: Audio<S>) -> Self[src]

Get internal pixel data as Vec of samples.

impl<S> From<Audio<S>> for Box<[i8]> where
    S: Sample<Chan = Ch8>, 
[src]

pub fn from(audio: Audio<S>) -> Self[src]

Get internal pixel data as boxed slice of i8.

impl<S> From<Audio<S>> for Box<[i16]> where
    S: Sample<Chan = Ch16>, 
[src]

pub fn from(audio: Audio<S>) -> Self[src]

Get internal pixel data as boxed slice of u16.

impl<S> From<Audio<S>> for Box<[f32]> where
    S: Sample<Chan = Ch32>, 
[src]

pub fn from(audio: Audio<S>) -> Self[src]

Get internal pixel data as boxed slice of u16.

impl<S> From<Audio<S>> for Box<[f64]> where
    S: Sample<Chan = Ch64>, 
[src]

pub fn from(audio: Audio<S>) -> Self[src]

Get internal pixel data as boxed slice of u16.

Auto Trait Implementations

impl<S> RefUnwindSafe for Audio<S> where
    S: RefUnwindSafe
[src]

impl<S> Send for Audio<S> where
    S: Send
[src]

impl<S> Sync for Audio<S> where
    S: Sync
[src]

impl<S> Unpin for Audio<S>[src]

impl<S> UnwindSafe for Audio<S> where
    S: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.