From ea98b2ff27bbfb419b9544fca9e3b164b53782f7 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sun, 17 Sep 2017 20:51:05 -0400 Subject: [PATCH] Working through chapter 1 of Nick Collins' tutorial --- sclang-play/tut/ch01.sc | 121 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 sclang-play/tut/ch01.sc diff --git a/sclang-play/tut/ch01.sc b/sclang-play/tut/ch01.sc new file mode 100644 index 0000000..ba815a4 --- /dev/null +++ b/sclang-play/tut/ch01.sc @@ -0,0 +1,121 @@ +( + s.boot; +) + +( + 2 + 2 +) + +( + "I am SuperCollider 3".speak +) + +( + { + Pan2.ar(SinOsc.ar(440, 0, 0.1), 0.0) + }.play; +) + +( + { + Pan2.ar(SinOsc.ar(MouseX.kr(440, 880), 0, 0.1), 0.0) + }.play; +) + +( + { + var n = 11; + + Resonz.ar( + Mix.fill(n, { + var freq = rrand(50, 560.3); + var numcps = rrand(2, 20); + + Pan2.ar( + Gendy1.ar( + 6.rand, 6.rand, 1.0.rand, 1.0.rand, freq, freq, + 1.0.rand, 1.0.rand, numcps, + SinOsc.kr(exprand(0.02, 0.2), 0, numcps/2, numcps/2), + 0.5/(n.sqrt) + ), + 1.0.rand2 + ) + }), + MouseX.kr(100, 2000), + MouseY.kr(0.1, 1.0) + ); + }.play +) + +( + { + Pan2.ar( + SinOsc.ar(440, 0, 0.1), + 0.0 + ) + }.play +) + +( + { + SinOsc.ar(440, 0, 0.1) + Pulse.ar(443, 0.6, 0.05) + }.play; +) + +( + if(4 == 4, { + if(3 == 3, { + "correct!".postln + }); + }); +) + +( + 2.postln; + + Post << [2, 3, 4, 5] << nl; +) + +( + var freq; + freq = rrand(300, 600); + + { + SinOsc.ar(freq, 0, 0.1) + }.play; +) + +// :boom: +( + { SinOsc.ar(nil) }.play +) + +// :boom: +( + Array.series(9, 0, 1) + nil +) + +( + "ls -l".unixCmd +) + +( + var p, l, d = ""; + p = Pipe.new("ls -l", "r"); + l = p.getLine; + while( + { l.notNil }, + { + d = d ++ l ++ "\n"; + l = p.getLine; + } + ); + p.close; + + Post << d << nl; + d[0..20] +) + +( + Array.browse +)