use super::Signal;
pub trait SignalClipAmp: Signal {
fn clip_amp(self, threshold: f32) -> ClipAmp<Self>
where
Self: Sized,
{
ClipAmp {
signal: self,
threshold,
}
}
}
impl<T> SignalClipAmp for T where T: Signal {}
#[derive(Clone)]
pub struct ClipAmp<S>
where
S: Signal,
{
signal: S,
threshold: f32,
}
impl<S> Signal for ClipAmp<S>
where
S: Signal,
{
#[inline]
fn next(&mut self) -> f32 {
self.signal.next().clamp(-self.threshold, self.threshold)
}
}