Add inner accessors for more sources

This commit is contained in:
Joe Clay 2019-01-17 01:10:12 +00:00
parent 4bb832ba30
commit 53a7d78cd8
8 changed files with 171 additions and 0 deletions

View file

@ -49,6 +49,24 @@ where
pub fn set_volume(&mut self, channel: usize, volume: f32) {
self.channel_volumes[channel] = volume;
}
/// Returns a reference to the inner source.
#[inline]
pub fn inner(&self) -> &I {
&self.input
}
/// Returns a mutable reference to the inner source.
#[inline]
pub fn inner_mut(&mut self) -> &mut I {
&mut self.input
}
/// Returns the inner source.
#[inline]
pub fn into_inner(self) -> I {
self.input
}
}
impl<I> Iterator for ChannelVolume<I>

View file

@ -31,6 +31,30 @@ where
requested_duration: Duration,
}
impl<I> Delay<I>
where
I: Source,
I::Item: Sample,
{
/// Returns a reference to the inner source.
#[inline]
pub fn inner(&self) -> &I {
&self.input
}
/// Returns a mutable reference to the inner source.
#[inline]
pub fn inner_mut(&mut self) -> &mut I {
&mut self.input
}
/// Returns the inner source.
#[inline]
pub fn into_inner(self) -> I {
self.input
}
}
impl<I> Iterator for Delay<I>
where
I: Source,

View file

@ -29,6 +29,24 @@ where
signal_sent: false,
}
}
/// Returns a reference to the inner source.
#[inline]
pub fn inner(&self) -> &I {
&self.input
}
/// Returns a mutable reference to the inner source.
#[inline]
pub fn inner_mut(&mut self) -> &mut I {
&mut self.input
}
/// Returns the inner source.
#[inline]
pub fn into_inner(self) -> I {
self.input
}
}
impl<I: Source> Iterator for Done<I>

View file

@ -30,6 +30,30 @@ where
total_ns: f32,
}
impl<I> FadeIn<I>
where
I: Source,
I::Item: Sample,
{
/// Returns a reference to the inner source.
#[inline]
pub fn inner(&self) -> &I {
&self.input
}
/// Returns a mutable reference to the inner source.
#[inline]
pub fn inner_mut(&mut self) -> &mut I {
&mut self.input
}
/// Returns the inner source.
#[inline]
pub fn into_inner(self) -> I {
self.input
}
}
impl<I> Iterator for FadeIn<I>
where
I: Source,

View file

@ -38,6 +38,32 @@ pub struct PeriodicAccess<I, F> {
samples_until_update: u32,
}
impl<I, F> PeriodicAccess<I, F>
where
I: Source,
I::Item: Sample,
F: FnMut(&mut I),
{
/// Returns a reference to the inner source.
#[inline]
pub fn inner(&self) -> &I {
&self.input
}
/// Returns a mutable reference to the inner source.
#[inline]
pub fn inner_mut(&mut self) -> &mut I {
&mut self.input
}
/// Returns the inner source.
#[inline]
pub fn into_inner(self) -> I {
self.input
}
}
impl<I, F> Iterator for PeriodicAccess<I, F>
where
I: Source,

View file

@ -34,6 +34,24 @@ where
dest: PhantomData,
}
}
/// Returns a reference to the inner source.
#[inline]
pub fn inner(&self) -> &I {
&self.inner
}
/// Returns a mutable reference to the inner source.
#[inline]
pub fn inner_mut(&mut self) -> &mut I {
&mut self.inner
}
/// Returns the inner source.
#[inline]
pub fn into_inner(self) -> I {
self.inner
}
}
impl<I, D> Iterator for SamplesConverter<I, D>

View file

@ -26,6 +26,31 @@ where
factor: f32,
}
impl<I> Speed<I>
where
I: Source,
I::Item: Sample,
{
/// Returns a reference to the inner source.
#[inline]
pub fn inner(&self) -> &I {
&self.input
}
/// Returns a mutable reference to the inner source.
#[inline]
pub fn inner_mut(&mut self) -> &mut I {
&mut self.input
}
/// Returns the inner source.
#[inline]
pub fn into_inner(self) -> I {
self.input
}
}
impl<I> Iterator for Speed<I>
where
I: Source,

View file

@ -40,6 +40,24 @@ where
// \|/ the maximum value of `ns` is one billion, so this can't fail
Duration::new(0, ns as u32)
}
/// Returns a reference to the inner source.
#[inline]
pub fn inner(&self) -> &I {
&self.input
}
/// Returns a mutable reference to the inner source.
#[inline]
pub fn inner_mut(&mut self) -> &mut I {
&mut self.input
}
/// Returns the inner source.
#[inline]
pub fn into_inner(self) -> I {
self.input
}
}
impl<I> Iterator for TakeDuration<I>