hysysk:old

this blog will not be updated.

土曜日, 3月 11, 2006

switch_SC3

(
Task({
inf.do({ var x, z;
z = [0, 1, 2, 3, 4];
x = switch(z.choose)
{0} {Synth("line",
[\freq, 5000, \amp, 0.8.rand])}
{1} {Synth("points",
[\freq, rand(20, 2000), \amp, 0.8.rand])}
{2} {Synth("plane",
[\amp, rand(0.1, 0.8)])}
{3} {Synth("points2", [\freq1, 200.rand, \freq2, 200.rand,
\amp1, 0.5.rand, \amp2, 0.7.rand, \dur, 0.2.rand])}
{4} {Synth("line2", [\freq1, 120, \freq2, 60.rand,
\amp1, 0.9, \amp2, 0.7.rand, \dur, 0.2])};
0.2.wait;
x.postln;
})
}).play
)

(
(
SynthDef("points", {arg freq = 440, amp = 0.8;
var src, env;
src=Impulse.ar(freq, 0, amp);
env=EnvGen.ar(Env.new([0.8,0.8,0],[0.1,0.001]), doneAction:2);
Out.ar(0, Pan2.ar(src*env));
}).send(s)
);

(
SynthDef("points2", {
arg freq1 = 20, freq2 = 2000, pan1 = 1, pan2 = -1, amp1 = 0.8, amp2 = 1, dur = 0.2;
var src, env;
src=Impulse.ar(Line.kr(freq1, freq2, dur),0,Line.kr(amp1, amp2, dur));
env=EnvGen.ar(Env.new([0.8,0.8,0],[dur]), doneAction:2);
Out.ar(0, Pan2.ar(src*env,Line.kr(pan1, pan2, 0.2)));
}).send(s)
);

(
SynthDef("line", {arg freq = 440, amp = 0.8;
var src, env;
src=SinOsc.ar(freq, 0, amp);
env=EnvGen.ar(Env.new([0.8,0.8,0],[0.1,0.001]), doneAction:2);
Out.ar(0, Pan2.ar(src*env));
}).send(s)
);

(
SynthDef("line2", {arg freq1 = 440, freq2 = 880;
var src, env;
src=SinOsc.ar(Line.kr(freq1, freq2, 0.1));
env=EnvGen.ar(Env.new([0.8,0.8,0],[0.2,0.001]), doneAction:2);
Out.ar(0, Pan2.ar(src*env));
}).send(s)
);

(
SynthDef("plane", {arg amp = 0.8;
var src, env;
src=WhiteNoise.ar(amp);
env=EnvGen.ar(Env.new([0,0.9,0],[0.001,0.1]), doneAction:2);
Out.ar(0, Pan2.ar(src*env));
}).send(s)
);
)

1 Comments:

  • At 6:12 午後, Blogger hysysk said…

    Task部分をこう書き換えるとアルゴリズム作曲ぽくなりますね。目指せ脱・ランダム。
    (
    var count=0;

    Task({
    inf.do({ var x, z;
    z = [0, 1, 2, 3, 4];
    x = switch(z.at(count))
    {0} {Synth("line",
    [\freq, 5000, \amp, 0.8.rand])}
    {1} {Synth("points",
    [\freq, rand(20, 2000), \amp, 0.8.rand])}
    {2} {Synth("plane",
    [\amp, rand(0.1, 0.8)])}
    {3} {Synth("points2", [\freq1, 200.rand, \freq2, 200.rand,
    \amp1, 0.5.rand, \amp2, 0.7.rand, \dur, 0.2.rand])}
    {4} {Synth("line2", [\freq1, 120, \freq2, 60.rand,
    \amp1, 0.9, \amp2, 0.7.rand, \dur, 0.2])};
    0.2.wait;

    if(count > 4, {
    count = 0;
    },{count = count + 1;
    })
    })
    }).play
    )

     

コメントを投稿

<< Home