[PD] Help with compressor/limiter abstraction

Roman Haefeli reduzierer at yahoo.de
Sun Nov 2 22:54:17 CET 2008


On Wed, 2008-10-15 at 17:24 +0200, Frank Barknecht wrote:
> Hallo,
> Frank Barknecht hat gesagt: // Frank Barknecht wrote:
> 
> > I'm trying to build a pure-Pd compressor/limiter effect.
> 
> Attached is a slightly better version, which now uses a snapshot~ to
> get the current gain, which then is compared to the target gain to
> calculate the next gain. Now it seems to be possible to actually
> compress audio with it, if you set a low threshold (~ 0.2), a sharp
> attack (~1ms), and comp1 to some small value (or 1/comp1 to a large
> one) while keeping comp1 at 1.
> 
> Testing and comments would be cool!


yo... late comment, but still a comment :-)

i tried it on a bad quality voice recording (with some background noise,
which makes it easier for me to hear, how the compressor behaves). it
turned out, that i ended up using similar settings as you proposed in
the post above to get compressorlike results. and yes, at least for
voice it works pretty well, i'd say.

with c2 set to ~2 i could achieve a noise gate (or more correct:
downwards expander) with voice compressor at the same time. however, i
had the impression, that the release time doesn't seem to affect the
gate. when c2 is set to 1, i clearly hear the difference between 10 and
1000 ms release time. when i set c2 to > 1 and release time to a high
value, the abstraction still very quickly kicks in to suppress
background noise. is this because both, c1 and c2, share the same [pd
attack-release] section? 
i checked again by watching the $0-diff table and it seems, that attack
and release times are swapped for c2, compared to what you usually would
expect from a downward expander/gate. on a raising signal, the gain
should be corrected in 'attack' time, while on a muting signal, the gain
should follow in 'release' time. in your implementation it is the other
way around. i am not quite sure, how this could be fixed. probably c1
and c2 need a separate [pd attack-release] section?

i also encountered, that the c1 ratio is not a straight line, but rather
curve on a logarithmic (dB) scale (except when it is 1, of course),
while the c2 ratio is a straight line. i know some vst compressor
plugins - the C1 from waves in particular - that show similar behaviour.
i always wondered about the formula for those curves. it's cool to have
that now in pd  as well.

i added an input/output graph to compress~-help.pd, which helped me to
understand what the abstraction actually does. see attachment.

roman 
-------------- next part --------------
#N canvas 140 96 1089 805 10;
#N canvas 0 0 450 300 (subpatch) 0;
#X array \$0-orig 22050 float 2;
#X coords 0 1 22050 -1 200 140 1;
#X restore 751 34 graph;
#N canvas 0 0 450 300 (subpatch) 0;
#X array \$0-proc 22050 float 2;
#X coords 0 1 22050 -1 200 140 1;
#X restore 751 194 graph;
#X obj 563 160 tabwrite~ \$0-orig;
#X obj 567 436 tabwrite~ \$0-proc;
#X obj 563 105 metro 150;
#X obj 563 79 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 200 77 osc~ 200;
#X obj 264 99 / 100;
#X floatatom 264 77 5 0 0 0 - - -;
#X floatatom 307 298 5 0 0 0 comp1 - -;
#X msg 307 254 1 \$1;
#X obj 307 277 /;
#X floatatom 307 233 5 0 0 2 1/comp1 - -;
#X floatatom 244 233 5 0 0 2 thresh - -;
#X text 417 485 Modes;
#X text 417 550 expander:;
#X text 515 551 comp1 = 1 \, comp2 > 1;
#X text 415 578 limiter:;
#X text 522 580 comp1 very small \, comp2 = 1;
#X text 416 511 compressor:;
#X text 417 608 noise gate:;
#X text 523 609 comp1 = 1 \, comp2 very small;
#X floatatom 381 298 5 0 0 1 comp2 - -;
#X msg 381 254 1 \$1;
#X obj 381 277 /;
#X floatatom 381 233 5 0 0 2 1/comp2 - -;
#X floatatom 490 264 5 0 1000 2 att(ms) - -;
#X floatatom 550 264 5 0 1000 2 rel(ms) - -;
#X obj 205 401 compress~ 0.7 0.5 1 50 200;
#X text 120 20 compress~;
#X text 194 36 dynamics processor;
#N canvas 0 0 500 344 snd 0;
#X obj 113 153 readsf~;
#X obj 113 75 openpanel;
#X obj 113 101 symbol;
#X msg 113 127 open \$1 \, 1;
#X obj 180 154 spigot 1;
#X obj 233 125 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 113 51 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X msg 66 72 bang;
#X msg 141 51 symbol ~/loops;
#X obj 113 179 outlet~;
#X obj 89 24 inlet;
#X obj 244 182 outlet;
#X connect 0 0 9 0;
#X connect 0 1 4 0;
#X connect 1 0 2 0;
#X connect 2 0 3 0;
#X connect 3 0 0 0;
#X connect 4 0 2 0;
#X connect 4 0 11 0;
#X connect 5 0 4 1;
#X connect 6 0 1 0;
#X connect 7 0 2 0;
#X connect 8 0 1 0;
#X connect 10 0 1 0;
#X restore 112 143 pd snd;
#X obj 112 123 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X obj 137 190 / 100;
#X floatatom 137 168 5 0 0 0 - - -;
#X obj 112 219 *~ 1;
#X obj 206 453 *~ 1;
#X obj 251 463 / 100;
#X floatatom 251 441 5 0 0 1 make-up-gain - -;
#X text 522 510 comp1 < 1 \, comp2 = 1 (try comp2 > 1 for that pumping
sound);
#N canvas 0 0 450 300 (subpatch) 0;
#X array \$0-diff 22050 float 2;
#X coords 0 1 22050 0 200 140 1;
#X restore 752 362 graph;
#X obj 567 464 tabwrite~ \$0-diff;
#X obj 563 132 b;
#X msg 596 133 bang;
#N canvas 0 0 406 309 resize 0;
#X obj 65 129 s \$0-orig;
#X obj 62 162 s \$0-proc;
#X obj 62 190 s \$0-diff;
#X msg 74 99 resize \$1;
#X obj 74 70 inlet;
#X connect 3 0 0 0;
#X connect 3 0 1 0;
#X connect 3 0 2 0;
#X connect 4 0 3 0;
#X restore 619 266 pd resize;
#X msg 627 239 441;
#X msg 619 216 44100;
#X obj 547 166 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X msg 662 239 22050;
#X obj 265 150 delay 500;
#X floatatom 325 113 5 0 0 0 - - -;
#X obj 244 256 / 100;
#X obj 201 107 *~ 0;
#X obj 300 473 env~;
#X obj 300 498 - 100;
#X obj 301 526 vu 15 120 empty empty -1 -8 0 10 -66577 -1 1 0;
#X obj 49 469 env~;
#X obj 49 494 - 100;
#X obj 50 522 vu 15 120 empty empty -1 -8 0 10 -66577 -1 1 0;
#X obj 207 514 dac~;
#X floatatom 626 88 5 0 0 0 - - -;
#X obj 339 73 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#N canvas 0 0 450 300 (subpatch) 0;
#X array \$0.compcurve 100 float 0;
#X coords 0 100 99 0 200 200 1;
#X restore 756 557 graph;
#N canvas 31 200 554 461 compgui- 0;
#N canvas 312 148 648 448 compress 0;
#X obj 204 62 inlet;
#X obj 204 137 moses 0.5;
#X obj 285 69 inlet;
#X text 282 47 threshold;
#X obj 204 345 outlet;
#X obj 286 188 -;
#X text 323 192 power - thres;
#X text 320 221 * comp1;
#X obj 286 252 +;
#X text 325 254 + thres;
#X obj 401 74 inlet;
#X text 401 52 comp1;
#X obj 204 320 / 1;
#X text 234 321 / power;
#X obj 204 94 t a a;
#X obj 471 74 inlet;
#X text 471 52 comp2;
#X obj 471 124 /;
#X msg 471 102 1 \$1;
#X text 19 380 thresh * pow(power/thresh \, 1/comp2);
#X obj 204 265 *;
#X obj 285 95 t a a a a a;
#X obj 204 187 / 1;
#X obj 204 237 pow 1;
#X obj 286 219 * 1;
#X connect 0 0 14 0;
#X connect 1 0 22 0;
#X connect 1 1 5 0;
#X connect 2 0 21 0;
#X connect 5 0 24 0;
#X connect 8 0 12 0;
#X connect 10 0 24 1;
#X connect 12 0 4 0;
#X connect 14 0 1 0;
#X connect 14 1 12 1;
#X connect 15 0 18 0;
#X connect 17 0 23 1;
#X connect 18 0 17 0;
#X connect 20 0 12 0;
#X connect 21 0 1 1;
#X connect 21 1 22 1;
#X connect 21 2 20 1;
#X connect 21 3 5 1;
#X connect 21 4 8 1;
#X connect 22 0 23 0;
#X connect 23 0 20 0;
#X connect 24 0 8 0;
#X restore 86 135 pd compress;
#X obj 55 74 dbtorms;
#X obj 55 112 t a a;
#X obj 55 181 rmstodb;
#X obj 55 50 t a a;
#X obj 55 158 *;
#X obj 143 -12 dbtorms;
#X obj 199 229 - 50;
#X obj 55 213 - 50;
#X msg 55 -47 100;
#X obj 55 -5 until;
#X obj 55 21 i;
#X obj 98 22 + 1;
#X obj 55 -26 t a b;
#X msg 103 -3 50;
#X obj 157 -74 t b a;
#X obj 224 -75 t b a;
#X obj 271 -74 t b a;
#X obj 143 -36 + 100;
#X obj 55 236 clip 0 100;
#X obj 55 258 tabwrite \$0.compcurve;
#X obj 157 -130 inlet;
#X obj 224 -129 inlet;
#X obj 271 -129 inlet;
#X obj 169 -103 outlet;
#X obj 238 -99 outlet;
#X obj 291 -99 outlet;
#X connect 0 0 5 1;
#X connect 1 0 2 0;
#X connect 2 0 5 0;
#X connect 2 1 0 0;
#X connect 3 0 8 0;
#X connect 4 0 1 0;
#X connect 4 1 7 0;
#X connect 5 0 3 0;
#X connect 6 0 0 1;
#X connect 7 0 20 1;
#X connect 8 0 19 0;
#X connect 9 0 13 0;
#X connect 10 0 11 0;
#X connect 11 0 12 0;
#X connect 11 0 4 0;
#X connect 12 0 11 1;
#X connect 13 0 10 0;
#X connect 13 1 14 0;
#X connect 14 0 11 1;
#X connect 15 0 9 0;
#X connect 15 1 18 0;
#X connect 16 0 9 0;
#X connect 16 1 0 2;
#X connect 17 0 9 0;
#X connect 17 1 0 3;
#X connect 18 0 6 0;
#X connect 19 0 20 0;
#X connect 21 0 15 0;
#X connect 21 0 24 0;
#X connect 22 0 16 0;
#X connect 22 0 25 0;
#X connect 23 0 17 0;
#X connect 23 0 26 0;
#X restore 240 364 pd compgui-;
#X text 729 757 -50;
#X text 849 757 0;
#X text 949 758 50 dB input;
#X text 739 647 0;
#X text 736 557 50 dB output;
#X connect 4 0 42 0;
#X connect 5 0 4 0;
#X connect 6 0 52 0;
#X connect 7 0 52 1;
#X connect 8 0 7 0;
#X connect 9 0 63 1;
#X connect 10 0 11 0;
#X connect 11 0 9 0;
#X connect 12 0 10 0;
#X connect 13 0 51 0;
#X connect 22 0 63 2;
#X connect 23 0 24 0;
#X connect 24 0 22 0;
#X connect 25 0 23 0;
#X connect 26 0 28 4;
#X connect 27 0 28 5;
#X connect 28 0 36 0;
#X connect 28 1 41 0;
#X connect 31 0 35 0;
#X connect 31 1 49 0;
#X connect 32 0 31 0;
#X connect 33 0 35 1;
#X connect 34 0 33 0;
#X connect 35 0 28 0;
#X connect 35 0 2 0;
#X connect 35 0 56 0;
#X connect 36 0 3 0;
#X connect 36 0 53 0;
#X connect 36 0 59 0;
#X connect 36 0 59 1;
#X connect 37 0 36 1;
#X connect 38 0 37 0;
#X connect 42 0 2 0;
#X connect 42 0 3 0;
#X connect 42 0 41 0;
#X connect 42 0 47 0;
#X connect 43 0 42 0;
#X connect 45 0 44 0;
#X connect 46 0 44 0;
#X connect 48 0 44 0;
#X connect 49 0 42 0;
#X connect 50 0 49 1;
#X connect 51 0 63 0;
#X connect 52 0 2 0;
#X connect 52 0 28 0;
#X connect 53 0 54 0;
#X connect 54 0 55 0;
#X connect 56 0 57 0;
#X connect 57 0 58 0;
#X connect 60 0 4 1;
#X connect 61 0 52 1;
#X connect 63 0 28 1;
#X connect 63 1 28 2;
#X connect 63 2 28 3;


More information about the Pd-list mailing list