391 lines
5.7 KiB
Python
391 lines
5.7 KiB
Python
(
|
|
s.boot;
|
|
)
|
|
|
|
(
|
|
s.reboot;
|
|
)
|
|
|
|
(
|
|
s.quit;
|
|
)
|
|
|
|
(
|
|
s.scope;
|
|
)
|
|
|
|
(
|
|
{
|
|
var pitchOsc;
|
|
var ampOsc;
|
|
pitchOsc = { 300 + SinOsc.kr(0.1, 1.5pi, 20, 20); };
|
|
ampOsc = SinOsc.kr(0.5, 1.5pi, 1.0, 1.0);
|
|
SinOsc.ar([pitchOsc, pitchOsc], 0, ampOsc);
|
|
}.play;
|
|
)
|
|
|
|
(
|
|
{ [SinOsc.ar(440, 0, 0.2), SinOsc.ar(442, 0, 0.2)] }.play;
|
|
)
|
|
|
|
(
|
|
{
|
|
var freq;
|
|
freq = [[600, 880], [400, 660], 1320, 880].choose;
|
|
SinOsc.ar(freq, 0, 0.2);
|
|
}.play;
|
|
)
|
|
|
|
(
|
|
{
|
|
Pan2.ar(PinkNoise.ar(0.2), SinOsc.kr(0.5));
|
|
}.play;
|
|
)
|
|
|
|
(
|
|
{
|
|
Pan2.ar(SinOsc.ar(440, 0, 0.2), SinOsc.kr(0.5));
|
|
}.play;
|
|
)
|
|
|
|
(
|
|
{
|
|
Pan2.ar(PinkNoise.ar(0.2), -0.3);
|
|
}.play;
|
|
)
|
|
|
|
(
|
|
{
|
|
PinkNoise.ar(0.2) + SinOsc.ar([440, 442], 0, 0.2) + Saw.ar([660, 662], 0.2);
|
|
}.play;
|
|
)
|
|
|
|
(
|
|
{
|
|
var a, b;
|
|
a = [
|
|
SinOsc.ar(440, 0, 0.2),
|
|
Saw.ar(662, 0.2)
|
|
];
|
|
b = [
|
|
SinOsc.ar(442, 0, 0.2),
|
|
Saw.ar(660, 0.2)
|
|
];
|
|
|
|
Mix([a, b]).postln;
|
|
}.play;
|
|
)
|
|
|
|
(
|
|
var n = 8;
|
|
{
|
|
Mix.fill(n, { SinOsc.ar([220, 500 + 500.0.rand], 0, 1 / n) });
|
|
}.play;
|
|
)
|
|
|
|
(
|
|
var n = 8;
|
|
{
|
|
Mix.fill(n, { |index|
|
|
var freq;
|
|
index.postln;
|
|
freq = 440 + index;
|
|
freq.postln;
|
|
SinOsc.ar(freq, 0, 1 / n)
|
|
});
|
|
}.play;
|
|
)
|
|
|
|
(
|
|
{
|
|
PinkNoise.ar(0.2) + SinOsc.ar(440, 0, 0.2) + Saw.ar(660, 0.2)
|
|
}.plot;
|
|
)
|
|
|
|
(
|
|
{
|
|
PinkNoise.ar(0.2) + SinOsc.ar(440, 0, 0.2) + Saw.ar(660, 0.2)
|
|
}.plot(1);
|
|
)
|
|
|
|
(
|
|
{
|
|
PinkNoise.ar(0.2) + SinOsc.ar(440, 0, 0.2) + Saw.ar(660, 0.2)
|
|
}.scope;
|
|
)
|
|
|
|
(
|
|
{
|
|
[
|
|
SinOsc.ar(440, 0, 0.2),
|
|
SinOsc.ar(442, 0, 0.2)
|
|
]
|
|
}.scope;
|
|
)
|
|
|
|
(
|
|
{
|
|
[
|
|
SinOsc.ar(440, 0, 0.2),
|
|
SinOsc.ar(442, 0, 0.2)
|
|
]
|
|
}.scope(zoom: 10);
|
|
)
|
|
|
|
(
|
|
SynthDef.new(
|
|
"tutorial-SinOsc",
|
|
{
|
|
Out.ar(0, SinOsc.ar(440, 0, 0.2))
|
|
}
|
|
).play;
|
|
)
|
|
|
|
(
|
|
SynthDef.new(
|
|
"tutorial-SinOsc-stereo",
|
|
{
|
|
var outArray;
|
|
outArray = [
|
|
SinOsc.ar(440, 0, 0.2),
|
|
SinOsc.ar(442, 0, 0.2)
|
|
];
|
|
Out.ar(0, outArray)
|
|
}
|
|
).play;
|
|
)
|
|
|
|
(
|
|
x = { SinOsc.ar(660, 0, 0.2) }.play;
|
|
y = SynthDef.new(
|
|
"tutorial-SinOsc",
|
|
{
|
|
Out.ar(0, SinOsc.ar(440, 0, 0.2))
|
|
}
|
|
).play;
|
|
)
|
|
|
|
(
|
|
x.free;
|
|
y.free;
|
|
)
|
|
|
|
|
|
(
|
|
SynthDef.new(
|
|
"tutorial-PinkNoise",
|
|
{
|
|
Out.ar(0, PinkNoise.ar(0.3))
|
|
}
|
|
).add;
|
|
|
|
x = Synth.new("tutorial-PinkNoise");
|
|
y = Synth.new("tutorial-PinkNoise");
|
|
)
|
|
|
|
(
|
|
f = {
|
|
SinOsc.ar(440 + 200.rand, 0, 0.2)
|
|
};
|
|
x = f.play;
|
|
y = f.play;
|
|
z = f.play;
|
|
)
|
|
|
|
(
|
|
SynthDef(
|
|
"tutorial-NoRand",
|
|
{
|
|
Out.ar(0, SinOsc.ar(440 + 200.rand, 0, 0.2))
|
|
}
|
|
).add;
|
|
x = Synth("tutorial-NoRand");
|
|
y = Synth("tutorial-NoRand");
|
|
z = Synth("tutorial-NoRand");
|
|
)
|
|
|
|
(
|
|
SynthDef(
|
|
"tutorial-Rand",
|
|
{
|
|
Out.ar(0, SinOsc.ar(Rand(440, 660), 0, 0.2))
|
|
}
|
|
).add;
|
|
x = Synth("tutorial-Rand");
|
|
y = Synth("tutorial-Rand");
|
|
z = Synth("tutorial-Rand");
|
|
)
|
|
|
|
(
|
|
SynthDef(
|
|
"tutorial-args",
|
|
{
|
|
|freq = 440, out = 0|
|
|
Out.ar(out, SinOsc.ar(freq, 0, 0.2))
|
|
}
|
|
).add;
|
|
Task({
|
|
x = Synth("tutorial-args");
|
|
1.wait;
|
|
y = Synth("tutorial-args", ["freq", 660]);
|
|
1.wait;
|
|
z = Synth("tutorial-args", ["freq", 880, "out", 1]);
|
|
1.wait;
|
|
//x.free; y.free; z.free;
|
|
}).play;
|
|
)
|
|
|
|
(
|
|
SynthDef.new(
|
|
\tutorialargs,
|
|
{
|
|
|freq = 440, out = 0|
|
|
Out.ar(out, SinOsc.ar(freq, 0, 0.2));
|
|
}
|
|
).add;
|
|
Task({
|
|
x = Synth(\tutorialargs);
|
|
1.wait;
|
|
x.set(\freq, 660);
|
|
1.wait;
|
|
x.set(\freq, 880, \out, 1);
|
|
1.wait;
|
|
//x.free;
|
|
}).play;
|
|
)
|
|
|
|
(
|
|
In.ar(0, 1);
|
|
In.ar(0, 4);
|
|
)
|
|
|
|
(
|
|
{
|
|
Out.ar(0, SinOsc.kr)
|
|
}.play;
|
|
)
|
|
|
|
(
|
|
{
|
|
Out.kr(0, SinOsc.ar)
|
|
}.scope;
|
|
)
|
|
|
|
(
|
|
SynthDef(
|
|
"tutorial-args",
|
|
{
|
|
|freq = 440, out = 0|
|
|
Out.ar(out, SinOsc.ar(freq, 0, 0.2));
|
|
}
|
|
).add;
|
|
|
|
x = Synth("tutorial-args", ["out", 1, "freq", 660]);
|
|
y = Synth("tutorial-args", ["out", 1, "freq", 770]);
|
|
)
|
|
|
|
(
|
|
b = Bus.control(s, 2);
|
|
c = Bus.audio(s);
|
|
)
|
|
|
|
(
|
|
b = Bus.control(s, 2);
|
|
b.index.postln;
|
|
b.numChannels.postln;
|
|
|
|
c = Bus.control(s);
|
|
c.index.postln;
|
|
c.numChannels.postln;
|
|
)
|
|
|
|
(
|
|
SynthDef(
|
|
"tutorial-Infreq",
|
|
{
|
|
|bus, freqOffset = 0|
|
|
Out.ar(0, SinOsc.ar(In.kr(bus) + freqOffset, 0, 0.5));
|
|
}
|
|
).add;
|
|
|
|
SynthDef(
|
|
"tutorial-Outfreq",
|
|
{
|
|
|freq = 400, bus|
|
|
Out.kr(bus, SinOsc.kr(1, 0, freq/40, freq));
|
|
}
|
|
).add;
|
|
|
|
b = Bus.control(s, 1);
|
|
|
|
x = Synth("tutorial-Outfreq", [\bus, b]);
|
|
y = Synth.after(x, "tutorial-Infreq", [\bus, b]);
|
|
z = Synth.after(x, "tutorial-Infreq", [\bus, b, \freqOffset, 200]);
|
|
)
|
|
|
|
(
|
|
SynthDef(
|
|
"tutorial-DecayPink",
|
|
{
|
|
|outBus = 0, effectBus, direct = 0.5|
|
|
var source;
|
|
source = Decay2.ar(Impulse.ar(1, 0.25), 0.01, 0.2, PinkNoise.ar);
|
|
Out.ar(outBus, source * direct);
|
|
Out.ar(effectBus, source * (1 - direct));
|
|
}
|
|
).add;
|
|
|
|
SynthDef(
|
|
"tutorial-DecaySin",
|
|
{
|
|
|outBus = 0, effectBus, direct = 0.5|
|
|
var source;
|
|
source = Decay2.ar(
|
|
Impulse.ar(1, 0.25),
|
|
0.3,
|
|
1,
|
|
SinOsc.ar(
|
|
SinOsc.kr(0.2, 0, 110, 440)
|
|
)
|
|
);
|
|
|
|
Out.ar(outBus, source * direct);
|
|
Out.ar(effectBus, source * (1 - direct));
|
|
}
|
|
).add;
|
|
|
|
SynthDef(
|
|
"tutorial-Reverb",
|
|
{
|
|
|outBus = 0, inBus|
|
|
var input;
|
|
|
|
input = In.ar(inBus, 1);
|
|
|
|
16.do({
|
|
input = AllpassC.ar(
|
|
input,
|
|
0.04,
|
|
{
|
|
Rand(0.001, 0.04);
|
|
}.dup,
|
|
3
|
|
)
|
|
});
|
|
|
|
Out.ar(outBus, input);
|
|
}
|
|
).add;
|
|
|
|
b = Bus.audio(s, 1);
|
|
|
|
x = Synth("tutorial-Reverb", [\inBus, b]);
|
|
y = Synth.before(x, "tutorial-DecayPink", [\effectBus, b]);
|
|
z = Synth.before(x, "tutorial-DecaySin", [\effectBus, b, \outBus, 1]);
|
|
|
|
y.set(\direct, 1);
|
|
z.set(\direct, 1);
|
|
y.set(\direct, 0);
|
|
z.set(\direct, 0);
|
|
)
|