scide: LookupDialog - redo lookup on classes after partial lookup
[supercollider.git] / SCClassLibrary / Common / Audio / FSinOsc.sc
blobece05c9549a7685499b50e73946d7432ad11b2d9
1 /*
2         FSinOsc - fixed frequency sine oscillator
3         arguments :
4                 freq - frequency in cycles per second. Must be a scalar.
5                 mul - multiply by signal or scalar
6                 add - add to signal or scalar
8         This unit generator uses a very fast algorithm for generating a sine
9         wave at a fixed frequency.
12 FSinOsc : UGen {
13         *ar { arg freq=440.0, iphase = 0.0, mul = 1.0, add = 0.0;
14                 ^this.multiNew('audio', freq, iphase).madd(mul, add)
15         }
16         *kr { arg freq=440.0, iphase = 0.0, mul = 1.0, add = 0.0;
17                 ^this.multiNew('control', freq, iphase).madd(mul, add)
18         }
22 Klang : UGen {
23         *ar { arg specificationsArrayRef, freqscale = 1.0, freqoffset = 0.0;
24                 specificationsArrayRef = specificationsArrayRef.multichannelExpandRef(2);
25                         ^this.multiNewList(['audio', freqscale,
26                                                 freqoffset, specificationsArrayRef] )
27         }
28         *new1 { arg rate, freqscale, freqoffset, arrayRef;
29                 var specs, freqs, amps, phases;
30                 # freqs, amps, phases = arrayRef.dereference;
31                 specs = [freqs,
32                                 amps ?? {Array.fill(freqs.size,1.0)},
33                                 phases ?? {Array.fill(freqs.size,0.0)}
34                                 ].flop.flat;
36                 ^super.new.rate_(rate).addToSynth.init([freqscale,freqoffset] ++ specs);
37         }
38         init { arg theInputs;
39                 // store the inputs as an array
40                 inputs = theInputs;
41         }
42         argNamesInputsOffset { ^2 }
45 Klank : UGen {
46         *ar { arg specificationsArrayRef, input, freqscale = 1.0, freqoffset = 0.0, decayscale = 1.0;
47                         specificationsArrayRef = specificationsArrayRef.multichannelExpandRef(2);
48                         ^this.multiNewList(['audio',  input, freqscale,
49                                                 freqoffset, decayscale, specificationsArrayRef] )
50         }
51         *new1 { arg rate, input, freqscale, freqoffset, decayscale, arrayRef;
52                 var specs, freqs, amps, times;
53                 # freqs, amps, times = arrayRef.dereference;
54                 specs = [freqs,
55                                 amps ?? {Array.fill(freqs.size,1.0)},
56                                 times ?? {Array.fill(freqs.size,1.0)}
57                                 ].flop.flat;
59                 ^super.new.rate_(rate).addToSynth.init([input,freqscale,freqoffset,decayscale] ++ specs);
60         }
61         init { arg theInputs;
62                 // store the inputs as an array
63                 inputs = theInputs;
64         }
65         argNamesInputsOffset { ^2 }
68 DynKlank : UGen {
70         *ar { arg specificationsArrayRef, input, freqscale = 1.0, freqoffset = 0.0, decayscale = 1.0;
71                 ^this.multiNew(\audio, specificationsArrayRef, input, freqscale, freqoffset, decayscale)
72         }
74         *kr { arg specificationsArrayRef, input, freqscale = 1.0, freqoffset = 0.0, decayscale = 1.0;
75                 ^this.multiNew(\control, specificationsArrayRef, input, freqscale, freqoffset, decayscale)
76         }
78         *new1 { arg rate, specificationsArrayRef, input, freqscale = 1.0, freqoffset = 0.0, decayscale = 1.0;
79                 var spec = specificationsArrayRef.value;
80                 var selector = this.methodSelectorForRate(rate);
81                 ^Ringz.perform(selector,
82                                 input,
83                                 spec[0] ? #[440.0] * freqscale + freqoffset,
84                                 spec[2] ? #[1.0] * decayscale,
85                                 spec[1] ? #[1.0]
86                 ).sum
87         }
90 DynKlang : UGen {
92         *ar { arg specificationsArrayRef, freqscale = 1.0, freqoffset = 0.0;
93                 ^this.multiNew(\audio, specificationsArrayRef, freqscale, freqoffset);
94         }
96         *kr { arg specificationsArrayRef, freqscale = 1.0, freqoffset = 0.0;
97                 ^this.multiNew(\control, specificationsArrayRef, freqscale, freqoffset);
98         }
100         *new1 { arg rate, specificationsArrayRef, freqscale = 1.0, freqoffset = 0.0;
101                 var spec = specificationsArrayRef.value;
102                 var selector = this.methodSelectorForRate(rate);
103                 ^SinOsc.perform(selector,
104                                 spec[0] ? #[440.0] * freqscale + freqoffset,
105                                 spec[2] ? #[0.0],
106                                 spec[1] ? #[1.0]
107                 ).sum
108         }
112 Blip : UGen {
113         *ar { arg freq=440.0, numharm = 200.0, mul = 1.0, add = 0.0;
114                 ^this.multiNew('audio', freq, numharm).madd(mul, add)
115         }
116         *kr { arg freq=440.0, numharm = 200.0, mul = 1.0, add = 0.0;
117                 ^this.multiNew('control', freq, numharm).madd(mul, add)
118         }
121 Saw : UGen {
122         *ar { arg freq=440.0, mul = 1.0, add = 0.0;
123                 ^this.multiNew('audio', freq).madd(mul, add)
124         }
125         *kr { arg freq=440.0, mul = 1.0, add = 0.0;
126                 ^this.multiNew('control', freq).madd(mul, add)
127         }
130 Pulse : UGen {
131         *ar { arg freq=440.0, width = 0.5, mul = 1.0, add = 0.0;
132                 ^this.multiNew('audio', freq, width).madd(mul, add)
133         }
134         *kr { arg freq=440.0, width = 0.5, mul = 1.0, add = 0.0;
135                 ^this.multiNew('control', freq, width).madd(mul, add)
136         }