497 lines
6.6 KiB
Python
497 lines
6.6 KiB
Python
(
|
|
s.boot;
|
|
)
|
|
|
|
(
|
|
FreqScope.new;
|
|
)
|
|
|
|
(
|
|
{
|
|
WhiteNoise.ar(0.1)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
LPF.ar(WhiteNoise.ar(0.1), 1000)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
HPF.ar(LPF.ar(WhiteNoise.ar(0.1), 1000), 1000)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
LPF.ar(WhiteNoise.ar(0.1), Line.kr(10000, 1000, 10))
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
Resonz.ar(
|
|
LFNoise0.ar(400),
|
|
1000,
|
|
0.1
|
|
)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
Resonz.ar(
|
|
LFNoise0.ar(400),
|
|
Line.kr(10000, 1000, 10),
|
|
0.1
|
|
)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
var source, line, filter;
|
|
|
|
source = LFNoise0.ar(400);
|
|
line = Line.kr(10000, 1000, 10);
|
|
filter = Resonz.ar(source, line, 0.1);
|
|
|
|
filter
|
|
}.scope;
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar(400, 0, 0.1) + SinOsc.ar(660, 0, 0.1)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar([400, 660], 0, 0.1)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
Pan2.ar(
|
|
WhiteNoise.ar(0.1),
|
|
MouseX.kr(-1, 1)
|
|
)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar([400], 0, 0.1)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar(400, 0, 0.1)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar([400, 660, 870], 0, 0.1)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
Mix(
|
|
SinOsc.ar([400, 660], 0, 0.1)
|
|
)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
Pan2.ar(
|
|
Mix(
|
|
SinOsc.ar([400, 660], 0, 0.1)
|
|
),
|
|
MouseX.kr(-1, 1)
|
|
)
|
|
}.scope
|
|
)
|
|
|
|
// sawtooth wave
|
|
(
|
|
{
|
|
var n = 10;
|
|
var wave = Mix.fill(10, { |i|
|
|
var mult = ((-1) ** i) * (0.5 / ((i + 1)));
|
|
SinOsc.ar(440 * (i + 1)) * mult
|
|
});
|
|
|
|
Pan2.ar(wave / n, 0.0);
|
|
}.scope
|
|
)
|
|
|
|
// square wave
|
|
(
|
|
{
|
|
var n = 10;
|
|
var wave = Mix.fill(10, { |i|
|
|
var harmonicnumber = 2 * i + 1;
|
|
SinOsc.ar(440 * harmonicnumber) / harmonicnumber
|
|
}) * 0.25;
|
|
|
|
Pan2.ar(wave, 0.0);
|
|
}.scope
|
|
)
|
|
|
|
// triangle wave
|
|
(
|
|
{
|
|
var n = 10;
|
|
var wave = Mix.fill(10, { |i|
|
|
var harmonicnumber = 2 * i + 1;
|
|
var mult = ((-1) ** ((harmonicnumber - 1)/2)) * (1.0/(harmonicnumber*harmonicnumber));
|
|
SinOsc.ar(440 * i) * mult
|
|
})/n;
|
|
|
|
Pan2.ar(wave, 0.0);
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
Mix(
|
|
SinOsc.ar(500 * [0.5, 1, 1.19, 1.56, 2.51, 2.66, 3.01, 4.1], 0, 0.1)
|
|
)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
Mix(
|
|
SinOsc.ar(
|
|
500 * [0.5, 1, 1.19, 1.56, 2.51, 2.66, 3.01, 4.1],
|
|
0,
|
|
0.1 * [0.25, 1, 0.8, 0.5, 0.9, 0.4, 0.3, 0.6, 0.1]
|
|
)
|
|
)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
var n = 10;
|
|
|
|
{
|
|
Mix(SinOsc.ar(250 * (1..n), 0, 1/n))
|
|
}.scope
|
|
)
|
|
|
|
// 2.2
|
|
|
|
(
|
|
{
|
|
SinOsc.ar(mul: 0.1)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar(mul: 2.0)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar(mul: 0.1)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar(
|
|
mul: MouseY.kr(1.0, 0.1)
|
|
)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar(
|
|
mul: 0.1, add: MouseY.kr(0.9, -0.9)
|
|
)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar(
|
|
mul: MouseX.kr(0.1, 1.0),
|
|
add: MouseY.kr(0.9, -0.9)
|
|
)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
var cutoff = SinOsc.ar(
|
|
1,
|
|
mul: MouseX.kr(0.0, 1700.0),
|
|
add: 2000.0
|
|
);
|
|
|
|
LPF.ar(
|
|
WhiteNoise.ar,
|
|
freq: cutoff
|
|
);
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
0.1 * SinOsc.ar
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar(mul: 0.1)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
0.1 * SinOsc.ar + 0.5
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar(mul: 0.1, add: 0.5)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
var cutoff = SinOsc.ar(1) * 1700.0 + 2000.0;
|
|
LPF.ar(WhiteNoise.ar, freq: cutoff)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar(440, 0.0, 0.1, 0.0)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar(MouseX.kr(440, 880), 0.0, 0.1, 0.0)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar(MouseX.kr(440, 880), mul: 0.1)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar(440, mul: -20.dbamp)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
SinOsc.ar(
|
|
40 * SinOsc.ar(MouseX.kr(1, 20)) + 440,
|
|
0,
|
|
0.1
|
|
)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
a = {
|
|
SinOsc.ar(440) * 0.1
|
|
}.play;
|
|
)
|
|
|
|
(
|
|
a.run(false);
|
|
)
|
|
|
|
(
|
|
a.run;
|
|
)
|
|
|
|
(
|
|
a.free;
|
|
)
|
|
|
|
(
|
|
a = {
|
|
arg freq=440;
|
|
SinOsc.ar(freq) * 0.1
|
|
}.play
|
|
)
|
|
|
|
(
|
|
a = {
|
|
arg freq=440, amp=0.1;
|
|
SinOsc.ar(freq) * amp;
|
|
}.play
|
|
)
|
|
|
|
(
|
|
a.set(\freq, rrand(220, 440), \amp, rrand(0.05, 0.2));
|
|
)
|
|
|
|
(
|
|
{
|
|
var carrier, modulator, carrfreq, modfreq;
|
|
|
|
carrfreq = MouseX.kr(440, 5000, 'exponential');
|
|
modfreq = MouseY.kr(1, 5000, 'exponential');
|
|
|
|
carrier = SinOsc.ar(carrfreq, 0, 0.5);
|
|
modulator = SinOsc.ar(modfreq, 0, 0.5);
|
|
|
|
carrier * modulator;
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{ SinOsc.ar(440, 0, 0.5) }.scope
|
|
)
|
|
|
|
(
|
|
{ SinOsc.ar(440, 0, 0.5, 0.5) }.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
var carrier, modulator, carrfreq, modfreq;
|
|
|
|
carrfreq = MouseX.kr(440, 5000, 'exponential');
|
|
modfreq = MouseY.kr(1, 5000, 'exponential');
|
|
|
|
carrier = SinOsc.ar(carrfreq, 0, 0.5);
|
|
modulator = SinOsc.ar(modfreq, 0, 0.25, 0.25);
|
|
|
|
carrier * modulator;
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
var w, carrfreqslider, modfreqslider, moddepthslider, synth;
|
|
|
|
w = Window("frequency modulation", Rect(100, 400, 400, 300));
|
|
w.view.decorator = FlowLayout(w.view.bounds);
|
|
|
|
synth = {
|
|
arg carrfreq=440, modfreq=1, moddepth=0.1;
|
|
SinOsc.ar(carrfreq + (moddepth * SinOsc.ar(modfreq)), 0, 0.25)
|
|
}.scope;
|
|
|
|
carrfreqslider = EZSlider(
|
|
w, 300@50, "carrfreq",
|
|
ControlSpec(20, 5000, 'exponential', 10, 440),
|
|
{ |ez| synth.set(\carrfreq, ez.value) }
|
|
);
|
|
w.view.decorator.nextLine;
|
|
|
|
modfreqslider = EZSlider(
|
|
w, 300@50, "modfreq",
|
|
ControlSpec(1, 5000, 'exponential', 1, 1),
|
|
{ |ez| synth.set(\modfreq, ez.value) }
|
|
);
|
|
w.view.decorator.nextLine;
|
|
|
|
moddepthslider = EZSlider(
|
|
w, 300@50, "moddepth",
|
|
ControlSpec(0.01, 5000, 'exponential', 0.01, 0.01),
|
|
{ |ez| synth.set(\moddepth, ez.value) }
|
|
);
|
|
|
|
w.front;
|
|
)
|
|
|
|
// 2.5
|
|
|
|
(
|
|
{
|
|
Mix(Saw.ar([440, 443, 437], 0.1))
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
{
|
|
Mix(
|
|
Resonz.ar(
|
|
Saw.ar([440, 443, 437] + SinOsc.ar(100, 0, 100)),
|
|
XLine.kr(10000, 10, 10),
|
|
Line.kr(1, 0.05, 10),
|
|
mul: LFSaw.kr(
|
|
Line.kr(3, 17, 3), 0, 0.5, 0.5
|
|
) * Line.kr(1, 0, 10)
|
|
)
|
|
)
|
|
}.scope
|
|
)
|
|
|
|
(
|
|
b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");
|
|
)
|
|
|
|
(
|
|
{
|
|
var modfreq, modindex, modulator;
|
|
|
|
modfreq = MouseX.kr(1, 4400, 'exponential');
|
|
modindex = MouseY.kr(0.0, 10.0, 'linear');
|
|
|
|
modulator = SinOsc.kr(modfreq, 0, modfreq * modindex, 440);
|
|
|
|
PlayBuf.ar(1, b, BufRateScale.kr(b) * (modulator/440), 1, 0, 1)
|
|
}.scope;
|
|
)
|
|
|
|
(
|
|
var numpartials, spectrum, amplitudes, modfreqs1, modfreqs2, decaytimes;
|
|
|
|
spectrum = [0.5, 1, 1.19, 1.56, 2, 2.51, 2.66, 3.01, 4.1];
|
|
|
|
amplitudes = [0.25, 1, 0.8, 0.5, 0.9, 0.4, 0.3, 0.6, 0.1];
|
|
|
|
numpartials = spectrum.size;
|
|
|
|
modfreqs1 = Array.rand(numpartials, 1, 5.0);
|
|
|
|
modfreqs2 = Array.rand(numpartials, 0.1, 3.0);
|
|
|
|
decaytimes = Array.fill(numpartials, { |i|
|
|
rrand(2.5, 2.5 + (5 * (1.0 - (1/numpartials))))
|
|
});
|
|
|
|
{
|
|
Mix.fill(spectrum.size, { arg i;
|
|
var amp, freq;
|
|
|
|
freq = (spectrum[i] + (SinOsc.kr(modfreqs1[i], 0, 0.005))) * 500;
|
|
amp = 0.1 * Line.kr(1, 0, decaytimes[i]) *
|
|
(SinOsc.ar(modfreqs2[i], 0, 0.1, 0.9) * amplitudes[i]);
|
|
|
|
Pan2.ar(SinOsc.ar(freq, 0, amp), 1.0.rand2) }
|
|
)
|
|
}.scope
|
|
)
|