Skip to content

Commit

Permalink
Prevent wobble noises produced by short feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Horacek <petr@zlosynth.com>
  • Loading branch information
phoracek committed Nov 14, 2023
1 parent 7486e0a commit 978989c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ backwards compatibility.
* Visualize progress of the buffer reset.
* Improve position response to control input.
* Make clearing of the tape 2x faster.
* Prevent wobble noises produced by short feedback with wow/flutter.

## 1.2.0

Expand Down
28 changes: 21 additions & 7 deletions dsp/src/delay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub struct Delay {
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
struct Head {
reader: FractionalDelay,
position: f32,
feedback: f32,
volume: f32,
pan: f32,
Expand Down Expand Up @@ -224,16 +225,22 @@ impl Delay {
{
// NOTE: Must read from back, so heads can move from old to new.
let age = buffer_len - i;

let mut offset = age as f32;
if self.wow_flutter_placement.is_read() {
offset += wow_flutter_delays[i];
}
let offset = age as f32;

let mut feedback: f32 = self
.heads
.iter_mut()
.map(|head| head.reader.read(&self.buffer, offset) * head.feedback)
.map(|head| {
// NOTE: Wow and flutter on a very short loop cause
// beeps and wobbles.
head.reader.read(&self.buffer, {
if self.wow_flutter_placement.is_read() && head.position > 0.01 {
offset + wow_flutter_delays[i]
} else {
offset
}
}) * head.feedback
})
.enumerate()
.map(|(i, x)| self.compressor[i].process(self.dc_blocker[i].tick(x)))
.sum();
Expand All @@ -246,7 +253,13 @@ impl Delay {
let mut left = 0.0;
let mut right = 0.0;
for head in &mut self.heads {
let value = head.reader.read(&self.buffer, offset);
let value = head.reader.read(&self.buffer, {
if self.wow_flutter_placement.is_read() {
offset + wow_flutter_delays[i]
} else {
offset
}
});
let amplified = value * head.volume;
left += amplified * (1.0 - head.pan);
right += amplified * head.pan;
Expand Down Expand Up @@ -336,6 +349,7 @@ impl Delay {

self.length = attributes.length;
for (i, head) in self.heads.iter_mut().enumerate() {
head.position = self.length * attributes.heads[i].position;
head.feedback = attributes.heads[i].feedback;
head.volume = attributes.heads[i].volume;
head.pan = attributes.heads[i].pan;
Expand Down

0 comments on commit 978989c

Please sign in to comment.