Skip to content

Commit

Permalink
tweak meters, clip panning
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetophon committed Nov 15, 2024
1 parent 837a9bf commit 47c07b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,12 @@ impl DelayGraph {
let pan_offset = pan_value * line_length;

pan_path.move_to(diamond_center_x, diamond_center_y);
pan_path.line_to(diamond_center_x + pan_offset, diamond_center_y);
pan_path.line_to(
(diamond_center_x + pan_offset)
.max(bounds.x)
.min(bounds.x + bounds.w),
diamond_center_y,
);
}

canvas.stroke_path(
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,12 +1010,12 @@ impl Plugin for Del2 {
let right = self.delayed_audio_r[tap_index][sample_idx] * post_filter_gain;
output[0][sample_idx] += left;
output[1][sample_idx] += right;
amplitude += left.abs() + right.abs();
amplitude += (left.abs() + right.abs()) * 0.5;
}

if self.params.editor_state.is_open() {
let weight = self.peak_meter_decay_weight * 0.93; // TODO: way too slow without this, why is that?
amplitude = (amplitude / block_len as f32).abs();
let weight = self.peak_meter_decay_weight * 0.91; // TODO: way too slow without this, why is that?
amplitude = (amplitude / block_len as f32).min(1.0);
let current_peak_meter =
self.tap_meters[tap_index].load(std::sync::atomic::Ordering::Relaxed);
let new_peak_meter = if amplitude > current_peak_meter {
Expand Down Expand Up @@ -1474,11 +1474,11 @@ impl Del2 {

for sample in channel_samples {
// Process each sample (e.g., apply gain if necessary)
amplitude += *sample;
amplitude += sample.abs();
}

if self.params.editor_state.is_open() {
amplitude = (amplitude / num_samples as f32).abs();
amplitude = (amplitude / num_samples as f32).min(1.0);
let current_peak_meter = peak_meter.load(std::sync::atomic::Ordering::Relaxed);
let new_peak_meter = if amplitude > current_peak_meter {
amplitude
Expand Down

0 comments on commit 47c07b9

Please sign in to comment.