File: Compander.schelp

package info (click to toggle)
supercollider 1%3A3.6.6~repack-2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 23,792 kB
  • ctags: 25,269
  • sloc: cpp: 177,129; lisp: 63,421; ansic: 11,297; python: 1,787; perl: 766; yacc: 311; sh: 286; lex: 181; ruby: 173; makefile: 168; xml: 13
file content (126 lines) | stat: -rw-r--r-- 3,424 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
class:: Compander
summary:: Compressor, expander, limiter, gate, ducker
categories:: UGens>Dynamics

description::
General purpose (hard-knee) dynamics processor.

classmethods::
method:: ar
argument::in
The signal to be compressed / expanded / gated.

argument::control
The signal whose amplitude determines the gain applied to the input signal. Often the same as in (for standard gating or compression) but should be different for ducking.

argument::thresh
Control signal amplitude threshold, which determines the break point between slopeBelow and slopeAbove. Usually 0..1. The control signal amplitude is calculated using RMS.

argument::slopeBelow
Slope of the amplitude curve below the threshold. If this slope > 1.0, the amplitude will drop off more quickly the softer the control signal gets; when the control signal is close to 0 amplitude, the output should be exactly zero -- hence, noise gating. Values < 1.0 are possible, but it means that a very low-level control signal will cause the input signal to be amplified, which would raise the noise floor.

argument::slopeAbove
Same thing, but above the threshold. Values < 1.0 achieve compression (louder signals are attenuated); > 1.0, you get expansion (louder signals are made even louder). For 3:1 compression, you would use a value of 1/3 here.

argument::clampTime
The amount of time it takes for the amplitude adjustment to kick in fully. This is usually pretty small, not much more than 10 milliseconds (the default value). I often set it as low as 2 milliseconds (0.002).

argument::relaxTime
The amount of time for the amplitude adjustment to be released. Usually a bit longer than clampTime; if both times are too short, you can get some (possibly unwanted) artifacts.

argument::mul

argument::add

discussion::
If any of this is confusing, see http://en.wikipedia.org/wiki/Audio_level_compression

examples::

code::
(
// example signal to process
play({
    var z;
    z = Decay2.ar(
        Impulse.ar(8, 0,LFSaw.kr(0.3, 0, -0.3, 0.3)),
        0.001, 0.3, Mix.ar(Pulse.ar([80,81], 0.3)))
})
)
::

code::
(
// noise gate
play({
    var z;
    z = Decay2.ar(
        Impulse.ar(8, 0,LFSaw.kr(0.3, 0, -0.3, 0.3)),
        0.001, 0.3, Mix.ar(Pulse.ar([80,81], 0.3)));
    Compander.ar(z, z,
        thresh: MouseX.kr(0.1, 1),
        slopeBelow: 10,
        slopeAbove: 1,
        clampTime: 0.01,
        relaxTime: 0.01
    );
})
)
::

code::
(
// compressor
play({
    var z;
    z = Decay2.ar(
        Impulse.ar(8, 0,LFSaw.kr(0.3, 0, -0.3, 0.3)),
        0.001, 0.3, Mix.ar(Pulse.ar([80,81], 0.3)));
    Compander.ar(z, z,
        thresh: MouseX.kr(0.1, 1),
        slopeBelow: 1,
        slopeAbove: 0.5,
        clampTime: 0.01,
        relaxTime: 0.01
    );
})
)
::

code::
(
// limiter
play({
    var z;
    z = Decay2.ar(
        Impulse.ar(8, 0,LFSaw.kr(0.3, 0, -0.3, 0.3)),
        0.001, 0.3, Mix.ar(Pulse.ar([80,81], 0.3)));
    Compander.ar(z, z,
        thresh: MouseX.kr(0.1, 1),
        slopeBelow: 1,
        slopeAbove: 0.1,
        clampTime: 0.01,
        relaxTime: 0.01
    );
})
)
::

code::
(
// sustainer
play({
    var z;
    z = Decay2.ar(
        Impulse.ar(8, 0,LFSaw.kr(0.3, 0, -0.3, 0.3)),
        0.001, 0.3, Mix.ar(Pulse.ar([80,81], 0.3)));
    Compander.ar(z, z,
        thresh: MouseX.kr(0.1, 1),
        slopeBelow: 0.1,
        slopeAbove: 1,
        clampTime: 0.01,
        relaxTime: 0.01
    )*0.1;
})
)
::