1
$\begingroup$

I implemented an echo effect using the following diagrams: enter image description here

enter image description here

To summarize, an echo effect is basically a positive feedback effect that is implemented with a delay line zD which delays the input signal by D samples. My effects works fine. I get the echo effect.

My issue is I gave the user to adjust D sample amount during runtime just like in Pioneer equiments you can set echo as 4beats, 2beats, 1beats etc. When a user request a beat duration change I immediatly change the D parameter in my audio plugin. The problem is sometimes this causes click due to sudden audio level changes. I am trying to find a way to counter this but so far I can not think of anyways to do it. How may I ensure that the audio level is continous(doesnt spike and result in audio clicks) when user changes the parameter D?

$\endgroup$
2
$\begingroup$

Maybe, when $D$ changes, you can crossfade from the audio at the old $D$ to audio at the new $D$.

If you ran a pitch detector alongside of the delay (and stored the detected period length in a corresponding array) you could crossfade one period at a time until you got to within a period of your new $D$. Then slide very slowly to the exact $D$.

$\endgroup$
5
  • $\begingroup$ I tried cross fade with 16ms, the results got way better but somehow I sometimes do get clicks still. This audio click problem shows up everytime I work with audio. So frustrating. It ruins my code base too. Is there something like a general click detector algorithm to detect the clicks and smooth them? I really tried to find one but no luck. I notice this issue is even present on YouTube app. So I guess its not very easy to solve this issue... $\endgroup$
    – cs guy
    Apr 23 at 2:32
  • $\begingroup$ I think a 16 ms cross fade is long enough when $D$ changes smoothly. But since $D$ won't change all the time, you may try a longer cross fade. $\endgroup$
    – ZR Han
    Apr 23 at 3:13
  • $\begingroup$ 16 ms is the displacement of the crossfades, right? The difference between the initial $D$ and the final $D$, right? It's not necessarily the crossfade time, right? $\endgroup$ Apr 23 at 13:25
  • $\begingroup$ @robertbristow-johnson 16ms it is the crossfade time between fading from initial $D$ to final $D$, here is how i used it in my code crossFadePerc * targetDelayVal + (1 - crossFadePerc) * curDelayVal; with each sample crossFadePerc increases from 0.0f to 1.0f $\endgroup$
    – cs guy
    Apr 23 at 14:07
  • 1
    $\begingroup$ I applied equal power cross fade (I've seen this in one of your posts) and pushed the cross fade value to my echo buffer and the results are very good. I am testing the results on a bass sample and I get very minimal noise alike sounds, clicks are gone. Thank your for helping. You are awesome. $\endgroup$
    – cs guy
    Apr 23 at 15:44
1
$\begingroup$

One way to do this is to have a simple one pole smoothing filter. The one-pole lowpass filter is often used to smooth noisy signals to seek slow-moving trends in them. The one pole filter is defined as $$\begin{aligned} y(n) = x(n) + a_1 y(n-1)\\ H(z) = \frac{Y(z)}{X(z)} = \frac{1}{1-a_1z^{-1}} \end{aligned}$$ The pole is located at $z = a_1$. In such applications where the parameter needs to be interpolated smoothly, the pole is typically located near DC, and you can use $a_1 \approx 0.99$. This means the output of your filter starts rolling off at a rate of -20dB/decade near 0Hz.

enter image description here

You are applying this filter to your parameter value, $D$, which is being changed by the user. This filter ensures that your parameter value changes smoothly (it filters out rapid changes), and does not cause any clicks in the audio. There must be a function in your plugin that takes care of that update. $x(n)$ is the input value from the slider, $y(n)$ will be the smoothed and filtered value that you will send to the echo effect in the audio callback function. In the update method, you will need to store the value of the last element that was output, $y(n-1)$, to calculate the current value of $y(n)$.

$\endgroup$
5
  • $\begingroup$ Well this answer was too advanced for me to understand sadly, I haven't worked with filters before, there is a section about filters in the book I am reading, It is around 40 pages, I will read that and will check with this answer. Let me ask one thing, so basically your solution is to apply this filter after applying echo parameter change right? $\endgroup$
    – cs guy
    Apr 22 at 18:30
  • $\begingroup$ Also wouldn't a low pass filter alter the audio signal a lot? I've heard people suggesting low pass filters for clicks before but I was always hesitant since I wouldn't want my original audio signal to sound too different after smoothing with a Low pass, I might be wrong here, I'm very new to filters $\endgroup$
    – cs guy
    Apr 22 at 18:50
  • $\begingroup$ I have updated my answer, you are applying the low pass filter to the parameter value, not to the signal. It is just a filter to smooth out rapid changes in the slider value. $\endgroup$
    – orchi_d
    Apr 22 at 19:12
  • $\begingroup$ I tried something similar, I tried a linear interpolation on value change with 16ms (1 frame 60fps), the problem was it caused a strange audable audio, i suspected that it is because the ms change gets feed into feedback, I am not sure if my implementation was wrong or not tho, ie let's say you want to go from 2 beats to 1 beats, if you interpolate the feedback will use some values between 2beats and 1 beat causing a potential strange audio $\endgroup$
    – cs guy
    Apr 22 at 20:35
  • $\begingroup$ i debuged my code and, smoothing the D value actually causes strange audable audio, this is again probably due to smoothed data gets fed into the feedback causing strange additions, is there a way to solve my problem without parameter smoothing? $\endgroup$
    – cs guy
    Apr 22 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.