From 4326243c0a1475234a5016176a2df045941a59ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Prin=C4=8Di=C4=8D?= Date: Wed, 16 Sep 2020 12:43:41 +0200 Subject: [PATCH] adding env and pan example --- Env_and_Pan2.scd | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Env_and_Pan2.scd diff --git a/Env_and_Pan2.scd b/Env_and_Pan2.scd new file mode 100644 index 0000000..87be2e7 --- /dev/null +++ b/Env_and_Pan2.scd @@ -0,0 +1,58 @@ +/* + +An example of: +- use of variables +- use of Pan2.ar to have stereo +- use of Env().kr() to create start and + end fades of sound stream + +*/ +( +{ + // define variables' names we will need + var fadein, duration, fadeout, pan; + + // assign values (or synths!) to variables + fadein = 4; // fade-in in seconds + duration = 50; // duration in seconds + fadeout = 5; // fade-out in, you guessed it, seconds! + + // panning left-right: from "-1" to "1". 0 is center. + // do you dare to put an UGen instead of floating point number? + pan = LFNoise1.kr(0.5).range(-1,1); + + // a mono signal "inside" the Pan2 UGen will become stereo with a pan + Pan2.ar( + in: + //...... your code .......... + // for example: + (Saw.ar(LFNoise0.kr(0.4).range(50,90)) + * LFPulse.kr(0.4, width: 0.2)) + + + (Saw.ar(LFNoise0.kr(0.5).range(100,200)) + * LFPulse.kr(0.5, width: 0.4)) + + + (Saw.ar(LFNoise0.kr(0.6).range(100,400)) + * LFPulse.kr(0.6, width: 0.1)) + + + (Saw.ar(LFNoise0.kr(0.7).range(40,150)) + * LFPulse.kr(0.7, width: 0.3)) + * 0.2 + // + // .... end of your code. + , // this comma separates arguments inside Pan2.ar: (in, pos, level) + // define position in the stereo + pos: pan, + + // define level. + // we use a simple basic envelope definition to create + // fade-in and fade-out + level: Env([0,1,1,0], [fadein, duration, fadeout]).kr(2); + + // check the shape with .plot: + // Env([0,1,1,0], [4,50,5]).plot + // just select above code and evaluate with ctrl+enter) + + ) +}.play +) \ No newline at end of file