mirror of
https://github.com/RustAudio/rodio
synced 2024-11-10 06:04:16 +00:00
Renamed this field for consistency
with other library structs.
This commit is contained in:
parent
a3f36c50f1
commit
7fe76c7e95
2 changed files with 14 additions and 7 deletions
|
@ -11,14 +11,14 @@ where
|
|||
I::Item: Sample,
|
||||
{
|
||||
FadeIn {
|
||||
ramp: linear_gain_ramp(input, duration, 0.0f32, 1.0f32, false),
|
||||
input: linear_gain_ramp(input, duration, 0.0f32, 1.0f32, false),
|
||||
}
|
||||
}
|
||||
|
||||
/// Filter that modifies raises the volume from silence over a time period.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct FadeIn<I> {
|
||||
ramp: LinearGainRamp<I>
|
||||
input: LinearGainRamp<I>
|
||||
}
|
||||
|
||||
impl<I> FadeIn<I>
|
||||
|
@ -29,19 +29,19 @@ where
|
|||
/// Returns a reference to the inner source.
|
||||
#[inline]
|
||||
pub fn inner(&self) -> &I {
|
||||
self.ramp.inner()
|
||||
self.input.inner()
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the inner source.
|
||||
#[inline]
|
||||
pub fn inner_mut(&mut self) -> &mut I {
|
||||
self.ramp.inner_mut()
|
||||
self.input.inner_mut()
|
||||
}
|
||||
|
||||
/// Returns the inner source.
|
||||
#[inline]
|
||||
pub fn into_inner(self) -> I {
|
||||
self.ramp.into_inner()
|
||||
self.input.into_inner()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ where
|
|||
start_gain,
|
||||
end_gain,
|
||||
clamp_end,
|
||||
sample_idx: 0u64,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +38,7 @@ pub struct LinearGainRamp<I> {
|
|||
start_gain: f32,
|
||||
end_gain: f32,
|
||||
clamp_end: bool,
|
||||
sample_idx: u64
|
||||
}
|
||||
|
||||
impl<I> LinearGainRamp<I>
|
||||
|
@ -82,6 +84,8 @@ where
|
|||
factor = 1.0f32;
|
||||
}
|
||||
} else {
|
||||
self.sample_idx += 1;
|
||||
|
||||
factor = f32::lerp(
|
||||
self.start_gain,
|
||||
self.end_gain,
|
||||
|
@ -90,8 +94,11 @@ where
|
|||
);
|
||||
}
|
||||
|
||||
self.elapsed_ns +=
|
||||
1000000000.0 / (self.input.sample_rate() as f32 * self.channels() as f32);
|
||||
if self.sample_idx % (self.channels() as u64) == 0 {
|
||||
self.elapsed_ns +=
|
||||
1000000000.0 / (self.input.sample_rate() as f32);
|
||||
}
|
||||
|
||||
|
||||
self.input.next().map(|value| value.amplify(factor))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue