Browse Source

adding env and pan example

master
Luka Prinčič 10 months ago
parent
commit
4326243c0a
1 changed files with 58 additions and 0 deletions
  1. +58
    -0
      Env_and_Pan2.scd

+ 58
- 0
Env_and_Pan2.scd View File

@ -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
)

Loading…
Cancel
Save