[−][src]Struct fon::Audio
Audio buffer (array of audio Frame
s 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]
F::Chan: From<S::Chan>,
R: Into<f64>,
M: Stream<S>,
S: Frame,
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]
s_rate: R,
frames: B
) -> Self
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]
B: Into<Box<[i8]>>,
F: Frame<Chan = Ch8>,
R: Into<f64>,
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]
B: Into<Box<[i16]>>,
F: Frame<Chan = Ch16>,
R: Into<f64>,
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]
B: Into<Box<[f32]>>,
F: Frame<Chan = Ch32>,
R: Into<f64>,
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]
B: Into<Box<[f64]>>,
F: Frame<Chan = Ch64>,
R: Into<f64>,
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]
&'a mut self,
reg: R
) -> impl Sink<F> + '_
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]
F::Chan: From<G::Chan>,
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.
pub fn into_iter(self) -> Cloned<Iter<'a, F>>
[src]
impl<F: Frame> Stream<F> for &Audio<F>
[src]
pub fn sample_rate(&self) -> Option<f64>
[src]
pub fn len(&self) -> Option<usize>
[src]
pub fn is_empty(&self) -> bool
[src]
pub fn set_sample_rate<R: Into<f64>>(&mut self, sr: R)
[src]
pub fn take(self, samples: usize) -> TakeStream<F, Self>
[src]
pub fn blend<G: Frame, M: Stream<G>, O: Blend>(
self,
other: M,
op: O
) -> BlendStream<F, G, Self, M, O>
[src]
self,
other: M,
op: O
) -> BlendStream<F, G, Self, M, O>
Auto Trait Implementations
impl<F> RefUnwindSafe for Audio<F> where
F: RefUnwindSafe,
[src]
F: RefUnwindSafe,
impl<F> Send for Audio<F> where
F: Send,
[src]
F: Send,
impl<F> Sync for Audio<F> where
F: Sync,
[src]
F: Sync,
impl<F> Unpin for Audio<F>
[src]
impl<F> UnwindSafe for Audio<F> where
F: UnwindSafe,
[src]
F: UnwindSafe,
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, 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>,