1
0
Fork 0

Remove all traces of Buffr Glitch normalization

This isn't going to work anymore.
This commit is contained in:
Robbert van der Helm 2023-01-16 23:48:57 +01:00
parent 754f3c3785
commit 955f40da11
2 changed files with 5 additions and 61 deletions

View file

@ -16,7 +16,7 @@
use nih_plug::prelude::*;
use crate::{NormalizationMode, MAX_OCTAVE_SHIFT};
use crate::MAX_OCTAVE_SHIFT;
/// A super simple ring buffer abstraction that records audio into a buffer until it is full, and
/// then starts looping the already recorded audio. The recording starts hwne pressing a key so
@ -91,12 +91,7 @@ impl RingBuffer {
/// this will store the input samples into the bufffer and return the input value as is.
/// Afterwards it will read the previously recorded data from the buffer. The read/write
/// position is advanced whenever the last channel is written to.
pub fn next_sample(
&mut self,
channel_idx: usize,
input_sample: f32,
normalization_mode: NormalizationMode,
) -> f32 {
pub fn next_sample(&mut self, channel_idx: usize, input_sample: f32) -> f32 {
if !self.playback_buffer_ready {
self.audio_buffers[channel_idx][self.next_sample_pos] = input_sample;
}
@ -110,36 +105,10 @@ impl RingBuffer {
if self.next_sample_pos == self.audio_buffers[0].len() {
self.next_sample_pos = 0;
// The playback buffer is normalized as necessary. This prevents small grains from being
// either way quieter or way louder than the origianl audio.
if !self.playback_buffer_ready {
match normalization_mode {
NormalizationMode::None => (),
NormalizationMode::Auto => {
// FIXME: This needs to take the input audio into account, but we don't
// have access to that anymore. We can just use a simple envelope
// follower instead
// // Prevent this from causing divisions by zero or making very loud clicks when audio
// // playback has just started
// let playback_rms = calculate_rms(&self.playback_buffers);
// if playback_rms > 0.001 {
// let recording_rms = calculate_rms(&self.recording_buffers);
// let normalization_factor = recording_rms / playback_rms;
// for buffer in self.playback_buffers.iter_mut() {
// for sample in buffer.iter_mut() {
// *sample *= normalization_factor;
// }
// }
// }
}
}
// At this point the buffer is ready for playback
self.playback_buffer_ready = true;
}
}
}
result
}

View file

@ -41,10 +41,6 @@ struct BuffrGlitch {
#[derive(Params)]
struct BuffrGlitchParams {
// FIXME: Add normalization back in, it doesn't work anymore so it's been removed to avoid causing confusion
// /// Controls whether and how grains are normalization.
// #[id = "normalization_mode"]
// normalization_mode: EnumParam<NormalizationMode>,
/// From 0 to 1, how much of the dry signal to mix in. This defaults to 1 but it can be turned
/// down to use Buffr Glitch as more of a synth.
#[id = "dry_mix"]
@ -59,18 +55,6 @@ struct BuffrGlitchParams {
octave_shift: IntParam,
}
/// Controls how grains are normalized.
#[derive(Enum, Debug, PartialEq, Eq)]
pub enum NormalizationMode {
/// Don't normalize at all
#[id = "none"]
None,
/// Automatically normalize based on the recording buffer's RMS value.
#[id = "auto"]
Auto,
// TODO: Explicit RMS target
}
impl Default for BuffrGlitch {
fn default() -> Self {
Self {
@ -88,7 +72,6 @@ impl Default for BuffrGlitch {
impl Default for BuffrGlitchParams {
fn default() -> Self {
Self {
// normalization_mode: EnumParam::new("Normalization", NormalizationMode::Auto),
dry_level: FloatParam::new(
"Dry Level",
1.0,
@ -166,7 +149,6 @@ impl Plugin for BuffrGlitch {
context: &mut impl ProcessContext<Self>,
) -> ProcessStatus {
let mut next_event = context.next_event();
for (sample_idx, channel_samples) in buffer.iter_samples().enumerate() {
let dry_amount = self.params.dry_level.smoothed.next();
@ -213,14 +195,7 @@ impl Plugin for BuffrGlitch {
for (channel_idx, sample) in channel_samples.into_iter().enumerate() {
// This will start recording on the first iteration, and then loop the recorded
// buffer afterwards
let result = self.buffer.next_sample(
channel_idx,
*sample,
// FIXME: This has temporarily been removed, and `NormalizationMode::Auto`
// doesn't do anything right now
// self.params.normalization_mode.value(),
NormalizationMode::Auto,
);
let result = self.buffer.next_sample(channel_idx, *sample);
*sample = result * self.midi_note_gain_scaling;
}