// Log file // for the first day of the Gaffta Spatialization Workshop // Evaluate some simple expressions (press enter to evaluate the current line) 4 + 4 // watch the post-window for the replies from sclang // make some sound (make sure the Server is booted) { WhiteNoise.ar }.play; // This is a function {} // Functions can be used like in any other programming language // like for example with the following functions to square // the argument: f = { arg x; x*x }; f.value(2.0); // But functions are also used to describe audio networks // if you send the play message to a functions a "Synth" will\ // be created and started { WhiteNoise.ar(0.1) }.play // WhiteNoise is a UGen // All subclasses of UGen respond to the .ar and a .kr message // which stands for audio-rate and control rate // Demonstrate multichannel expansion { var sig; sig = SinOsc.ar(200, 0, 0.2); Out.ar(0, sig); } { var sig; sig = [SinOsc.ar(200, 0, 0.2), SinOsc.ar(400, 0, 0.4)]; Out.ar(0, sig); } { var sig; sig = SinOsc.ar([200,400], 0, [0.2,0.4]); Out.ar(0, sig); } // select only one channel from the array { var sig; sig = SinOsc.ar([200,400], 0, [0.2,0.4]); Out.ar(0, sig[0]); } SynthDef("ourSynth", { arg freqratio=1; var sig; sig = SinOsc.ar([200,400] * freqratio, 0, [0.2,0.4]); Out.ar(0); }).store; // start a synth using the SynthDef "ourSynth" Synth("ourSynth"); ~s1 = Synth("ourSynth", [\freqratio, 1.2]); ~s2 = Synth("ourSynth", [\freqratio, 1.8]); // stop the synth (instead of stopping everything with Cmd-. ~s1.free; ~s2.free;