Move tons of stuff into oldstuff/

This commit is contained in:
2020-06-04 09:54:59 -04:00
parent 49038bb8ef
commit aa1345b6ed
213 changed files with 0 additions and 12 deletions

View File

@@ -0,0 +1,41 @@
(
s.boot;
)
(
s.stop;
)
// modulate a sine frequency and a noise amplitude with another sine
// whose frequency depends on the horizontal mouse pointer position
(
{
var x = SinOsc.ar(MouseX.kr(1, 100));
SinOsc.ar(300 * x + 800, 0, 0.1) + PinkNoise.ar(0.1 * x + 0.1)
}.play;
)
// simple synth definition using the Atari2600 UGen:
(
SynthDef(
\atari2600, {
|out=0, gate=1, tone0=5, tone1=8, freq0=10, freq1=20, amp=1, pan=0|
var e, z;
e = EnvGen.kr(Env.asr(0.01, amp, 0.05), gate, doneAction: 2);
z = Atari2600.ar(tone0, tone1, freq0, freq1, 15, 15);
Out.ar(out, Pan2.ar(z * e, pan));
}).add
)
// and a pattern to play it:
(
Pbind(
\instrument, \atari2600,
\dur, Pseq([0.25, 0.25, 0.25, 0.45], inf),
\amp, 0.8,
\tone0, Pseq([Pseq([2, 5], 32), Pseq([3, 5], 32)], inf),
\tone1, 14,
\freq0, Pseq([Pbrown(28, 31, 1, 32), Pbrown(23, 26, 3, 32)], inf),
\freq1, Pseq([Pn(10, 16), Pn(11, 16)], inf)
).play
)

View File

@@ -0,0 +1,15 @@
(
s.boot;
)
(
{
var freqCutoff = MouseX.kr(400, 2000);
var ampl = MouseY.kr(0.1, 1.5);
var out = LPF.ar(
WhiteNoise.ar(mul: ampl),
freq: freqCutoff
);
[out, out]
}.scope
)

View File

@@ -0,0 +1,43 @@
package main
import (
"fmt"
"net"
"github.com/hypebeast/go-osc/osc"
)
func main() {
// client := osc.NewClient("localhost", 9949)
msg := osc.NewMessage("/osc/address")
msg.Append(int32(111))
msg.Append(true)
msg.Append("hello")
fmt.Printf("Sending: %#v\n", msg)
// err := client.Send(msg)
err := sendTCP(msg)
if err != nil {
fmt.Printf("ERROR: %#v\n", err)
}
}
func sendTCP(packet osc.Packet) error {
conn, err := net.Dial("tcp", "127.0.0.1:9949")
if err != nil {
return err
}
defer conn.Close()
data, err := packet.ToByteArray()
if err != nil {
return err
}
_, err = conn.Write(data)
if err != nil {
return err
}
return nil
}

View File

@@ -0,0 +1,40 @@
(
n = NetAddr("127.0.0.1", 8765);
n.sendMsg("/good/news", "haaay");
)
(
f = { |msg, time, addr|
if((addr.port == 8765) && (msg[0] != '/status.reply'), {
"time: % sender: %\nmessage: %\n".postf(time, addr, msg);
});
};
thisProcess.addOSCRecvFunc(f);
)
(
thisProcess.replaceOSCRecvFunc(f, f);
)
(
thisProcess.removeOSCRecvFunc(f);
)
(
thisProcess.openUDPPort(1121);
)
(
thisProcess.stop;
)
(
thisProcess.openPorts;
)
(
// OSCFunc.trace(false);
s.quit;
s.boot;
// OSCFunc.trace(true);
)

View File

@@ -0,0 +1,121 @@
(
s.boot;
)
(
2 + 2
)
(
"I am SuperCollider 3".speak
)
(
{
Pan2.ar(SinOsc.ar(440, 0, 0.1), 0.0)
}.play;
)
(
{
Pan2.ar(SinOsc.ar(MouseX.kr(440, 880), 0, 0.1), 0.0)
}.play;
)
(
{
var n = 11;
Resonz.ar(
Mix.fill(n, {
var freq = rrand(50, 560.3);
var numcps = rrand(2, 20);
Pan2.ar(
Gendy1.ar(
6.rand, 6.rand, 1.0.rand, 1.0.rand, freq, freq,
1.0.rand, 1.0.rand, numcps,
SinOsc.kr(exprand(0.02, 0.2), 0, numcps/2, numcps/2),
0.5/(n.sqrt)
),
1.0.rand2
)
}),
MouseX.kr(100, 2000),
MouseY.kr(0.1, 1.0)
);
}.play
)
(
{
Pan2.ar(
SinOsc.ar(440, 0, 0.1),
0.0
)
}.play
)
(
{
SinOsc.ar(440, 0, 0.1) + Pulse.ar(443, 0.6, 0.05)
}.play;
)
(
if(4 == 4, {
if(3 == 3, {
"correct!".postln
});
});
)
(
2.postln;
Post << [2, 3, 4, 5] << nl;
)
(
var freq;
freq = rrand(300, 600);
{
SinOsc.ar(freq, 0, 0.1)
}.play;
)
// :boom:
(
{ SinOsc.ar(nil) }.play
)
// :boom:
(
Array.series(9, 0, 1) + nil
)
(
"ls -l".unixCmd
)
(
var p, l, d = "";
p = Pipe.new("ls -l", "r");
l = p.getLine;
while(
{ l.notNil },
{
d = d ++ l ++ "\n";
l = p.getLine;
}
);
p.close;
Post << d << nl;
d[0..20]
)
(
Array.browse
)

View File

@@ -0,0 +1,496 @@
(
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
)

View File

@@ -0,0 +1,300 @@
(
s.boot;
)
(
FreqScope.new;
)
(
{SinOsc.ar(440, 0, 0.1)}.scope
)
(
{SinOsc.ar(440, 0, Line.kr(0.1, 0.0, 1.0))}.scope
)
(
{SinOsc.ar(440, 0, Line.kr(0.1, 0, 1, doneAction: 2))}.scope
)
(
Env([1, 0, 1], [1, 1]).plot
)
(
Env([0, 1, 0], [1.0, 0.5]).plot
)
(
Env.linen(0.03, 0.5, 0.1).plot
)
(
Env.adsr(0.01, 0.5, 0.5, 0.1, 1.0, 0).plot
)
(
Env.perc(0.05, 0.5, 1.0, 0).plot
)
(
Env([1, 0], [1.0]).plot
)
(
{EnvGen.ar(Env([1, 0], [1.0]))}.scope
)
(
{SinOsc.ar(440, 0, 0.1) * EnvGen.kr(Env([1, 0], [1.0]))}.scope
)
(
Env([1000, 20], [1.0]).plot
)
(
{Saw.ar(EnvGen.ar(Env([1000, 20], [1.0])), 0.1)}.scope
)
(
{
Saw.ar(
EnvGen.ar(Env([1000, 20], [0.5])),
EnvGen.ar(Env([0.1, 0], [2.0]))
)
}.scope
)
(
{
Saw.ar(
EnvGen.kr(Env([1000, 20], [0.5])),
EnvGen.kr(Env([0.1, 0], [2.0]))
)
}.play
)
(
{
SinOsc.ar(
SinOsc.ar(10, 0, 10, 440),
0.0,
EnvGen.kr(Env([0.5, 0.0], [1.0]), doneAction: 2)
)
}.scope
)
(
{
Saw.ar(
EnvGen.kr(Env([500, 100], [1.0]), doneAction: 2),
0.1
)
}.scope
)
(
{
Saw.ar(
SinOsc.ar(1, 0, 10, 440),
Line.kr(0, 1, 1, doneAction: 2)
)
}.scope
)
(
{
Saw.ar(
SinOsc.ar(1, 0, 10, 440),
XLine.kr(0.0001, 1, 1, doneAction: 2)
)
}.scope
)
(
{
EnvGen.ar(
Env([0, 0.1, 0], [0.1, 0.9]), doneAction: 2
) * SinOsc.ar(330)
}.scope
)
(
a = {
EnvGen.ar(
Env.asr(0.1, 0.1, 1.0), doneAction: 2
) * SinOsc.ar(330)
}.play
)
(
a.release(2.0);
)
(
a = {
arg gate=1;
EnvGen.ar(
Env.asr(0.1, 0.1, 0.9), gate, doneAction: 2
) * SinOsc.ar(330)
}.play
)
(
a.set(\gate, 0)
)
(
e = Env([0.2, 1.0, 0.0], [0.1, 3.0], 0, 1);
a = {
arg gate=1;
EnvGen.ar(
e, gate, doneAction: 2
) * SinOsc.ar(550, 0, 0.1)
}.play
)
(
a.set(\gate, 0);
)
(
e = Env([0.0, 0.0, 1.0, 0.0], [0.5, 1.0, 2.0], 0, 2, 0);
a = {
arg gate=1;
EnvGen.ar(
e, gate, doneAction: 2
) * SinOsc.ar(550, 0, 0.1)
}.play
)
(
a.set(\gate, 0);
)
(
e = Env(
[0.0, 1.0, -1.0, 0.0],
[0.01, 0.01, 2.0],
0,
2, // releaseNode
0 // loopNode
);
e.plot;
a = {
arg gate=1;
EnvGen.ar(
e, gate, timeScale: MouseX.kr(0.1, 2.0), doneAction: 2
)
}.play
)
(
a.set(\gate, 0);
)
(
SynthDef(\sine,
{
Out.ar(
0, SinOsc.ar(
Rand(440, 880), 0, 0.1
)
)
}
).add;
)
(
Synth(\sine);
)
(
a = Synth(\sine);
a.writeDefFile("synth.out");
)
(
SynthDef(\sine, {
arg freq=440, amp=0.1;
Out.ar(
0,
SinOsc.ar(freq, 0, amp)
)
}).add;
)
(
Synth("sine");
Synth("sine", [\freq, 880])
)
(
a = Synth(\sine);
b = Synth(\sine, [\freq, 550]);
c = Synth(\sine, [\freq, 660, \amp, 0.5]);
)
(
c.set(\freq, 1000);
b.set(\amp, 0.3, \freq, 100);
)
(
a.free;
b.free;
c.free;
)
(
SynthDef(\hum, {
arg freq=440;
var finaloutput = Mix(
[
SinOsc.ar(freq, 0, 0.3),
SinOsc.ar(freq*2, 0, 0.2),
SinOsc.ar(freq*3, 0, 0.1),
SinOsc.ar(freq*3.33, 0, 0.01),
SinOsc.ar(freq*4, 0, 0.1),
SinOsc.ar(freq*4.5, 0, 0.01),
SinOsc.ar(freq*4.75, 0, 0.02)
]
);
Out.ar(0, finaloutput);
}).add;
)
(
Synth(\hum, [\freq, 220]);
)
(
Synth(\hum, [\freq, 880]);
)
(
Synth(\hum, [\freq, 440]);
)
(
SynthDescLib.global.synthDescs[\sine].def.func.postcs
)
(
SynthDescLib.global.synthDescs.do { |desc|
if(desc.def.notNil) {
"\nSynthDef %\n".postf(desc.name.asCompileString);
desc.def.func.postcs;
};
}
)

View File

@@ -0,0 +1,919 @@
(
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);
)
(
b = Bus.control(s, 1);
b.set(880);
c = Bus.control(s, 1);
c.set(884);
x = SynthDef(
"tutorial-map",
{
|freq1 = 440, freq2 = 440|
Out.ar(0, SinOsc.ar([freq1, freq2], 0, 0.2));
}
).play(s);
// x.map(\freq1, b, \freq2, c);
/*
y = {
Out.kr(b, SinOsc.kr(1, 0, 50, 880));
}.play(addAction: \addToHead);
*/
// y.free;
// b.get({ |val| val.postln; f = val; });
// x.set(\freq2, f / 2);
// c.set(200);
// x.free;
// b.free;
// c.free;
)
(
SynthDef(
\tutorial_DecaySin2,
{
|outBus = 0, effectBus, direct = 0.5, freq = 440|
var source;
source = Pan2.ar(
Decay2.ar(
Impulse.ar(
Rand(0.3, 1),
0,
0.125
),
0.3,
1,
SinOsc.ar(
SinOsc.kr(0.2, 0, 110, freq)
)
),
Rand(-1.0, 1.0)
);
Out.ar(outBus, source * direct);
Out.ar(effectBus, source * (1 - direct));
}
).add;
SynthDef(
\tutorial_Reverb2,
{
|outBus = 0, inBus|
var input;
input = In.ar(inBus, 2);
16.do({
input = AllpassC.ar(input, 0.04, Rand(0.001, 0.04), 3)
});
Out.ar(outBus, input);
}
).add;
~sources = Group.new;
~effects = Group.after(~sources);
~bus = Bus.audio(s, 2);
x = Synth(
\tutorial_Reverb2,
[\inBus, b],
~effects
);
y = Synth(
\tutorial_DecaySin2,
[\effectBus, ~bus, \outBus, 0],
~sources
);
z = Synth(
\tutorial_DecaySin2,
[\effectBus, ~bus, \outBus, 0, \freq, 660],
~sources
);
/*
~sources.free;
~effects.free;
~bus.free;
currentEnvironment.clear;
*/
)
(
g = Group.new;
h = Group.head(g);
x = Synth.tail(h, \default);
s.queryAllNodes;
)
(
Server.default.boot;
a = Synth.new(\default);
a.group;
)
(
{
SinOsc.ar(mul: 0.2)
}.scope(1);
s.queryAllNodes;
)
(
g = Group.new;
4.do({
{
|amp = 0.1|
Pan2.ar(
SinOsc.ar(440 + 110.rand, 0, amp),
1.0.rand2
)
}.play(g);
});
g.set(\amp, 0.005);
// g.free;
)
(
"--- haaaay ---".postln;
Group.superclass.postln;
// Group.superclass.help;
Group.findRespondingMethodFor('set').postln;
Group.findRespondingMethodFor('postln').postln;
// Group.findHelpForMethod('postln');
)
(
b = Buffer.alloc(s, 100, 2);
b.free;
)
(
b = Buffer.alloc(s, s.sampleRate * 8.0, 2);
b.free;
)
(
b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");
x = SynthDef(
"tutorial-PlayBuf",
{
|out = 0, bufnum|
Out.ar(out,
PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum))
)
}
).play(s, [\bufnum, b]);
// x.free;
// b.free;
)
(
SynthDef(
"tutorial-Buffer-cue",
{
|out = 0, bufnum|
Out.ar(out, DiskIn.ar(1, bufnum))
}
).add;
)
(
b = Buffer.cueSoundFile(
s,
Platform.resourceDir +/+ "sounds/a11wlk01-44_1.aiff",
0,
1
);
y = Synth.new("tutorial-Buffer-cue", [\bufnum, b], s);
b.free;
y.free;
)
(
b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");
b.bufnum.postln;
b.numFrames.postln;
b.numChannels.postln;
b.sampleRate.postln;
b.free.postln;
)
(
b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav", action: { |buffer|
("numFrames after update:" + buffer.numFrames).postln;
x = {
PlayBuf.ar(1, buffer, BufRateScale.kr(buffer))
}.play;
});
("numFrames before update:" + b.numFrames).postln;
// x.free; b.free;
)
(
b = Buffer.alloc(s, s.sampleRate * 5, 1);
x = SynthDef(
"tutorial-RecordBuf",
{
|out = 0, bufnum = 0|
var noise;
noise = PinkNoise.ar(0.3);
RecordBuf.ar(noise, bufnum);
}
).play(s, [\out, 0, \bufnum, b]);
)
(
x.free;
)
(
SynthDef(
"tutorial-Playback",
{
|out = 0, bufnum = 0|
var playbuf;
playbuf = PlayBuf.ar(1, bufnum);
FreeSelfWhenDone.kr(playbuf);
Out.ar(out, playbuf);
}
).play(s, [\out, 0, \bufnum, b]);
)
(
b.free;
)
(
Date.getDate.postln;
b = Buffer.alloc(s, 8, 1);
b.updateInfo({
|buf|
buf.set(7, 0.5);
buf.get(7, { |msg| msg.postln });
});
)
(
b.free;
)
(
var nFrames = 16;
Buffer.alloc(s, nFrames).updateInfo({
|b|
Task.new({
0.01.wait;
b.setn(0, [1, 2, 3]);
b.getn(0, 3, { |msg| ("1: "+ msg).postln });
0.01.wait;
b.setn(0, Array.fill(nFrames, { 1.0.rand }));
b.getn(0, nFrames, {
|msg|
("2: " + msg).postln;
"3: buh bye".postln;
b.free
});
}).play;
});
)
(
v = FloatArray.fill(44100, { 1.0.rand2 });
b = Buffer.alloc(s, 44100);
)
(
b.loadCollection(v, action: {
|buf|
x = {
PlayBuf.ar(buf.numChannels, buf, BufRateScale.kr(buf), loop: 1) * 0.2;
}.play;
});
)
(
x.free;
)
(
b.loadToFloatArray(0, -1, { |floatArray| (floatArray == v).postln; });
b.free;
)
(
b.free;
)
(
b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");
b.updateInfo({
|b|
x = b.play(true);
SystemClock.sched(5, { x.free; b.free; });
});
// b.play;
)
(
b = Buffer.alloc(s, 512, 1);
b.cheby([1, 0, 1, 1, 0, 1]);
x = play({
Shaper.ar(
b,
SinOsc.ar(300, 0, Line.kr(0, 1, 6)),
0.5
)
});
SystemClock.sched(10, { x.free; b.free; });
)
(
SystemClock.sched(5, { "hello".postln });
)
(
var timeNow = TempoClock.default.beats;
"Time is now: ".post;
timeNow.postln;
"Scheduling for: ".post;
(timeNow + 5).postln;
TempoClock.default.schedAbs(timeNow + 5,
{ "Time is later: ".post; thisThread.clock.beats.postln; nil }
);
)
(
var timeNow;
"------------------------------------".postln;
TempoClock.default.tempo = 2;
timeNow = TempoClock.default.beats;
"Time is now: ".post;
timeNow.postln;
"Scheduling for: ".post;
(timeNow + 5).postln;
TempoClock.default.schedAbs(timeNow + 5,
{ "Time is later: ".post; thisThread.clock.beats.postln; nil }
);
)
(
"SystemClock.beats: ".post; SystemClock.beats.postln;
"TempoClock.default.beats: ".post; TempoClock.default.beats.postln;
"AppClock.beats: ".post; AppClock.beats.postln;
Task({
"thisThread.clock.beats: ".post; thisThread.clock.beats.postln;
}).play;
)
(
TempoClock.default.sched(5, { "hello".postln; nil; });
)
(
r = Routine({
"abcde".yield;
"fghij".yield;
"klmno".yield;
"pqrst".yield;
"uvwxy".yield;
"z{|}~".yield;
});
r.next;
6.do({ r.next.postln; });
)
(
r = Routine({
var delta;
loop {
delta = rrand(1, 3) * 0.5;
"Will wait ".post; delta.postln;
delta.yield;
}
});
r.next;
TempoClock.default.sched(0, r);
)
(
r.stop;
)
(
SystemClock.sched(1, { 20.do({ "".postln; }) });
)
// {-------------------------------------------------------------------------
(
SynthDef(
\singrain,
{
|freq = 440, amp = 0.2, sustain = 1|
var sig = SinOsc.ar(
freq, 0, amp
) * EnvGen.kr(
Env.perc(0.01, sustain), doneAction: 2
);
Out.ar(0, sig ! 2);
}
).add;
r = Routine({
var delta;
loop {
delta = rrand(1, 3) * 0.5;
Synth(
\singrain,
[
freq: exprand(200, 800),
amp: rrand(0.1, 0.5),
sustain: delta * 0.8
]
);
delta.yield;
}
});
)
(
"starting routine".postln;
r.play;
)
(
"stopping routine".postln;
r.stop;
)
// }-------------------------------------------------------------------------
// {-------------------------------------------------------------------------
(
t = Task({
loop {
[60, 62, 64, 65, 67, 69, 71, 72].do({
|midi|
Synth(
\singrain,
[
freq: midi.midicps,
amp: 0.2,
sustain: 0.2
]
);
0.125.wait;
});
}
}).play;
)
(
t.stop;
)
// }-------------------------------------------------------------------------
// {-------------------------------------------------------------------------
(
f = {
Task({
loop {
[60, 62, 64, 65, 67, 69, 71, 72].do({
|midi|
Synth(
\singrain,
[
freq: midi.midicps,
amp: 0.2,
sustain: 0.1
]
);
0.25.wait;
});
}
});
};
t = f.value.play(quant: 4);
u = f.value.play(quant: [4, 0.5]);
)
(
t.stop;
u.stop;
)
// }-------------------------------------------------------------------------