Created
April 23, 2013 01:53
-
-
Save mohayonao/5440216 to your computer and use it in GitHub Desktop.
SuperColliderをCoffeeScriptで書くとしたらこんな感じかな
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Hello world" | |
Server.default = s = Server.internal.boot() | |
############# | |
play((->SinOsc.ar(LFNoise0.kr(12, mul: 600, add: 100), 0.3))) | |
############# | |
play((->RLPF.ar(Dust.ar([12, 15]), LFNoise1.ar(1.div [3, 4], 1500, 1600), 0.02))) | |
############# Figure 1.1 Example of additive synthesis | |
play((-> | |
sines = 100; speed = 6 | |
Mix.fill(sines, | |
(x)-> | |
Pan2.ar( | |
SinOsc.ar(x+1*100, | |
mul: max(0, | |
LFNoise1.kr(speed).plus Line.kr(1, -1, 30) | |
) | |
), rand2(1.0)) ).div sines)) | |
############# | |
rand(100) | |
exprand(1.0, 100.0) | |
thisThread.randSeed = 666; (->rand(10.0)).dup 10 | |
dup("echo", 20) | |
round([3.141, 5.9265, 358.98], 0.01) | |
sort([23, 54, 678, 1, 21, 91, 34, 78]) | |
round(dup((->exprand(1, 10)), 100), 0.1) | |
sort(round(dup((->exprand(1, 10)), 100), 0.1)) | |
############# | |
exprand(1.0, 1000.0) | |
dup((->exprand(1.0, 1000.0)), 100) | |
sort(dup((->exprand(1.0, 1000.0)), 100)) | |
round(sort(dup((->exprand(1.0, 1000.0)), 100)), 0.01) | |
############# Figure 1.3 Fortuitous futuristic nested music. | |
( | |
play( | |
(-> | |
CombN.ar( | |
SinOsc.ar( | |
midicps( | |
LFNoise1.ar(3, 24, | |
LFSaw.ar([5, 5.123], 0, 3, 80) | |
) | |
), | |
0, 0,4), | |
1, 0.3, 2) | |
) | |
) | |
) | |
############# | |
[45, 13, 10, 498, 78].sort() # collection of items, do this; sort yourself | |
"echo".dup(20) # echo, do this; repeat yourself 20 times | |
50.midicps() # the number 50, do this; convert yourself into Hz | |
444.cpsmidi() # 444, do this; convert yourself into a midi number | |
100.rand() # 100, do this; pick a number between 0 and yourself | |
(->100.rand()).dup(50) # random picking function, do this; repeat 50 times | |
[1.001, 45.827, 187.18].round(0.1) # collection of items; round to 0.1 | |
# Mac users only, sorry | |
"I've just picked up a fault in the AE35 unit".speak() # Hal; plot to kill me | |
############# | |
1000.0 # a number | |
1000.0.rand() # choose a number between 0 and 1000 | |
1000.0.rand().round(0.01) # choose a number and round it | |
1000.0.rand().round(0.01).post() # choose, round, then post | |
(->1000.0.rand().round(0.01).postln()).dup(100).plot() # choose, round, dup, plot | |
(->1000.0.rand().round(0.01).postln()).dup(100).postln().sort().plot() # choose etc., sort, plot | |
# Mac only | |
1000.0.rand().round(0.01).postln().asString().speak() # convert to string and speak | |
(5 + 10) * 4 | |
[0, 11, 10, 1, 9, 8, 2, 3, 7, 4, 6, 5].reverse() # retrograde of a 12-tone row | |
12.substract([0, 11, 10, 1, 9, 8, 2, 3, 7, 4, 6, 5]).reverse() # retrograde inversion | |
[0, 2, 4, 5, 6, 7, 9, 11].scramble() # diatonic scale | |
[60, 62, 64, 67, 69].mirror() # pentatonic | |
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].rotate() | |
[60, 62, 64, 65, 67, 69, 71].midicps().round(0.1) # convert midi to frequency in Hz | |
[1, 0.75, 0.5, 0.25, 0.125].choose() # maybe durations? | |
0.125["*"] [1, 2, 3, 4, 5, 6, 7, 8].choose() # multiples of a smallest quantize value | |
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].permute(6) | |
############# | |
exprand(1, 1000.0) | |
(->exprand(1, 1000.0)) | |
dup(rand(1000.0), 5) # picks a number, duplicates it | |
dup((->rand(1000.0)), 5) # duplicates the function of picking a number | |
# essentially, this (which has a similar result) | |
[rand(1000.0), rand(1000.0), rand(1000.0), rand(1000.0), rand(1000.0)] | |
############# | |
(->LFNoise0.ar()).play() # play a series of random numbers | |
(->LFNoise0.ar(10000)).plot() # plot those numbers | |
(->LFNoise0.ar(10000)).scope() # play and show on a scope | |
(->100.rand()).dup(10) # pick 10 random numbers | |
(->100.rand()).dup 10 # same as above | |
(->100.rand()).dup(10).postln().plot() # pick 10 numbers, post, then plot them | |
(->100.rand()).dup(100).sort().plot() # pick 100 numbers, sort them, then plot | |
############# | |
(->Blip.ar(25, LFNoise0.kr(5, 12, 14), 0.3)).play() # single channel | |
(->Blip.ar(25, LFNoise0.kr([5, 10], 12, 14), 0.3)).play() # stereo | |
(->Blip.ar(25, LFNoise0.kr([5, 10, 2, 25], 12, 14), 0.3)).play() # quad | |
(->Blip.ar(25, LFNoise0.kr([5, 4, 7, 9, 5, 1, 9, 2], 12, 14), 0.3)).play() # 8 | |
############# | |
(->PMOsc.ar(440, 550, 7)).play() # pretty boring, like an FM radio | |
(->PMOsc.ar(440, MouseY.kr(1, 550), MouseX.kr(1, 15))).play() | |
(->PMOsc.ar(100, 500, 10, 0, 0.5)).play() # all arguments listed in order | |
(->PMOsc.ar(carfreq: 100, modfreq: 500, pmindex: 10, mul: 0.5)).play() # keywords | |
(->PMOsc.ar(carfreq: 100, mul: 0.5, pmindex: 10, modfreq: 500)).play() # mixed | |
(->SinOsc.ar(mul: MouseX.kr(0, 1.0))).scope() | |
############# Figure 1.4 VCO, VCF, VCA | |
( | |
(-> | |
Blip.ar( | |
TRand.kr( # frequency or VCO | |
100, 1000, # range | |
Impulse.kr(Line.kr(1, 20, 60))), # trigger | |
TRand.kr( # number of harmonics or VCF | |
1, 10, # range | |
Impulse.kr(Line.kr(1, 20, 60))), # trigger | |
Linen.kr( # mul, or amplitude, VCA | |
Impulse.kr(Line.kr(1, 20, 60)), # trigger | |
0, # attack | |
0.5, # sustain level | |
1.div Line.kr(1, 20, 60)) # trigger | |
) | |
).play() | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Hello world" | |
Server.default = s = Server.internal.boot; | |
///////////// | |
play({SinOsc.ar(LFNoise0.kr(12, mul: 600, add: 1000), 0.3)}) | |
///////////// | |
play({RLPF.ar(Dust.ar([12, 15]), LFNoise1.ar(1/[3, 4], 1500, 1600), 0.02)}) | |
///////////// Figure 1.1 Example of additive synthesis | |
play({ | |
var sines = 100, speed = 6; | |
Mix.fill(sines, | |
{arg x; | |
Pan2.ar( | |
SinOsc.ar(x+1*100, | |
mul: max(0, | |
LFNoise1.kr(speed) + | |
Line.kr(1, -1, 30) | |
) | |
), rand2(1.0))})/sines}) | |
///////////// | |
rand(100) | |
exprand(1.0, 100.0) | |
thisThread.randSeed = 666; {rand(10.0)} ! 10; | |
dup("echo", 20) | |
round([3.141, 5.9265, 358.98], 0.01) | |
sort([23, 54, 678, 1, 21, 91, 34, 78]) | |
round(dup({exprand(1, 10)}, 100), 0.1) | |
sort(round(dup({exprand(1, 10)}, 100), 0.1)) | |
///////////// | |
exprand(1.0, 1000.0) | |
dup({exprand(1.0, 1000.0)}, 100) | |
sort(dup({exprand(1.0, 1000.0)}, 100)) | |
round(sort(dup({exprand(1.0, 1000.0)}, 100)), 0.01) | |
///////////// Figure 1.3 Fortuitous futuristic nested music. | |
( | |
play( | |
{ | |
CombN.ar( | |
SinOsc.ar( | |
midicps( | |
LFNoise1.ar(3, 24, | |
LFSaw.ar([5, 5.123], 0, 3, 80) | |
) | |
), | |
0, 0.4), | |
1, 0.3, 2) | |
} | |
) | |
) | |
///////////// | |
[45, 13, 10, 498, 78].sort // collection of items, do this; sort yourself | |
"echo".dup(20) // echo, do this; repeat yourself 20 times | |
50.midicps // the number 50, do this; convert yourself into Hz | |
444.cpsmidi // 444, do this; convert yourself into a midi number | |
100.rand // 100, do this; pick a number between 0 and yourself | |
{100.rand}.dup(50) // random picking function, do this; repeat 50 times | |
[1.001, 45.827, 187.18].round(0.1) // collection of items; round to 0.1 | |
// Mac users only, sorry | |
"I've just picked up a fault in the AE35 unit".speak // Hal; plot to kill me | |
///////////// | |
1000.0 // a number | |
1000.0.rand // choose a number between 0 and 1000 | |
1000.0.rand.round(0.01) // choose a number and round it | |
1000.0.rand.round(0.01).post // choose, round, then post | |
{1000.0.rand.round(0.01).postln}.dup(100).plot // choose, round, dup, plot | |
{1000.0.rand.round(0.01).postln}.dup(100).postln.sort.plot // choose etc., sort, plot | |
//Mac only | |
1000.0.rand.round(0.01).postln.asString.speak // convert to string and speak | |
5 + 10 * 4 | |
[0, 11, 10, 1, 9, 8, 2, 3, 7, 4, 6, 5].reverse // retrograde of a 12-tone row | |
12 - [0, 11, 10, 1, 9, 8, 2, 3, 7, 4, 6, 5].reverse // retrograde inversion | |
[0, 2, 4, 5, 6, 7, 9, 11].scramble // diatonic scale | |
[60, 62, 64, 67, 69].mirror // pentatonic | |
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].rotate | |
[60, 62, 64, 65, 67, 69, 71].midicps.round(0.1) // convert midi to frequency in Hz | |
[1, 0.75, 0.5, 0.25, 0.125].choose // maybe durations? | |
0.125 * [1, 2, 3, 4, 5, 6, 7, 8].choose // multiples of a smallest quantize value | |
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].permute(6) | |
///////////// | |
exprand(1, 1000.0) | |
{exprand(1, 1000.0)} | |
dup(rand(1000.0), 5) // picks a number, duplicates it | |
dup({rand(1000.0)}, 5) //duplicates the function of picking a number | |
// essentially, this (which has a similar result) | |
[rand(1000.0), rand(1000.0), rand(1000.0), rand(1000.0), rand(1000.0)] | |
///////////// | |
{LFNoise0.ar}.play //play a series of random numbers | |
{LFNoise0.ar(10000)}.plot // plot those numbers | |
{LFNoise0.ar(10000)}.scope // play and show on a scope | |
{100.rand}.dup(10) // pick 10 random numbers | |
{100.rand} ! 10 // same as above | |
{100.rand}.dup(10).postln.plot // pick 10 numbers, post, then plot them | |
{100.rand}.dup(100).sort.plot // pick 100 numbers, sort them, then plot | |
///////////// | |
{Blip.ar(25, LFNoise0.kr(5, 12, 14), 0.3)}.play // single channel | |
{Blip.ar(25, LFNoise0.kr([5, 10], 12, 14), 0.3)}.play // stereo | |
{Blip.ar(25, LFNoise0.kr([5, 10, 2, 25], 12, 14), 0.3)}.play // quad | |
{Blip.ar(25, LFNoise0.kr([5, 4, 7, 9, 5, 1, 9, 2], 12, 14), 0.3)}.play // 8 | |
///////////// | |
{PMOsc.ar(440, 550, 7)}.play // pretty boring, like an FM radio | |
{PMOsc.ar(440, MouseY.kr(1, 550), MouseX.kr(1, 15))}.play | |
{PMOsc.ar(100, 500, 10, 0, 0.5)}.play // all arguments listed in order | |
{PMOsc.ar(carfreq: 100, modfreq: 500, pmindex: 10, mul: 0.5)}.play // keywords | |
{PMOsc.ar(carfreq: 100, mul: 0.5, pmindex: 10, modfreq: 500)}.play // mixed | |
{SinOsc.ar(mul: MouseX.kr(0, 1.0))}.scope | |
///////////// Figure 1.4 VCO, VCF, VCA | |
( | |
{ | |
Blip.ar( | |
TRand.kr( // frequency or VCO | |
100, 1000, // range | |
Impulse.kr(Line.kr(1, 20, 60))), // trigger | |
TRand.kr( // number of harmonics or VCF | |
1, 10, // range | |
Impulse.kr(Line.kr(1, 20, 60))), // trigger | |
Linen.kr( // mul, or amplitude, VCA | |
Impulse.kr(Line.kr(1, 20, 60)), // trigger | |
0, // attack | |
0.5, // sustain level | |
1/Line.kr(1, 20, 60)) // trigger | |
) | |
}.play | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment