From f9a9fb0ccb92eb1f8eac3edc64984b9481e5f668 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Tue, 10 Oct 2017 09:33:54 -0400 Subject: [PATCH] Up through ch 3.1 --- sclang-play/tut/ch03.sc | 204 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 sclang-play/tut/ch03.sc diff --git a/sclang-play/tut/ch03.sc b/sclang-play/tut/ch03.sc new file mode 100644 index 0000000..b98a688 --- /dev/null +++ b/sclang-play/tut/ch03.sc @@ -0,0 +1,204 @@ +( + s.boot; +) + +( + FreqScope.new; +) + +( + {SinOsc.ar(440, 0, 0.1)}.scope +) + +( + {SinOsc.ar(440, 0, Line.kr(0.1, 0.0, 1.0))}.scope +) + +( + {SinOsc.ar(440, 0, Line.kr(0.1, 0, 1, doneAction: 2))}.scope +) + +( + Env([1, 0, 1], [1, 1]).plot +) + +( + Env([0, 1, 0], [1.0, 0.5]).plot +) + +( + Env.linen(0.03, 0.5, 0.1).plot +) + +( + Env.adsr(0.01, 0.5, 0.5, 0.1, 1.0, 0).plot +) + +( + Env.perc(0.05, 0.5, 1.0, 0).plot +) + +( + Env([1, 0], [1.0]).plot +) + +( + {EnvGen.ar(Env([1, 0], [1.0]))}.scope +) + +( + {SinOsc.ar(440, 0, 0.1) * EnvGen.kr(Env([1, 0], [1.0]))}.scope +) + +( + Env([1000, 20], [1.0]).plot +) + +( + {Saw.ar(EnvGen.ar(Env([1000, 20], [1.0])), 0.1)}.scope +) + +( + { + Saw.ar( + EnvGen.ar(Env([1000, 20], [0.5])), + EnvGen.ar(Env([0.1, 0], [2.0])) + ) + }.scope +) + +( + { + Saw.ar( + EnvGen.kr(Env([1000, 20], [0.5])), + EnvGen.kr(Env([0.1, 0], [2.0])) + ) + }.play +) + +( + { + SinOsc.ar( + SinOsc.ar(10, 0, 10, 440), + 0.0, + EnvGen.kr(Env([0.5, 0.0], [1.0]), doneAction: 2) + ) + }.scope +) + +( + { + Saw.ar( + EnvGen.kr(Env([500, 100], [1.0]), doneAction: 2), + 0.1 + ) + }.scope +) + +( + { + Saw.ar( + SinOsc.ar(1, 0, 10, 440), + Line.kr(0, 1, 1, doneAction: 2) + ) + }.scope +) + +( + { + Saw.ar( + SinOsc.ar(1, 0, 10, 440), + XLine.kr(0.0001, 1, 1, doneAction: 2) + ) + }.scope +) + +( + { + EnvGen.ar( + Env([0, 0.1, 0], [0.1, 0.9]), doneAction: 2 + ) * SinOsc.ar(330) + }.scope +) + +( + a = { + EnvGen.ar( + Env.asr(0.1, 0.1, 1.0), doneAction: 2 + ) * SinOsc.ar(330) + }.play +) + +( + a.release(2.0); +) + +( + a = { + arg gate=1; + + EnvGen.ar( + Env.asr(0.1, 0.1, 0.9), gate, doneAction: 2 + ) * SinOsc.ar(330) + }.play +) + +( + a.set(\gate, 0) +) + +( + e = Env([0.2, 1.0, 0.0], [0.1, 3.0], 0, 1); + + a = { + arg gate=1; + + EnvGen.ar( + e, gate, doneAction: 2 + ) * SinOsc.ar(550, 0, 0.1) + }.play +) + +( + a.set(\gate, 0); +) + +( + e = Env([0.0, 0.0, 1.0, 0.0], [0.5, 1.0, 2.0], 0, 2, 0); + + a = { + arg gate=1; + + EnvGen.ar( + e, gate, doneAction: 2 + ) * SinOsc.ar(550, 0, 0.1) + }.play +) + +( + a.set(\gate, 0); +) + +( + e = Env( + [0.0, 1.0, -1.0, 0.0], + [0.01, 0.01, 2.0], + 0, + 2, // releaseNode + 0 // loopNode + ); + + e.plot; + + a = { + arg gate=1; + + EnvGen.ar( + e, gate, timeScale: MouseX.kr(0.1, 2.0), doneAction: 2 + ) + }.play +) + +( + a.set(\gate, 0); +)