Skip to content

Commit

Permalink
only enqueue if value > 0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetophon committed May 31, 2024
1 parent 79186cd commit 3fcb339
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/utils/buffers/histogram_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,17 @@ impl VisualizerBuffer<f32> for HistogramBuffer {
/// Once added, all values are scaled so the largest is 1
fn enqueue(self: &mut Self, value: f32) {
let value = value.abs();
let bin_index = self.find_bin(value);
self.data[bin_index] += (1.0-self.decay_weight); // Increment the count for the bin
for i in 0..self.size-1 {
self.data[i] *= self.decay_weight;
if value > 0.0 {
let bin_index = self.find_bin(value);
self.data[bin_index] += (1.0-self.decay_weight); // Increment the count for the bin
for i in 0..self.size-1 {
self.data[i] *= self.decay_weight;
}
}
}

fn enqueue_buffer(
self: &mut Self,
fn enqueue_buffer(
self: &mut Self,
buffer: &mut nih_plug::buffer::Buffer,
channel: Option<usize>,
) {
Expand Down

0 comments on commit 3fcb339

Please sign in to comment.