[sharing unfinished thing] a compressor in gen~

vichug's icon

I'm trying to replicate a guitar heavy amplifier kind of sound in max. i may have gotten lost along the way and thought i need a compressor for that. so here is an attempt at making a compressor with gen~. I'm not sure what i'm doing.

There is a buffer of 50 samples that is rewritten each sample and averaged, so it's a circular running buffer, to get the average sound level. Then this level is compared to a threshold and the sound that will be louder than this threshold will be attenuated, according to a ceiling : a maximum ceiling level must be set in dB wherein it will be the new maximum amplitude of the compressed sound. Then there is an automatic makeup gain which will add as much as the ceil level to the sound, so that the new maximum is like the previous maximum.

Max Patch
Copy patch and select New From Clipboard in Max.

I am not sure i got the maths right. It seems to work, but, well, sometimes it doesn't seem right, so i don't know, can someone advise ? !

vichug's icon

hm, *please* help ?

ak's icon

@raja: RMS is the other way around. It's the square root of the mean of squares (see wikipedia).

vichug's icon

hey, thanks,
1) probably the design is confusing ; this compressor's aim is to boost instead of reducing the final level ; by reducing difference between peak levels and lower levels ; that's why in each case i add the original input * ceil level (because logically, nothing should exceed ceil level) to get back to a level as close as 1 as possible. I'm not really sure how to visualize efficiently... tho indeed if i seek other people's advice i should care more about making things clear :)
2) it seems better indeed !! and tried the square root of the mean of squares as AK suggested...

Max Patch
Copy patch and select New From Clipboard in Max.

i think there are several things i didn't get right. Plus i mistook the wet and dry level...

jvkr's icon
Max Patch
Copy patch and select New From Clipboard in Max.

The running average or rms can also be implemented without a buffer, which makes it cheaper especially with larger buffer sizes.

vichug's icon

thanks a lot, that gets better every time!