It looks like what is happening is that lets say attack = .50, the output would be *input + .50 for attack. Now, that would just add volume wouldnt it? and otherwise if release, *input - release.
I don't get this at all, since attack and release are supposed to be TIME values, but to me, in my head, I dont see any time being changed, its just adding more volume or taking it away??????
I'm completely lost on this... Any idea how I can get my head around this, or where I am going wrong with this thinking? What am i MIssing?
BTW: if anyone wants to port that to simple`c++ from JS so its easier to understand, that would be cool... I'm so frustrated that I don't understand this, it looks like very very simple dsp. Unfortunately for compression i cant find much if anything on how to understand the DSP involved.
Thank you,
~Rob.
robrokken ·
Well, I can see here from this that this is the start of the envelope, with Full Wave Rectification it looks like:
Not really sure why its called "max samples". But lets say that max samples is 10 and the threshold is 5 and ratio is 5:
seekgain = 5 + 5 / 5 which gives seekgain a value of 2. gain = 1 so seekgain is greater so we use "decay" which is like .0015. so that means
gain * release so 1 * .0015
So all we are doing is for this sample just multiplying the input signal by .0015 ..... ????
How does that equate to a "release" ? Time.
robrokken ·
OK, I guess even though attack/release are lableled in ms, it isn't time...
exonerate ·
robrokken wrote: Ok, i'm racking my brain hardcore for 2 days trying tofigure out this code for a simple compressor.
It looks like what is happening is that lets say attack = .50, the output would be *input + .50 for attack. Now, that would just add volume wouldnt it? and otherwise if release, *input - release.
I don't get this at all, since attack and release are supposed to be TIME values, but to me, in my head, I dont see any time being changed, its just adding more volume or taking it away??????
I'm completely lost on this... Any idea how I can get my head around this, or where I am going wrong with this thinking? What am i MIssing?
There is no addition or subtraction going on in that line of code! What's happening is that gain is being scaled over time by either attack or release depending on if gain is more than seekgain.
Here's that line translated to SM code....
gain = (gain / attack ) & (gain > seekgain) + ( gain * release ) & (gain <= seekgain);
But that code is probably even harder for a newbie to understand though! 🙂
Maybe this will be easier if that line is rewritten like this?....
if (gain > seekgain)
{
gain = gain / attack;
}
else
{
gain = gain * release;
}
robrokken wrote: BTW: if anyone wants to port that to simple`c++ from JS so its easier to understand, that would be cool... I'm so frustrated that I don't understand this, it looks like very very simple dsp. Unfortunately for compression i cant find much if anything on how to understand the DSP involved.
Thank you,
~Rob.
The code would look exactly the same if it was ported to C++ ermm there'd be no porting involved. 😀
Sorry I don't have time just now to go into any detail but I hope I've helped you understand that line a bit!.
Cheers 😉
Exo
Disco_Steve ·
the reason you cant find anything on how to make compressors is because there isn't any hard and fast rules. (unlike filters)
also they are non linear, so the maths to understand their effect on a signal in general can't be analytically solved.
because of this people keep there ideas close to there chest.
if you want some guidance, the csound manual(book) in the last chapter on making your own opcode there is a 'how to make a compressor' section. I cant endorse the quality of the compressor from the book but it will help greatly in getting your head around compression DSP.
robrokken ·
Now is "gain" changing or does it get reset to one back through the loop. So, all that is happening is a gain value is being added or subtracted. and that gain value is based on the attack/release values, there isn't actually any time. Still not seeing how this is working.
If over threshold, ad the precalculated Attack + gain. there is nothing to change that for the next sample if its higher than the first sample but still over the threshold, it gets the same gain reduction..
So lost...
~Rob.
bootsy ·
Compression is really not that easy and for a jump start I would recommend to just dissect the SM compressor to see whats basically going on there. Seperate the compressors components, especially the transfer curve and the envelope follower. Also decide first if to work on linear or log scale audio.
On the next level try to imaginate how your compressor should treat the actual audio dynamics and then select appropriate concepts to implement that. I've given a broad overview about different approaches in my blog: http://varietyofsound.wordpress.com/200 ... rinciples/
TomC ·
bootsy wrote: Compression is really not that easy and for a jump start I would recommend to just dissect the SM compressor to see whats basically going on there. Seperate the compressors components, especially the transfer curve and the envelope follower. Also decide first if to work on linear or log scale audio.
On the next level try to imaginate how your compressor should treat the actual audio dynamics and then select appropriate concepts to implement that. I've given a broad overview about different approaches in my blog: http://varietyofsound.wordpress.com/200 ... rinciples/
Quoted for emphasis.
If you REALLY want to make your own compressor (and probably come up with something sounding good and unique) my advice is:
• read everything you can get your hands on about limiters and compressors. A good start is here.
• build a hard/brickwall limiter
• build a soft limiter, that means a limiter with a smooth way of limiting. It's up to you to decide how the smoothing should be implemented. Start easy!
• add an envelope for attack/release to the limiter.
Don't skip one of the steps, you need all of them to understand compression.
Now you hopefully understand how to reduce the level of a sound. Now you can start looking at the other half of compression, making low level sound louder. To make things easier to understand (and to implement) I'd create a second module just for the second part.
Do the same steps as above. You'll find that you can re-use a lot of the ideas you've got above, but of course in the opposite way.
Then, and only then, couple both together to the final compressor.
I know you'll be tempted to skip some of the steps above, but believe me, each one is important for your understanding.
There's nothing worse than someone implementing things without understanding what he actually does. IMO that's part of the reason for SynthMaker's bad reputation.
Tom
Edit: Forgot one important point: it's a VERY good idea to use a reference track in your VST-host application (preferably drums or percussion), render the processed track to a new audio track (or to disk and load it into a new track) and compare what your plug-in it has done to your transients.
infuzion ·
All good advice above! 😇
TomC wrote: Edit: Forgot one important point: it's a VERY good idea to use a reference track in your VST-host application (preferably drums or percussion), render the processed track to a new audio track (or to disk and load it into a new track) and compare what your plug-in it has done to your transients.
I just use the meters/Oscilloscopes/Wave Displays/etc with in SM, so you layer the before & after instantly. One of the great strengths of using SM over C++. 😉
robrokken ·
ok, I can't find one bit of limiter code, so i'm gonna try to make my own lol great 🙂
BTW: in that code i posted above, i think that "seekgain" is the desired gain:
When the signal is above the threshold, then the compressor kicks in so that the transfer curve is less steep above the knee (look here on bootsy's blog).
The slope above the knee depends on the compression ratio. If you're working with a logarithmic compression ratio of 2:1, then for every 1dB of input above the threshold, the output will be 1/2dB above the threshold. If you're working with a linear ratio then for every amplitude of say 0.1 above the threshold, then the output will be 0.05 above the threshold.
bootsy ·
robrokken wrote: ok, I can't find one bit of limiter code, so i'm gonna try to make my own lol great 🙂
Lightweight but decent limiter algo
Wrote something here? To have a post removed or your name hidden, write to [email protected].