/usr/share/SuperCollider/HelpSource/Classes/LFGauss.schelp is in supercollider-common 1:3.8.0~repack-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | class:: LFGauss
summary:: Gaussian function oscillator
categories:: UGens>Generators>Deterministic
description::
A non-band-limited gaussian function oscillator. Output ranges from strong::minval:: to 1.
LFGauss implements the formula:
code::
f(x) = exp(squared(x - iphase) / (-2.0 * squared(width)))
::
where x is to vary in the range -1 to 1 over the period dur. strong::minval:: is the initial value at -1.
classmethods::
method:: ar, kr
argument:: duration
duration of one full cycle ( for strong::freq:: input: strong::dur = 1 / freq:: )
argument:: width
relative width of the bell. Best to keep below 0.25 when used as envelope. (default: 0.1)
argument:: iphase
initial offset (default: 0)
argument:: loop
if loop is > 0, UGen oscillates. Otherwise it calls doneAction after one cycle (default: 1)
argument:: doneAction
doneAction, which is evaluated after cycle completes (2 frees the synth, default: 0).
See link::Reference/UGen-doneActions:: for more detail.
instancemethods::
method::minval
Returns the lowest value for the given parameters, which is code::exp(1.0 / (-2.0 * squared(width)))::
method::range
Scales the output to the given range. This can be convenient when using LFGauss as an envelope (see example below).
code::
{ LFGauss.ar(0.01, 0.6).range }.plot;
{ LFGauss.ar(0.01, 0.6) }.plot; // starts at about 0.25
::
examples::
subsection:: Some plots
code::
s.boot ;
// a 0.1 second grain
{ LFGauss.ar(0.1, 0.12) }.plot(0.1);
// shifting left
{ LFGauss.ar(0.1, 0.12, -1, loop: 0) }.plot(0.1);
// moving further away from the center
{ LFGauss.ar(0.1, 0.12, 2) }.plot(0.2);
// several grains
{ LFGauss.ar(0.065, 0.12, 0, loop: 1) }.plot(0.3);
::
subsection:: Some calculations
assuming iphase = 0:
strong::minval:: for a given width:
code::minval = exp(-1.0 / (2.0 * squared(width)))::
strong::width:: for a given minval:
code::width = sqrt(-1.0 / log(minval))::
strong::width at half maximum (0.5):::
code::(2 * sqrt(2 * log(2)) * width) = ca. 2.355 * width::
code::
// minval for a width of 0.1:
(exp(1 / (-2.0 * squared(0.1)))) // 2e-22
// maximum width for a beginning at -60dB:
// we want the beginning small enough to avoid clicks
sqrt(-1 / ( 2 * log(-60.dbamp))) // 0.269
// minval for width of 0.25
(exp(1 / (-2.0 * squared(0.25)))).ampdb // -70dB
// maximum is always 1:
{ LFGauss.ar(0.1, XLine.kr(1, 0.03, 1), 0, loop: 1) }.plot(1);
// a gauss curve in sclang:
(0..1000).normalize(-1, 1).collect(_.gaussCurve(1, 0, 0.1)).plot;
// rescale the function to the range 0..1
(
{
var width = XLine.kr(0.04, 1.0, 1);
var min = (exp(1.0 / (-2.0 * squared(width))));
var gauss = LFGauss.ar(0.1, width, loop: 1);
gauss.linlin(min, 1, 0, 1);
}.plot(1)
);
// range does the same implicitly
(
{
var width = XLine.kr(0.04, 1.0, 1);
LFGauss.ar(0.1, width, loop: 1).range(0, 1);
}.plot(1)
);
::
subsection:: Sound examples
code::
// modulating duration
{ LFGauss.ar(XLine.kr(0.1, 0.001, 10), 0.03) * 0.2 }.play;
// modulating width, freq 60 Hz
{ LFGauss.ar(1/60, XLine.kr(0.1, 0.001, 10)) * 0.2 }.play;
// modulating both: x position is frequency, y is width factor.
// note the artefacts due to aliasing at high frequencies
{ LFGauss.ar(MouseX.kr(1/8000, 0.1, 1), MouseY.kr(0.001, 0.1, 1)) * 0.1 }.play;
// LFGauss as amplitude modulator
{ LFGauss.ar(MouseX.kr(1, 0.001, 1), 0.1) * SinOsc.ar(1000) * 0.1 }.play;
// modulate iphase
{ LFGauss.ar(0.001, 0.2, [0, MouseX.kr(-1, 1)]).sum * 0.2 }.scope;
// for very small width we are "approaching" a dirac function
{ LFGauss.ar(0.01, SampleDur.ir * MouseX.kr(10, 3000, 1)) * 0.2 }.play;
// dur and width can be modulated at audio rate
(
{ var dur = SinOsc.ar(MouseX.kr(2, 1000, 1) * [1, 1.1]).range(0.0006, 0.01);
var width = SinOsc.ar(0.5 * [1, 1.1]).range(0.01, 0.3);
LFGauss.ar(dur, width) * 0.2
}.play
);
// several frequencies and widths combined
(
{
var mod = LFGauss.ar(MouseX.kr(1, 0.07, 1), 1 * (MouseY.kr(1, 3) ** (-1..-6)));
var carr = SinOsc.ar(200 * (1.3 ** (0..5)));
(carr * mod).sum * 0.1
}.play;
)
// test spectrum
(
{
var son = LeakDC.ar(LFGauss.ar(0.005, 0.2));
BPF.ar(son * 3, MouseX.kr(60, 2000, 1), 0.05)
}.play;
)
::
subsection:: Gabor Grain
note::
The gaussian function doesn't start with 0 – it asymptotically approaches it at code::-inf:: and code::inf::. When using it as an envelope, it has to start at some smaller value, and it has an offset for this value. You can remove this offset by explicitly setting the strong::range::, e.g. to code::0..1:: (this is the default).
::
code::
(
var freq = 1000;
var ncycles = 10;
var width = 0.25;
var dur = ncycles / freq;
{
var env = LFGauss.ar(dur, width, loop: 0, doneAction: 2).range;
var son = FSinOsc.ar(freq, 0.5pi, env);
son
}.plot(dur);
)
(
SynthDef(\gabor, { |out, i_freq = 440, i_sustain = 1, i_pan = 1, i_amp = 0.1, i_width = 0.25 |
var env = LFGauss.ar(i_sustain, i_width, loop: 0, doneAction: 2).range;
var son = FSinOsc.ar(i_freq, 0.5pi, env);
OffsetOut.ar(out, Pan2.ar(son, i_pan, i_amp));
}).add;
)
// modulating various parameters
(
Pdef(\x,
Pbind(
\instrument, \gabor,
\freq, Pbrown(step:0.01).linexp(0, 1, 100, 14000),
\dur, Pbrown().linexp(0, 1, 0.004, 0.02),
\legato, Pbrown(1, 3, 0.1, inf),
\pan, Pwhite() * Pbrown()
)
).play
)
// modulating width only
(
Pdef(\x,
Pbind(
\instrument, \gabor,
\freq, 1000,
\dur, 0.01,
\width, Pseg(Pseq([0.25, 0.002], inf), 10, \exp),
\legato, 2
)
).play
)
// compare with sine grain.
(
SynthDef(\gabor, { |out, i_freq = 440, i_sustain = 1, i_pan = 1, i_amp = 0.1, i_width=0.25 |
var env = EnvGen.ar(Env.sine(i_sustain * i_width), doneAction: 2);
var son = FSinOsc.ar(i_freq, 0.5pi, env);
OffsetOut.ar(out, Pan2.ar(son, i_pan, i_amp));
}).add;
)
::
|