From the original SynthMaker forum (2004–2014), with its members’ names and dates.
nmakinen ·
Hello,
I tried searching for a nice (moving average?) filter for smoothing an envelope, but couldn't find any. Since I can't code, I made a solution in SM which basically calculates the average of 9 consecutive samples at a time. It worked out pretty well when using the right values, because it turns a square wave into a near-perfect sine wave. But if you do it this way, it's probably quite CPU-costly, and if you want to do the same calculation with 200 samples, there's a lot of dirty work to do.
Is there a (coded) solution for this?
I found this code here on the forum, but it only makes the beginning of the envelope smooth and leaves the end sharp (why does this happen?). Look at the picture below to see what I mean. Doesn't look like a sine wave to me..
Your code example is a first order lowpass, sometimes referred to as leaky integrator. It will provide some basic smoothening. You may play with the f parameter (which is related to the cutoff frequency or amount of smoothening), however you will always get those kinks where there were discontinuities in the original signal. If you want it smoother try biquad lowpass filters or simply use two or more first order lowpasses in series.
There is also a running average module in SM however it will not turn a square wave into a sinus (triangle at best).
nmakinen ·
Thanks. I've tried some biquad lowpass filters (like the ones that come with SM), but when using low cutoff frequency, they haven't kept the volume right. I'm using an AHR envelope follower and have set the hold time long enough, so the filter has plenty of time to make the output signal reach the maximum volume, but it still doesn't match the maximum volume of the original signal. This problem doesn't occur with higher cutoff frequencies.
This would be essential for my purpose, because I'm making a brickwall limiter. The maximum peak level of the filtered envelope signal should be equal to the max level of the non-filtered one. If you know a solution for this, please let me know!
- nmakinen
nmakinen ·
The running average module seems very useful for similar purposes, but when the interval time is changed, the overall volume of the module gets louder than it should be. I want the interval time to be linked to a knob, so this shouldn't happen. Any ideas?
Wrote something here? To have a post removed or your name hidden, write to [email protected].