[][src]Struct fon::Audio

pub struct Audio<F: Frame> { /* fields omitted */ }

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

Audio implements the Stream trait.

Implementations

impl<F: Frame> Audio<F>[src]

pub fn get(&self, index: usize) -> Option<F>[src]

Get an audio frame.

pub fn get_mut(&mut self, index: usize) -> Option<&mut F>[src]

Get a mutable reference to an audio frame.

pub fn as_slice(&mut self) -> &mut [F][src]

Get a contiguous slice of all audio frames. This may have to re-arrange memory if drain() was used, and could be slow. If drain() was not called, this method should run in constant time.

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

Returns an iterator over the audio frames.

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

Returns an iterator that allows modifying each audio frame.

pub fn with_frame<R: Into<f64>>(s_rate: R, len: usize, frame: F) -> Self[src]

Construct an Audio buffer with all audio frames set to one value.

pub fn with_silence<R: Into<f64>>(s_rate: R, len: usize) -> Self[src]

Construct an Audio buffer with all all samples set to zero.

pub fn with_stream<S, R, M>(s_rate: R, src: M) -> Self where
    F::Chan: From<S::Chan>,
    R: Into<f64>,
    M: Stream<S>,
    S: Frame
[src]

Construct an Audio buffer from the contents of a Stream.

The audio format can be converted with this function.

Panics

When an infinite stream is passed in.

pub fn with_frames<B: Into<Box<[F]>>, R: Into<f64>>(
    s_rate: R,
    frames: B
) -> Self
[src]

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

pub fn with_i8_buffer<B, R>(s_rate: R, buffer: B) -> Self where
    B: Into<Box<[i8]>>,
    F: Frame<Chan = Ch8>,
    R: Into<f64>, 
[src]

Construct an Audio buffer from an i8 buffer.

pub fn with_i16_buffer<B, R>(s_rate: R, buffer: B) -> Self where
    B: Into<Box<[i16]>>,
    F: Frame<Chan = Ch16>,
    R: Into<f64>, 
[src]

Construct an Audio buffer from an i16 buffer.

pub fn with_f32_buffer<B, R>(s_rate: R, buffer: B) -> Self where
    B: Into<Box<[f32]>>,
    F: Frame<Chan = Ch32>,
    R: Into<f64>, 
[src]

Construct an Audio buffer from an f32 buffer.

pub fn with_f64_buffer<B, R>(s_rate: R, buffer: B) -> Self where
    B: Into<Box<[f64]>>,
    F: Frame<Chan = Ch64>,
    R: Into<f64>, 
[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) -> f64[src]

Get the sample rate of the Audio buffer.

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

Create an audio sink to overwrite a region of this Audio buffer.

Panics

If range is out of bounds

pub fn drain(&mut self) -> impl Stream<F> + '_[src]

Create a draining audio stream from this Audio buffer. When the stream is dropped, only sinked audio samples will be removed.

pub fn extend<G: Frame, M: Stream<G>>(&mut self, stream: M) where
    F::Chan: From<G::Chan>, 
[src]

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

Notes

Do not call repeatedly on a stream with a differnt sample rate. It will create extra "partial" samples.

Panics

When an infinite stream is passed in.

impl<F: Frame<Chan = Ch8>> Audio<F>[src]

pub fn as_i8_slice(&mut self) -> &mut [i8][src]

Get view of samples as an i8 slice. May require reordering memory.

impl<F: Frame<Chan = Ch16>> Audio<F>[src]

pub fn as_i16_slice(&mut self) -> &mut [i16][src]

Get view of samples as an i16 slice.

impl<S: Frame<Chan = Ch32>> Audio<S>[src]

pub fn as_f32_slice(&mut self) -> &mut [f32][src]

Get view of samples as an f32 slice.

impl<F: Frame<Chan = Ch64>> Audio<F>[src]

pub fn as_f64_slice(&mut self) -> &mut [f64][src]

Get view of samples as an f64 slice.

Trait Implementations

impl<F: Debug + Frame> Debug for Audio<F>[src]

impl<'a, F: Frame> IntoIterator for &'a Audio<F>[src]

type IntoIter = Cloned<Iter<'a, F>>

Which kind of iterator are we turning this into?

type Item = F

The type of the elements being iterated over.

impl<F: Frame> Stream<F> for &Audio<F>[src]

Auto Trait Implementations

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

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

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

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

impl<F> UnwindSafe for Audio<F> where
    F: 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.