1
0
Fork 0

AM only the positive ranges

This is what the original Fake Distortion preset did.
This commit is contained in:
Robbert van der Helm 2022-03-08 23:20:30 +01:00
parent 46901bf5c9
commit 792e9469b5

View file

@ -20,12 +20,12 @@ use std::pin::Pin;
mod pcg;
/// Hardcoded to make SIMD-ifying this a bit easier in the future
const NUM_CHANNELS: usize = 2;
/// These seeds being fixed makes bouncing deterministic.
const INITIAL_PRNG_SEED: Pcg32iState = Pcg32iState::new(69, 420);
/// Allow 100% amount to scale the gain to a bit above 100%, to make the effect even less subtle.
const AMOUNT_GAIN_MULTIPLIER: f32 = 2.0;
/// This plugin essentially layers the sound with another copy of the signal AM'ed with white (or
/// filtered) noise. That other copy of the sound may have a low pass filter applied to it since
/// this effect just turns into literal noise at high frequencies.
@ -101,15 +101,14 @@ impl Plugin for Crisp {
_context: &mut impl ProcessContext,
) -> ProcessStatus {
for channel_samples in buffer.iter_mut() {
let amount = self.params.amount.smoothed.next();
let amount = self.params.amount.smoothed.next() * AMOUNT_GAIN_MULTIPLIER;
// TODO: SIMD-ize this to process both channels at once
// TODO: This does not sound quite right
for sample in channel_samples.into_iter() {
let noise = self.prng.next_f32() * 2.0 - 1.0;
let am = *sample * noise;
let half_am = sample.max(0.0) * noise;
*sample += am * amount;
*sample += half_am * amount;
}
}