hysysk:old

this blog will not be updated.

火曜日, 3月 14, 2006

if_SC3

sc3でif文。%を使うとそれっぽいです何となく。
アルゴリズムで作曲することの面白さは、即興でも暗譜でもない
演奏が可能だということです。
このプログラムも、マッピング次第では人力で演奏できそうです。
(
SynthDef("sin", {arg freq = 440, amp = 0.8, pan = 0;
var src, env;
src=SinOsc.ar(freq, 0, amp);
env=EnvGen.ar(Env.new([0,0.8,0],[0.001,0.09]), doneAction:2);
Out.ar(0, Pan2.ar(src*env, pan));
}).send(s)
)

(
t = Task({
128.do({ arg i;
var freq=74, amp=0.5, pan=0;
if(i % 5 < 2, {
freq = freq + 4;
pan = 1;
},{amp = amp - 0.1;
});
if(i % 32 >= 12, {
freq = freq + 5;
pan = -1;
},{amp = amp + 0.2;
});
if(i % 64 >= 32, {
freq = freq + 2;
pan = 0;
},{amp = amp - 0.2;
});
Synth("sin", [\freq, freq.midicps, \amp, amp, \pan, pan]);
z = [0.1, 0.2, 0.25, 0.05, 0.5];
z.at(i%5).wait
});
});
)
t.start;
t.stop;

土曜日, 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)
);
)