1class:: DynKlang
2categories:: UGens>Generators>Deterministic
3summary:: Dynamic sine oscillator bank
4related:: Classes/Klang, Classes/DynKlank, Classes/Klank
5
6description::
7DynKlang is a bank of sine oscillators. It is less efficient than Klang, as it is basically a wrapper around SinOsc UGens in order to provide a similar interface to link::Classes/Klang::.
8
9Unlike Klang, parameters in code::specificationsArrayRef:: can be changed after it has been started.
10
11classmethods::
12private:: categories
13
14method:: ar, kr
15
16argument:: specificationsArrayRef
17a Ref to an Array of three Arrays:
18definitionlist::
19## frequencies || an Array of oscillator frequencies.
20## amplitudes || an Array of oscillator amplitudes, or nil. If nil, then amplitudes default to 1.0
21## phases || an Array of initial phases, or nil. If nil, then phases default to 0.0
22::
23argument:: freqscale
24a scale factor multiplied by all frequencies at initialization time.
25argument:: freqoffset
26an offset added to all frequencies at initialization time.
27
28examples::
29code::
30// frequency modulation
31(
32play {
33	DynKlang.ar(`[
34		[800, 1000, 1200] + SinOsc.kr([2, 3, 4.2], 0, [13, 24, 12]),
35		[0.3, 0.3, 0.3],
36		[pi,pi,pi]
37	]
38) * 0.1
39};
40)
41
42
43// building new synths every 2 seconds
44(
45fork {
46	loop {
47		play {
48			var mod = SinOsc.kr(Rand(0.1, 0.9), 0, Rand(5, 20));
49			Pan2.ar(DynKlang.ar(`[ Array.rand(12, 200.0, 2000.0), 1, mod ]), 1.0.rand)
50				* EnvGen.kr(Env.sine(4), 1, 0.02, doneAction: Done.freeSelf)
51		};
52		2.wait;
53	}
54}
55)
56
57
58// resetting the frequencies and amplitudes after the synth has been created
59(
60SynthDef('help-dynKlang', { |out,
61	freqs=#[220, 440, 880, 1760],
62	amps=#[0.35, 0.23, 0.12, 0.05],
63	phases=#[1, 1.5, 2, 2.5]|
64
65	Out.ar(out, DynKlang.ar(`[freqs, amps, phases]))
66}).add
67)
68
69a = Synth('help-dynKlang');
70
71a.setn(\freqs, Array.rand(4, 500, 2000));
72a.setn(\amps, Array.rand(4, 0.01, 0.25));
73::
74
75