Last active
November 22, 2015 04:48
-
-
Save eirikblekesaune/3812c5259b81b5695ff4 to your computer and use it in GitHub Desktop.
Pproto event type tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///Testing event type 'allocRead' | |
( | |
s.waitForBoot({ | |
SynthDef(\help_playbuf, { | out=0, bufnum = 0, rate = 1, startPos = 0, amp = 0.1, sustain = 1, pan = 0, loop = 1| | |
var audio; | |
rate = rate * BufRateScale.kr(bufnum); | |
startPos = startPos * BufFrames.kr(bufnum); | |
audio = BufRd.ar(1, bufnum, Phasor.ar(0, rate, startPos, BufFrames.ir(bufnum)), 1, 1); | |
audio = EnvGen.ar(Env.sine, 1, timeScale: sustain, doneAction: 2) * audio; | |
audio = Pan2.ar(audio, pan, amp); | |
OffsetOut.ar(out, audio); | |
}).add; | |
s.sync; | |
a = Pproto({ | |
~sf1 = (type: \allocRead, path: Platform.resourceDir +/+ "sounds/a11wlk01-44_1.aiff").yield; | |
}, | |
Pbind(*[ | |
instrument: \help_playbuf, | |
dur: Pseg([0,0,0.25,0.5, 0.75, 1],10).linexp(0,1,0.01,2), | |
legato: 4, | |
startPos: Pn(Pseg([0,1], 20), inf), | |
rate: Pwhite(1, 1).midiratio, | |
loop: 0, | |
bufnum: Pkey(\sf1) | |
]) | |
); | |
f = a.play; | |
}); | |
) | |
f.stop; | |
//Testing event type 'group' | |
( | |
s.waitForBoot({ | |
a = Pproto({ | |
~mygroup = (type: \group).yield; | |
}, | |
Pbind(\group, Pkey(\mygroup)) | |
); | |
f = a.play; | |
}); | |
) | |
f.stop; | |
//Testing event type 'table' | |
( | |
s.waitForBoot({ | |
SynthDef(\tabler, { | out=0, bufnum = 0, noteindex = 0, amp = 0.1, pan = 0, loop = 1, sustain = 1.0| | |
var audio; | |
audio = Saw.ar(Index.kr(bufnum, noteindex)); | |
audio = EnvGen.ar(Env.sine, 1, timeScale: sustain, doneAction: 2) * audio; | |
audio = Pan2.ar(audio, pan, amp); | |
OffsetOut.ar(out, audio); | |
}).add; | |
s.sync; | |
a = Pproto({ | |
~mytable = (type: \table, amps: [100, 200, 300, 400]).yield; | |
}, | |
Pbind( | |
\instrument, \tabler, | |
\bufnum, Pkey(\mytable), | |
\noteindex, Pseq([0,1,2,3], inf) | |
) | |
); | |
f = a.play; | |
}); | |
) | |
f.stop; | |
//Testing event type 'cue'. How should this work actually? | |
( | |
s.waitForBoot({ | |
s.dumpOSC(2); | |
SynthDef(\discplayer, { | out=0, bufnum = 0, amp = 0.1, pan = 0, loop = 1, sustain = 1.0| | |
var audio; | |
audio = DiskIn.ar(1, bufnum, loop).poll; | |
audio = EnvGen.ar(Env.sine, 1, timeScale: sustain, doneAction: 2) * audio; | |
audio = Pan2.ar(audio, pan, amp); | |
OffsetOut.ar(out, audio); | |
}).add; | |
s.sync; | |
a = Pproto({ | |
var path = Platform.resourceDir +/+ "sounds/a11wlk01-44_1.aiff"; | |
~mycue = (type: \cue, path: path).yield; | |
}, | |
Pmono(\discplayer, | |
\bufnum, Pkey(\mycue), loop: 0 | |
) | |
); | |
f = a.play; | |
}); | |
) | |
f.stop; fork{1.0.wait; s.dumpOSC(0)} | |
//Testing event type 'sine1' | |
( | |
s.waitForBoot({ | |
s.dumpOSC(2); | |
SynthDef(\osc, { | out=0, bufnum = 0, noteindex = 0, amp = 0.1, pan = 0, loop = 1, sustain = 1.0, freq = 440.0| | |
var audio; | |
audio = Osc.ar(bufnum, freq); | |
audio = EnvGen.ar(Env.sine, 1, timeScale: sustain, doneAction: 2) * audio; | |
audio = Pan2.ar(audio, pan, amp); | |
OffsetOut.ar(out, audio); | |
}).add; | |
s.sync; | |
a = Pproto({ | |
~mytable = (type: \sine1, amps: [1.0, 0.2, 0.5, 0.2]).yield; | |
}, | |
Pbind( | |
\instrument, \osc, | |
\bufnum, Pkey(\mytable), | |
\degree, Pseq([0,1,2,3], inf) | |
) | |
); | |
f = a.play; | |
}); | |
) | |
f.stop; fork{1.0.wait; s.dumpOSC(0)} | |
//Testing event type 'sine2' | |
( | |
s.waitForBoot({ | |
s.dumpOSC(2); | |
SynthDef(\osc, { | out=0, bufnum = 0, noteindex = 0, amp = 0.1, pan = 0, loop = 1, sustain = 1.0, freq = 440.0| | |
var audio; | |
audio = Osc.ar(bufnum, freq); | |
audio = EnvGen.ar(Env.sine, 1, timeScale: sustain, doneAction: 2) * audio; | |
audio = Pan2.ar(audio, pan, amp); | |
OffsetOut.ar(out, audio); | |
}).add; | |
s.sync; | |
a = Pproto({ | |
~mytable = (type: \sine2, amps: [1.0, 0.2, 0.5, 1.0], freqs: [1, 7/4, 5/4, 13/9]).yield; | |
}, | |
Pbind( | |
\instrument, \osc, | |
\bufnum, Pkey(\mytable), | |
\degree, Pseq([0,1,2,3], inf) | |
) | |
); | |
f = a.play; | |
}); | |
) | |
f.stop; fork{1.0.wait; s.dumpOSC(0)} | |
//Testing event type 'sine3' | |
( | |
s.waitForBoot({ | |
s.dumpOSC(2); | |
SynthDef(\osc, { | out=0, bufnum = 0, noteindex = 0, amp = 0.1, pan = 0, loop = 1, sustain = 1.0, freq = 440.0| | |
var audio; | |
audio = Osc.ar(bufnum, freq); | |
audio = EnvGen.ar(Env.sine, 1, timeScale: sustain, doneAction: 2) * audio; | |
audio = Pan2.ar(audio, pan, amp); | |
OffsetOut.ar(out, audio); | |
}).add; | |
s.sync; | |
a = Pproto({ | |
~mytable = (type: \sine3, amps: [1.0, 0.2, 0.5, 1.0], freqs: [1, 7/4, 5/4, 13/9], phases: {2pi.rand} ! 4).yield; | |
}, | |
Pbind( | |
\instrument, \osc, | |
\bufnum, Pkey(\mytable), | |
\degree, Pseq([0,1,2,3], inf) | |
) | |
); | |
f = a.play; | |
}); | |
) | |
f.stop; fork{1.0.wait; s.dumpOSC(0)} | |
//Testing event type 'audioBus' | |
( | |
s.waitForBoot({ | |
"Before alloc: %".format(s.audioBusAllocator.findAvailable(1)).postln; | |
a = Pproto({ | |
~mybuses = (type: \audioBus, channels: 4).yield; | |
"After alloc: %".format(s.audioBusAllocator.findAvailable(1)).postln; | |
}, | |
Pbind() | |
); | |
f = a.play; | |
}); | |
) | |
f.stop; fork{1.0.wait; s.dumpOSC(0)}; | |
"After freed: %".format(s.audioBusAllocator.findAvailable(1)).postln; | |
//Testing event type 'controlBus' | |
( | |
s.waitForBoot({ | |
"Before alloc: %".format(s.controlBusAllocator.findAvailable(1)).postln; | |
a = Pproto({ | |
~mybuses = (type: \controlBus, channels: 12).yield; | |
"After alloc: %".format(s.controlBusAllocator.findAvailable(1)).postln; | |
}, | |
Pbind() | |
); | |
f = a.play; | |
}); | |
) | |
f.stop; fork{1.0.wait; s.dumpOSC(0)}; | |
"After freed: %".format(s.controlBusAllocator.findAvailable(1)).postln; | |
//Testing event type 'sync' | |
( | |
s.waitForBoot({ | |
SynthDef(\help_playbuf, { | out=0, bufnum = 0, rate = 1, startPos = 0, amp = 0.1, sustain = 1, pan = 0, loop = 1| | |
var audio; | |
rate = rate * BufRateScale.kr(bufnum); | |
startPos = startPos * BufFrames.kr(bufnum); | |
audio = BufRd.ar(1, bufnum, Phasor.ar(0, rate, startPos, BufFrames.ir(bufnum)), 1, 1); | |
audio = EnvGen.ar(Env.sine, 1, timeScale: sustain, doneAction: 2) * audio; | |
audio = Pan2.ar(audio, pan, amp); | |
OffsetOut.ar(out, audio); | |
}).add; | |
s.sync; | |
a = Pproto({ | |
~sf1 = (type: \allocRead, path: Platform.resourceDir +/+ "sounds/a11wlk01-44_1.aiff").yield; | |
(type: \sync).yield; | |
}, | |
Pbind(*[ | |
instrument: \help_playbuf, | |
dur: Pseg([0,0,0.25,0.5, 0.75, 1],10).linexp(0,1,0.01,2), | |
legato: 4, | |
startPos: Pn(Pseg([0,1], 20), inf), | |
rate: Pwhite(1, 1).midiratio, | |
loop: 0, | |
bufnum: Pkey(\sf1) | |
]) | |
); | |
f = a.play; | |
}); | |
) | |
f.stop; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment