//------------------------------------------------------ looking at variables and values f = { 1 + 1 + 1}; f.value; f = { arg a, b; a + b}; f.value( 2,9); x = [1,2,3]; x.postln; //------------------------------------------------------ // making sound // play a sine wave {SinOsc.ar(100, 0,0.8) }.play {SinOsc.ar( (300 + 200 * SinOsc.kr(0.2, 0, 1)) , 0,0.8) }.play {SinOsc.ar(SinOsc.kr(SinOsc.kr(0.2, 0, 3), 0, 400),0,0.1) }.play for stereo: {SinOsc.ar(100, 0,0.8).dup }.play // dup = duplicate the channel phase cancellation: { SinOsc.ar(100, 0,0.2) + SinOsc.ar(100, pi,0.2) }.play // one osc is PI phased from another = silence (how noise cancelling headphones work) adjusting the phase: { SinOsc.ar(400, SinOsc.ar(0.3, 0,10) ,0.2) }.scope x = { arg freq=440; SinOsc.ar([freq, freq+5], 0, 0.2) }.play; x.set("freq", 880); x.set("freq", 80); x.free; //------------------------------------------------------ // mouse control {SinOsc.ar( MouseX.kr(200,440), 0,0.2) }.play {SinOsc.ar( MouseX.kr(200,440), 0, MouseY.kr(0,1) ) }.play { RHPF.ar(Saw.ar(100), MouseX.kr(1e2,2e4,1), 0.2, 0.2) }.scope(1); //------------------------------------------------------ // synth definition f = { SinOsc.ar(440 + 200.rand, 0, 0.2) }; x = f.play; y = f.play; z = f.play; x.free; y.free; z.free; ( SynthDef("mySineWave", { arg freq = 440, out = 0; Out.ar(out, SinOsc.ar(freq, 0, 0.2)); }).send(s); ) x = Synth("mySineWave"); y = Synth("mySineWave", ["freq", 660]); z = Synth("mySineWave", ["freq", 880, "out", 1]); x.free; y.free; z.free; //------------------------------------------------- synth with envelope: ( SynthDef("mySineWave", { arg freq = 440, out = 0; var env, x; env = EnvGen.kr(Env.perc(0.01,2,1,-4), doneAction: 2); x = env * SinOsc.ar(freq, 0, 0.2); Out.ar(out,x); }).send(s); ) x = Synth("mySineWave"); y = Synth("mySineWave", ["freq", 660]); z = Synth("mySineWave", ["freq", 880, "out", 1]); //---------------------------------------- // this is for a synth w/ envelope (fades out and gets deleted internally), please use the "superCollider_newSynths" example s = Server("myServer", NetAddr("127.0.0.1", 12000)); s.boot; s.dumpOSC(1); ( SynthDef("env-sine", { arg freq = 880, amp=0.125, detune=0; var env, x; env = EnvGen.kr(Env.perc(0.01,2,1,-4), doneAction: 2); x = env * SinOsc.ar([freq, freq+detune],0, amp); Out.ar(0, x) }).send(s)); // controllable //----------------------------------------------- // this is an un-ending synth, please use the "superCollider_controllable" example s = Server("myServer", NetAddr("127.0.0.1", 12000)); s.boot; //s.dumpOSC(1); ( SynthDef("sinewave", { arg freq = 880, amp=0.125, detune=0; x = SinOsc.ar([freq,freq+detune],0, amp); Out.ar(0, x) }).send(s));