diff --git a/sclang-play/tut/ch03.sc b/sclang-play/tut/ch03.sc index b98a688..9474bcb 100644 --- a/sclang-play/tut/ch03.sc +++ b/sclang-play/tut/ch03.sc @@ -202,3 +202,99 @@ ( a.set(\gate, 0); ) + +( + SynthDef(\sine, + { + Out.ar( + 0, SinOsc.ar( + Rand(440, 880), 0, 0.1 + ) + ) + } + ).add; +) + +( + Synth(\sine); +) + +( + a = Synth(\sine); + a.writeDefFile("synth.out"); +) + +( + SynthDef(\sine, { + arg freq=440, amp=0.1; + Out.ar( + 0, + SinOsc.ar(freq, 0, amp) + ) + }).add; +) + +( + Synth("sine"); + Synth("sine", [\freq, 880]) +) + +( + a = Synth(\sine); + b = Synth(\sine, [\freq, 550]); + c = Synth(\sine, [\freq, 660, \amp, 0.5]); +) + +( + c.set(\freq, 1000); + b.set(\amp, 0.3, \freq, 100); +) + +( + a.free; + b.free; + c.free; +) + +( + SynthDef(\hum, { + arg freq=440; + var finaloutput = Mix( + [ + SinOsc.ar(freq, 0, 0.3), + SinOsc.ar(freq*2, 0, 0.2), + SinOsc.ar(freq*3, 0, 0.1), + SinOsc.ar(freq*3.33, 0, 0.01), + SinOsc.ar(freq*4, 0, 0.1), + SinOsc.ar(freq*4.5, 0, 0.01), + SinOsc.ar(freq*4.75, 0, 0.02) + ] + ); + Out.ar(0, finaloutput); + }).add; +) + +( + Synth(\hum, [\freq, 220]); +) + +( + Synth(\hum, [\freq, 880]); +) + +( + Synth(\hum, [\freq, 440]); +) + +( + SynthDescLib.global.synthDescs[\sine].def.func.postcs +) + +( + SynthDescLib.global.synthDescs.do { |desc| + if(desc.def.notNil) { + "\nSynthDef %\n".postf(desc.name.asCompileString); + desc.def.func.postcs; + }; + } +)