Hacked looping as a separate method if you want it
parent
5ba3416b1f
commit
1ce69c48b6
|
@ -1,32 +1,22 @@
|
|||
|
||||
|
||||
Granulator {
|
||||
var <buflen, <inb, <outb, <>posb, <triggerb, <pitchb, <rectriggerb, <modb, <buffer, <recorder, <grains, <triggersynth, <pitchsynth, <loopsynth, server, mode, record, gain, mix, speed, trigger, size, blur, dust, slope, back, chorus, harmonics, depth, crate, detune, pitch, pan, track, jitter, loop, grainamp;
|
||||
var <buflen, <inb, <outb, <>posb, <triggerb, <pitchb, <rectriggerb, <modb, <buffer, <recorder, <grains, <triggersynth, <pitchsynth, <loopsynth, server, record, gain, mix, speed, trigger, size, blur, dust, slope, back, chorus, harmonics, depth, crate, detune, pitch, pan, track, jitter, amp, loopamp;
|
||||
|
||||
*init {
|
||||
SynthDef(
|
||||
\grain_record,
|
||||
{
|
||||
arg in = 2, triggerb = 0, buffer = 0, mix = 0.5, record = 0.0;
|
||||
var insig = record * In.ar(in, 1), trigsig = In.kr(triggerb, 1);
|
||||
RecordBuf.ar(insig, buffer, 0, mix, 1 - mix, loop: 1, trigger: trigsig)
|
||||
}
|
||||
).add();
|
||||
|
||||
SynthDef(
|
||||
\grain_looper,
|
||||
{
|
||||
arg out = 2, triggerb = 0, buffer = 0, speed = 1, amp = 0, pan = 0;
|
||||
var trigsig = In.kr(triggerb, 1), playsig;
|
||||
playsig = PlayBuf.ar(1, buffer, speed, trigsig, 0.0, 1.0);
|
||||
Out.ar(out, Pan2.ar(playsig, pan, amp));
|
||||
arg in = 2, rectriggerb = 0, buffer = 0, mix = 0.5, record = 0.0;
|
||||
var insig = record * In.ar(in, 1), rectrigsig = In.kr(rectriggerb, 1);
|
||||
RecordBuf.ar(insig, buffer, 0, mix, 1 - mix, loop: 1, trigger: rectrigsig)
|
||||
}
|
||||
).add();
|
||||
|
||||
SynthDef(
|
||||
\grain_play,
|
||||
{
|
||||
arg out=0, buffer, blen, pitchb, triggerb, posb, rectriggerb, modb, size=0.1, amp=0.5, pan=0, track=0.25, jitter=0, blur=0.0;
|
||||
arg out=0, buffer, blen, pitchb, triggerb, posb, modb, size=0.1, amp=0.5, pan=0, track=0.25, jitter=0, blur=0.0;
|
||||
var pitch, trigger, pos, pans, grains;
|
||||
trigger = In.kr(triggerb);
|
||||
pitch = In.kr(pitchb);
|
||||
|
@ -59,6 +49,15 @@ Granulator {
|
|||
Out.kr(out, (Impulse.kr(freq) * (1 - dust)) + (Dust.kr(freq) * dust));
|
||||
}
|
||||
).add();
|
||||
|
||||
SynthDef(
|
||||
\grain_looper, {
|
||||
arg out = 2, rectriggerb = 0, buffer = 0, speed = 1, amp = 0, pan = 0;
|
||||
var trigsig = In.kr(rectriggerb, 1), playsig;
|
||||
playsig = PlayBuf.ar(1, buffer, speed, trigsig, 0.0, 1.0);
|
||||
Out.ar(out, Pan2.ar(playsig, pan, amp));
|
||||
}
|
||||
).add();
|
||||
}
|
||||
|
||||
*new { | buflen, inb, outb, posb, rectriggerb |
|
||||
|
@ -75,13 +74,12 @@ Granulator {
|
|||
posb = aposb;
|
||||
rectriggerb = arectriggerb;
|
||||
server = Server.default;
|
||||
mode = 0;
|
||||
blur = 0;
|
||||
size = 0.1;
|
||||
trigger = 120;
|
||||
dust = 0;
|
||||
back = 0;
|
||||
slope = 0;
|
||||
slope = 1;
|
||||
chorus = 0;
|
||||
harmonics = 2;
|
||||
depth = 2;
|
||||
|
@ -92,8 +90,9 @@ Granulator {
|
|||
pan = 0;
|
||||
track = 0.5;
|
||||
jitter = 0.25;
|
||||
loop = 0.0;
|
||||
grainamp = 0.75;
|
||||
amp = 0.75;
|
||||
loopamp = 0;
|
||||
speed = 1;
|
||||
triggerb = Bus.control(server, 1);
|
||||
pitchb = Bus.control(server, 1);
|
||||
buffer = Buffer.alloc(server, server.sampleRate * buflen, 1);
|
||||
|
@ -101,7 +100,7 @@ Granulator {
|
|||
\in, inb,
|
||||
\buffer, buffer,
|
||||
\record, 0,
|
||||
\triggerb, rectriggerb
|
||||
\rectriggerb, rectriggerb
|
||||
], server, \addToTail);
|
||||
triggersynth = Synth.new(\grain_trigger, [ \out, triggerb ]);
|
||||
pitchsynth = Synth.new(\grain_pitch, [ \out, pitchb, \triggerb, triggerb, \posb, posb ]);
|
||||
|
@ -116,27 +115,34 @@ Granulator {
|
|||
\pitchb, pitchb,
|
||||
\modb, modb,
|
||||
\size, size,
|
||||
\amp, grainamp
|
||||
\amp, amp
|
||||
],
|
||||
server);
|
||||
// loopsynth = Synth.new(
|
||||
// \grain_looper, [
|
||||
// \out, outb, \buffer, buffer, \triggerb, triggerb,
|
||||
// \speed, speed, \pan, pan, \amp, loop
|
||||
// ],
|
||||
// server);
|
||||
}
|
||||
|
||||
looping { | amp |
|
||||
loopamp = amp;
|
||||
loopsynth = Synth.new(
|
||||
\grain_looper, [
|
||||
\out, outb,
|
||||
\buffer, buffer,
|
||||
\rectriggerb, ~rectriggerb,
|
||||
\speed, speed, \pan, pan, \amp, loopamp
|
||||
],
|
||||
server
|
||||
);
|
||||
}
|
||||
|
||||
reset { | newbuflen |
|
||||
var newbuf = Buffer.alloc(server, server.sampleRate * newbuflen, 1), oldbuf = buffer;
|
||||
"reset was called".postln;
|
||||
recorder.set(\buffer, newbuf);
|
||||
grains.set(\buffer, newbuf);
|
||||
loopsynth.set(\buffer, newbuf);
|
||||
buffer = newbuf;
|
||||
oldbuf.free;
|
||||
}
|
||||
|
||||
mode { ^mode }
|
||||
record { ^record }
|
||||
mix { ^mix }
|
||||
gain { ^gain }
|
||||
|
@ -156,10 +162,9 @@ Granulator {
|
|||
pan { ^pan }
|
||||
track { ^track }
|
||||
jitter { ^jitter }
|
||||
loop { ^loop }
|
||||
grainamp { ^grainamp }
|
||||
amp { ^amp }
|
||||
loopamp { ^loopamp }
|
||||
|
||||
mode_ { | v | mode = v; } // todo - playback mode in this class?
|
||||
record_ { | v | record = v; recorder.set(\record, v);}
|
||||
mix_ { | v | mix = v; recorder.set(\mix, v); }
|
||||
gain_ { | v | gain = v; grains.set(\amp, v); }
|
||||
|
@ -179,6 +184,6 @@ Granulator {
|
|||
crate_ { | v | crate = v; pitchsynth.set(\crate, v); }
|
||||
detune_ { | v | detune = v; pitchsynth.set(\detune, v); }
|
||||
pitch_ { | v | pitch = v; pitchsynth.set(\pitch, v); }
|
||||
loop_ { | v | loop = v; loopsynth.set(\amp, v); }
|
||||
grainamp_ { | v | grainamp = v; grains.set(\amp, v); }
|
||||
amp_ { | v | amp = v; grains.set(\amp, v); }
|
||||
loopamp_ { | v | loopamp = v; loopsynth.set(\amp, v); }
|
||||
}
|
Loading…
Reference in New Issue