Compare commits

..

5 Commits

Author SHA1 Message Date
bombinans e1c1a5b82d Very rough metronome 2023-09-30 18:21:29 +10:00
bombinans 9ba8700d8a A few little bugs cleaned up 2023-09-30 18:11:55 +10:00
bombinans de332e6c48 Fixed position buffer amplitude bug 2023-09-30 17:24:29 +10:00
bombinans e22b46066a Removed redundant interface code block 2023-09-30 17:24:15 +10:00
bombinans 1f6210c6d8 Fixed reset bug 2023-09-30 17:24:01 +10:00
3 changed files with 58 additions and 30 deletions

View File

@ -1,7 +1,7 @@
( (
~to = TouchOSC("192.168.0.209", 9000); ~to = TouchOSC(~touchosc_ip, 9000);
~tracknum = 0; ~tracknum = 0;
@ -15,12 +15,9 @@ OSCdef.freeAll;
~to.button('/grains/reset', 0, { | v | ~to.button('/grains/reset', 0, { | v |
if( v > 0, { if( v > 0, {
var sp = ~to.v('/grains/speed')[0];
~buflen = ~to.v('/grains/buflen'); ~buflen = ~to.v('/grains/buflen');
(0..3).do({|i| (0..3).do({|i|
var speed = ~to.v('/grains/speed' ++ i);
~granulators[i].reset(~buflen); ~granulators[i].reset(~buflen);
~possynths[i].set(\speed, speed / ~buflen);
}); });
}); });
}); });
@ -33,7 +30,6 @@ OSCdef.freeAll;
~setspeed = { | track, v | ~setspeed = { | track, v |
var speed, qv = if(~speedquant > 0, { ~quantspeed.value(v) }, { v }); var speed, qv = if(~speedquant > 0, { ~quantspeed.value(v) }, { v });
speed = qv / ~buflen; speed = qv / ~buflen;
[ "setspeed", v, qv, speed ].postln;
if(~speedlock > 0, { if(~speedlock > 0, {
(0..3).do({|n| (0..3).do({|n|
~possynths[n].set(\speed, speed); ~possynths[n].set(\speed, speed);
@ -58,7 +54,6 @@ OSCdef.freeAll;
~setrecord = { | track, v | ~setrecord = { | track, v |
~granulators[track].record_(v); ~granulators[track].record_(v);
[ v, track, ~tracknum ].postln;
if(v == 0, { if(v == 0, {
~mixlevel[track] = ~granulators[track].mix; ~mixlevel[track] = ~granulators[track].mix;
~granulators[track].mix_(0); ~granulators[track].mix_(0);
@ -77,15 +72,6 @@ OSCdef.freeAll;
~to.slider('/grains/buflen', ~buflen, TouchOSCScale(0.1, 10.0), {}); ~to.slider('/grains/buflen', ~buflen, TouchOSCScale(0.1, 10.0), {});
~to.button('/grains/record0', 0, { | v | ~setrecord.value(0, v) });
~to.button('/grains/record1', 0, { | v | ~setrecord.value(1, v) });
~to.button('/grains/record2', 0, { | v | ~setrecord.value(2, v) });
~to.button('/grains/record3', 0, { | v | ~setrecord.value(3, v) });
~to.button('/grains/mode0', 0, { |v| ~granulators[0].mode_(v); ~setmode.value(0, v) }); ~to.button('/grains/mode0', 0, { |v| ~granulators[0].mode_(v); ~setmode.value(0, v) });
~to.button('/grains/mode1', 0, { |v| ~granulators[1].mode_(v); ~setmode.value(1, v) }); ~to.button('/grains/mode1', 0, { |v| ~granulators[1].mode_(v); ~setmode.value(1, v) });
~to.button('/grains/mode2', 0, { |v| ~granulators[2].mode_(v); ~setmode.value(2, v) }); ~to.button('/grains/mode2', 0, { |v| ~granulators[2].mode_(v); ~setmode.value(2, v) });
@ -112,7 +98,7 @@ OSCdef.freeAll;
// Page 2: track // Page 2: track
~to.xy('/track/triggersize', [ 320, 0.25 ], TouchOSCScale(0, 640), TouchOSCScale(0, 0.5), { |v| ~to.xy('/track/triggersize', [ 100, 0.125 ], TouchOSCScale(0, 400), TouchOSCScale(0, 1.5), { |v|
~granulator.trigger_(v[0]); ~granulator.trigger_(v[0]);
~granulator.size_(v[1]); ~granulator.size_(v[1]);
}); });
@ -152,6 +138,13 @@ OSCdef.freeAll;
~to.v_('/track/pitch', ~granulator.pitch); ~to.v_('/track/pitch', ~granulator.pitch);
}); });
// set up the record buttons on the front page now because /track/mix has been defined
~to.button('/grains/record0', 0, { | v | ~setrecord.value(0, v) });
~to.button('/grains/record1', 0, { | v | ~setrecord.value(1, v) });
~to.button('/grains/record2', 0, { | v | ~setrecord.value(2, v) });
~to.button('/grains/record3', 0, { | v | ~setrecord.value(3, v) });
@ -193,6 +186,52 @@ OSCdef.freeAll;
~to.slider('/lfos/cfreq', 0.5,TouchOSCScale(0.1, 200), { |v| ~lfoc.set(\freq, v) } ); ~to.slider('/lfos/cfreq', 0.5,TouchOSCScale(0.1, 200), { |v| ~lfoc.set(\freq, v) } );
~to.slider('/lfos/camp', 0, TouchOSCScale(0, 1), { |v| ~lfoc.set(\amp, v) }); ~to.slider('/lfos/camp', 0, TouchOSCScale(0, 1), { |v| ~lfoc.set(\amp, v) });
// metronome code here is a bit gross but easier
~beatsperbar = 4;
~bps = ~beatsperbar / ~buflen;
~tc = TempoClock.new(~bps);
SynthDef(\metronome, {
arg out=0, amp=1, pan=0, filter=1000, atk=0.01, rel=0.1;
var sig, env;
env = EnvGen.kr(Env.perc(atk, rel, amp), doneAction: Done.freeSelf);
sig = HPF.ar(WhiteNoise.ar(), filter);
Out.ar(out, Pan2.ar(sig * env, pan));
}
).add;
~metrob = Bus.audio(s, 2);
~metromix = SynthDef(\metromix, {
arg in=1, out=0, amp=1;
Out.ar(out, amp * In.ar(in, 2));
}).play(s, [\in, ~metrob, \out, 0, \amp, 0]);
~metronome = Pbind(
\instrument, \metronome,
\dur, 1,
\amp, 0.5,
\pan, 0,
\out, ~metrob
).play(~tc);
~to.button('/grains/metronome', 0, { |v|
// reset tempo when turning metronome on
if( v == 1, {
~bps = ~beatsperbar / ~buflen;
~tc.tempo_(~bps);
});
// FIXME
~metromix.set(\amp, v)
});
) )

View File

@ -20,6 +20,7 @@ Routine.run({
s.sync; s.sync;
("./effects.scd").loadRelative; ("./effects.scd").loadRelative;
s.sync; s.sync;
~touchosc_ip = "192.168.0.209";
("./interface.scd").loadRelative; ("./interface.scd").loadRelative;
}); });
) )
@ -27,14 +28,3 @@ Routine.run({
("./synths.scd").loadRelative;
Granulator.init(s);
("./control.scd").loadRelative;
("./granulator.scd").loadRelative;
("./effects.scd").loadRelative;
("./interface.scd").loadRelative;

View File

@ -14,12 +14,12 @@ SynthDef(\pos_sine, {
SynthDef(\pos_saw, { SynthDef(\pos_saw, {
arg out, speed=1; arg out, speed=1;
Out.kr(out, 0.5 + LFSaw.kr(speed, 0, 0.5, 0.5)); Out.kr(out, 0.5 + LFSaw.kr(speed, 0, 0.5, 0));
}).add; }).add;
SynthDef(\pos_reverse, { SynthDef(\pos_reverse, {
arg out, speed=1; arg out, speed=1;
Out.kr(out, 0.5 - LFSaw.kr(speed, 0, 0.5, 0.5)); Out.kr(out, 0.5 - LFSaw.kr(speed, 0, 0.5, 0));
}).add; }).add;
SynthDef(\pos_step, { SynthDef(\pos_step, {
@ -43,5 +43,4 @@ SynthDef(\trigger, {
Out.kr(out, Impulse.kr(0)) Out.kr(out, Impulse.kr(0))
}).add; }).add;
) )