Compare commits
5 Commits
bugfix-res
...
main
Author | SHA1 | Date |
---|---|---|
bombinans | 1ce69c48b6 | |
bombinans | 5ba3416b1f | |
bombinans | e25cd1dd53 | |
bombinans | ec7c859f36 | |
bombinans | c7138325c8 |
|
@ -1,22 +1,22 @@
|
||||||
|
|
||||||
|
|
||||||
Granulator {
|
Granulator {
|
||||||
var <buflen, <inb, <outb, <>posb, <triggerb, <pitchb, <rectriggerb, <modb, <buffer, <recorder, <grains, <triggersynth, <pitchsynth, server, mode, record, gain, mix, speed, trigger, size, blur, dust, slope, back, chorus, detune, pitch, pan, track, jitter;
|
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 {
|
*init {
|
||||||
SynthDef(
|
SynthDef(
|
||||||
\grain_record,
|
\grain_record,
|
||||||
{
|
{
|
||||||
arg in = 2, trigger = 0, buffer = 0, mix = 0.5, record = 0.0;
|
arg in = 2, rectriggerb = 0, buffer = 0, mix = 0.5, record = 0.0;
|
||||||
var insig = record * In.ar(in, 1), trigsig = In.kr(trigger, 1);
|
var insig = record * In.ar(in, 1), rectrigsig = In.kr(rectriggerb, 1);
|
||||||
RecordBuf.ar(insig, buffer, 0, mix, 1 - mix, loop: 1, trigger: trigsig)
|
RecordBuf.ar(insig, buffer, 0, mix, 1 - mix, loop: 1, trigger: rectrigsig)
|
||||||
}
|
}
|
||||||
).add();
|
).add();
|
||||||
|
|
||||||
SynthDef(
|
SynthDef(
|
||||||
\grain_play,
|
\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;
|
var pitch, trigger, pos, pans, grains;
|
||||||
trigger = In.kr(triggerb);
|
trigger = In.kr(triggerb);
|
||||||
pitch = In.kr(pitchb);
|
pitch = In.kr(pitchb);
|
||||||
|
@ -30,14 +30,14 @@ Granulator {
|
||||||
SynthDef(
|
SynthDef(
|
||||||
\grain_pitch,
|
\grain_pitch,
|
||||||
{
|
{
|
||||||
arg out, posb, triggerb, track=1, dir=1, detune=0.0, chorus=0, harmonics=2, pitch=0;
|
arg out, posb, triggerb, track=1, dir=1, detune=0.0, chorus=0, depth=2, crate=128, harmonics=2, pitch=0;
|
||||||
var tracking, base, chor, det, csig, dsig;
|
var tracking, base, chor, det, csig, dsig;
|
||||||
csig = Latch.kr(WhiteNoise.kr(), In.kr(triggerb));
|
csig = Latch.kr(SinOsc.kr(crate), In.kr(triggerb));
|
||||||
dsig = Latch.kr(WhiteNoise.kr(), In.kr(triggerb));
|
dsig = Latch.kr(WhiteNoise.kr(), In.kr(triggerb));
|
||||||
tracking = Schmidt.kr(Slope.kr(posb), 0, 0) * 2 - 1;
|
tracking = Schmidt.kr(Slope.kr(posb), 0, 0) * 2 - 1;
|
||||||
base = 2.pow(pitch) * dir * (track * tracking + (1 - track));
|
base = 2.pow(pitch) * dir * (track * tracking + (1 - track));
|
||||||
det = detune * dsig + 1;
|
det = detune * dsig + 1;
|
||||||
chor = chorus * harmonics.pow((csig * 2).round) + (1 - chorus);
|
chor = chorus * harmonics.pow((csig * depth).round) + (1 - chorus);
|
||||||
Out.kr(out, base * chor * det);
|
Out.kr(out, base * chor * det);
|
||||||
}
|
}
|
||||||
).add();
|
).add();
|
||||||
|
@ -49,6 +49,15 @@ Granulator {
|
||||||
Out.kr(out, (Impulse.kr(freq) * (1 - dust)) + (Dust.kr(freq) * dust));
|
Out.kr(out, (Impulse.kr(freq) * (1 - dust)) + (Dust.kr(freq) * dust));
|
||||||
}
|
}
|
||||||
).add();
|
).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 |
|
*new { | buflen, inb, outb, posb, rectriggerb |
|
||||||
|
@ -65,20 +74,25 @@ Granulator {
|
||||||
posb = aposb;
|
posb = aposb;
|
||||||
rectriggerb = arectriggerb;
|
rectriggerb = arectriggerb;
|
||||||
server = Server.default;
|
server = Server.default;
|
||||||
mode = 0;
|
|
||||||
blur = 0;
|
blur = 0;
|
||||||
size = 0.1;
|
size = 0.1;
|
||||||
trigger = 120;
|
trigger = 120;
|
||||||
dust = 0;
|
dust = 0;
|
||||||
back = 0;
|
back = 0;
|
||||||
slope = 0;
|
slope = 1;
|
||||||
chorus = 0;
|
chorus = 0;
|
||||||
|
harmonics = 2;
|
||||||
|
depth = 2;
|
||||||
|
crate = 128;
|
||||||
detune = 0;
|
detune = 0;
|
||||||
pitch = 0;
|
pitch = 0;
|
||||||
mix = 0.25;
|
mix = 0.25;
|
||||||
pan = 0;
|
pan = 0;
|
||||||
track = 0.5;
|
track = 0.5;
|
||||||
jitter = 0.25;
|
jitter = 0.25;
|
||||||
|
amp = 0.75;
|
||||||
|
loopamp = 0;
|
||||||
|
speed = 1;
|
||||||
triggerb = Bus.control(server, 1);
|
triggerb = Bus.control(server, 1);
|
||||||
pitchb = Bus.control(server, 1);
|
pitchb = Bus.control(server, 1);
|
||||||
buffer = Buffer.alloc(server, server.sampleRate * buflen, 1);
|
buffer = Buffer.alloc(server, server.sampleRate * buflen, 1);
|
||||||
|
@ -86,34 +100,49 @@ Granulator {
|
||||||
\in, inb,
|
\in, inb,
|
||||||
\buffer, buffer,
|
\buffer, buffer,
|
||||||
\record, 0,
|
\record, 0,
|
||||||
\trigger, rectriggerb
|
\rectriggerb, rectriggerb
|
||||||
], server, \addToTail);
|
], server, \addToTail);
|
||||||
triggersynth = Synth.new(\grain_trigger, [ \out, triggerb ]);
|
triggersynth = Synth.new(\grain_trigger, [ \out, triggerb ]);
|
||||||
pitchsynth = Synth.new(\grain_pitch, [ \out, pitchb, \triggerb, triggerb, \posb, posb ]);
|
pitchsynth = Synth.new(\grain_pitch, [ \out, pitchb, \triggerb, triggerb, \posb, posb ]);
|
||||||
grains = Synth.new(
|
grains = Synth.new(
|
||||||
\grain_play,
|
\grain_play,
|
||||||
[
|
[
|
||||||
\out, outb,
|
\out, outb,
|
||||||
\buffer, buffer,
|
\buffer, buffer,
|
||||||
\blen, buflen,
|
\blen, buflen,
|
||||||
\posb, posb,
|
\posb, posb,
|
||||||
\triggerb, triggerb,
|
\triggerb, triggerb,
|
||||||
\pitchb, pitchb,
|
\pitchb, pitchb,
|
||||||
\modb, modb,
|
\modb, modb,
|
||||||
\size, 0.1
|
\size, size,
|
||||||
],
|
\amp, amp
|
||||||
server);
|
],
|
||||||
|
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 |
|
reset { | newbuflen |
|
||||||
var newbuf = Buffer.alloc(server, server.sampleRate * newbuflen, 1), oldbuf = buffer;
|
var newbuf = Buffer.alloc(server, server.sampleRate * newbuflen, 1), oldbuf = buffer;
|
||||||
|
"reset was called".postln;
|
||||||
recorder.set(\buffer, newbuf);
|
recorder.set(\buffer, newbuf);
|
||||||
grains.set(\buffer, newbuf);
|
grains.set(\buffer, newbuf);
|
||||||
|
loopsynth.set(\buffer, newbuf);
|
||||||
buffer = newbuf;
|
buffer = newbuf;
|
||||||
oldbuf.free;
|
oldbuf.free;
|
||||||
}
|
}
|
||||||
|
|
||||||
mode { ^mode }
|
|
||||||
record { ^record }
|
record { ^record }
|
||||||
mix { ^mix }
|
mix { ^mix }
|
||||||
gain { ^gain }
|
gain { ^gain }
|
||||||
|
@ -122,6 +151,9 @@ Granulator {
|
||||||
size { ^size }
|
size { ^size }
|
||||||
blur { ^blur }
|
blur { ^blur }
|
||||||
chorus { ^chorus }
|
chorus { ^chorus }
|
||||||
|
harmonics { ^harmonics }
|
||||||
|
depth { ^depth }
|
||||||
|
crate { ^crate }
|
||||||
detune { ^detune }
|
detune { ^detune }
|
||||||
pitch { ^pitch }
|
pitch { ^pitch }
|
||||||
dust { ^dust }
|
dust { ^dust }
|
||||||
|
@ -130,13 +162,15 @@ Granulator {
|
||||||
pan { ^pan }
|
pan { ^pan }
|
||||||
track { ^track }
|
track { ^track }
|
||||||
jitter { ^jitter }
|
jitter { ^jitter }
|
||||||
|
amp { ^amp }
|
||||||
|
loopamp { ^loopamp }
|
||||||
|
|
||||||
mode_ { | v | mode = v; } // todo - playback mode in this class?
|
|
||||||
record_ { | v | record = v; recorder.set(\record, v);}
|
record_ { | v | record = v; recorder.set(\record, v);}
|
||||||
mix_ { | v | mix = v; recorder.set(\mix, v); }
|
mix_ { | v | mix = v; recorder.set(\mix, v); }
|
||||||
gain_ { | v | gain = v; grains.set(\amp, v); }
|
gain_ { | v | gain = v; grains.set(\amp, v); }
|
||||||
size_ { | v | size = v; grains.set(\size, v); }
|
size_ { | v | size = v; grains.set(\size, v); }
|
||||||
pan_ { | v | pan = v; grains.set(\pan, v); }
|
pan_ { | v | pan = v; grains.set(\pan, v); }
|
||||||
|
speed_ { | v | speed = v; loopsynth.set(\speed, v); }
|
||||||
track_ { | v | track = v; grains.set(\track, v); }
|
track_ { | v | track = v; grains.set(\track, v); }
|
||||||
jitter_ { | v | jitter = v; grains.set(\jitter, v); }
|
jitter_ { | v | jitter = v; grains.set(\jitter, v); }
|
||||||
blur_ { | v | blur = v; grains.set(\blur, v); }
|
blur_ { | v | blur = v; grains.set(\blur, v); }
|
||||||
|
@ -145,7 +179,11 @@ Granulator {
|
||||||
slope_ { | v | slope = v; pitchsynth.set(\track, v); }
|
slope_ { | v | slope = v; pitchsynth.set(\track, v); }
|
||||||
back_ { | v | back = v; pitchsynth.set(\dir, if( v > 0, { -1 }, { 1 })); }
|
back_ { | v | back = v; pitchsynth.set(\dir, if( v > 0, { -1 }, { 1 })); }
|
||||||
chorus_ { | v | chorus = v; pitchsynth.set(\chorus, v); }
|
chorus_ { | v | chorus = v; pitchsynth.set(\chorus, v); }
|
||||||
|
harmonics_ { | v | harmonics = v; pitchsynth.set(\harmonics, v); }
|
||||||
|
depth_ { | v | depth = v; pitchsynth.set(\depth, v); }
|
||||||
|
crate_ { | v | crate = v; pitchsynth.set(\crate, v); }
|
||||||
detune_ { | v | detune = v; pitchsynth.set(\detune, v); }
|
detune_ { | v | detune = v; pitchsynth.set(\detune, v); }
|
||||||
pitch_ { | v | pitch = v; pitchsynth.set(\pitch, v); }
|
pitch_ { | v | pitch = v; pitchsynth.set(\pitch, v); }
|
||||||
|
amp_ { | v | amp = v; grains.set(\amp, v); }
|
||||||
|
loopamp_ { | v | loopamp = v; loopsynth.set(\amp, v); }
|
||||||
}
|
}
|
Loading…
Reference in New Issue