multigrain/interface.scd

238 lines
7.5 KiB
Plaintext
Raw Permalink Normal View History

2023-04-09 02:12:36 +00:00
(
2023-09-30 08:11:55 +00:00
~to = TouchOSC(~touchosc_ip, 9000);
2023-04-09 02:12:36 +00:00
~tracknum = 0;
~granulator = ~granulators[0];
2023-04-09 02:12:36 +00:00
~speedlock = 0;
~speedquant = 0;
2023-04-09 02:12:36 +00:00
OSCdef.freeAll;
~to.button('/grains/reset', 0, { | v |
2023-04-09 02:12:36 +00:00
if( v > 0, {
~buflen = ~to.v('/grains/buflen');
(0..3).do({|i|
~granulators[i].reset(~buflen);
});
2023-04-09 02:12:36 +00:00
});
});
2023-09-23 05:05:33 +00:00
~quantspeed = { |v| 2.pow((v * 4 + 0.5).round - 5) };
// control ganging is hella laggy, do it in TouchOSC
2023-09-23 05:05:33 +00:00
~setspeed = { | track, v |
var speed, qv = if(~speedquant > 0, { ~quantspeed.value(v) }, { v });
speed = qv / ~buflen;
if(~speedlock > 0, {
(0..3).do({|n|
~possynths[n].set(\speed, speed);
if( n != track, {
var url = ("/grains/speed" ++ n).asSymbol;
~to.s_(url, v);
});
});
},
{ ~possynths[track].set(\speed, speed) });
};
// setrecord: toggles record on (1) or off (0) for a track, and also sets the
// track's input mix to 0 so that it doesn't start fadeing out. If the track
// is the currently selected track, set its touchosc control to 0.
// keeps the level for each track in an array and resets it
~mixlevel = Array.new(4);
(0..3).do({~mixlevel.add(0.25)});
~setrecord = { | track, v |
~granulators[track].record_(v);
if(v == 0, {
~mixlevel[track] = ~granulators[track].mix;
~granulators[track].mix_(0);
},
{
~granulators[track].mix_(~mixlevel[track]);
});
if( track == ~tracknum, { ~to.v_('/track/mix', ~granulators[track].mix); })
};
2023-04-09 02:12:36 +00:00
// note: ~buflen is the variable for buffer length, which only gets set to
// ~to.v('/grains/buflen') when the buffer is reset with the clear button
~to.slider('/grains/buflen', ~buflen, TouchOSCScale(0.1, 10.0), {});
~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/mode2', 0, { |v| ~granulators[2].mode_(v); ~setmode.value(2, v) });
~to.button('/grains/mode3', 0, { |v| ~granulators[3].mode_(v); ~setmode.value(3, v) });
2023-04-09 02:12:36 +00:00
~to.slider('/grains/speed0', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(0, v) });
~to.slider('/grains/speed1', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(1, v) });
~to.slider('/grains/speed2', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(2, v) });
~to.slider('/grains/speed3', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(3, v) });
~to.slider('/grains/passthrough', 0.75, TouchOSCScale(0, 1), { |v| ~grainmixer.set(\passthrough, v) });
2023-04-09 02:12:36 +00:00
~to.slider('/grains/mix0', 0.5, TouchOSCScale(0, 1), { | v | ~granulators[0].gain_(v) });
~to.slider('/grains/mix1', 0.5, TouchOSCScale(0, 1),{ | v | ~granulators[1].gain_(v) });
~to.slider('/grains/mix2', 0.5, TouchOSCScale(0, 1),{ | v | ~granulators[2].gain_(v) });
~to.slider('/grains/mix3', 0.5, TouchOSCScale(0, 1),{ | v | ~granulators[3].gain_(v) });
2023-04-09 02:12:36 +00:00
~to.button('/grains/lock', 0, { |v| ~speedlock = v });
~to.button('/grains/quant', 0, { |v| ~speedquant = v });
// Page 2: track
2023-09-30 08:21:29 +00:00
~to.xy('/track/triggersize', [ 100, 0.125 ], TouchOSCScale(0, 400), TouchOSCScale(0, 1.5), { |v|
~granulator.trigger_(v[0]);
~granulator.size_(v[1]);
});
~to.slider('/track/blur', 0, TouchOSCScale(0, 0.25), { |v| ~granulator.blur_(v) });
~to.button('/track/dust', 0, { |v| ~granulator.dust_(v) });
~to.button('/track/back', 0, { |v| ~granulator.back_(v)});
2023-09-23 05:06:26 +00:00
~to.button('/track/slope', 0, { |v| ~granulator.slope_(v) });
~to.button('/track/chorus', 0, { |v| ~granulator.chorus_(v) });
~to.slider('/track/detune', 0, TouchOSCScale(0, 0.059), { |v| ~granulator.detune_(v) });
~to.slider('/track/pitch', 0, TouchOSCScale(-2, 2), { |v| ~granulator.pitch_(v.round) });
~to.slider('/track/mix', 0.25, TouchOSCScale(0, 1), { |v| ~granulator.mix_(v); });
~to.slider('/track/pan', 0, TouchOSCScale(-1, 1), { |v| ~granulator.pan_(v) });
~to.slider('/track/track', 0.5, TouchOSCScale(-1, 1), { |v| ~granulator.track_(v) });
~to.slider('/track/jitter', 0.25, TouchOSCScale(0, 1), { |v| ~granulator.jitter_(v) });
~to.button('/trackselect', 0, { |v|
~tracknum = v.asInteger;
~granulator = ~granulators[~tracknum];
~to.v_('/track/triggersize', [~granulator.trigger, ~granulator.size]);
~to.v_('/track/blur', ~granulator.blur);
~to.v_('/track/mix', ~granulator.mix);
~to.v_('/track/pan', ~granulator.pan);
~to.v_('/track/track', ~granulator.track);
~to.v_('/track/jitter', ~granulator.jitter);
~to.v_('/track/dust', ~granulator.dust);
~to.v_('/track/slope', ~granulator.slope);
~to.v_('/track/back', ~granulator.back);
~to.v_('/track/chorus', ~granulator.chorus);
~to.v_('/track/detune', ~granulator.detune);
~to.v_('/track/pitch', ~granulator.pitch);
});
2023-09-30 08:11:55 +00:00
// 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) });
2023-04-09 02:12:36 +00:00
~to.slider(
'/fx/filterfreq',
10000, TouchOSCScaleExp(100, 10000), { |v| ~filter.set(\freq, v) }
);
2023-04-09 02:12:36 +00:00
~to.slider('/fx/grainmix', 1.0, TouchOSCScale(0, 1), { |v| ~grainmixer.set(\grains, v) } );
~to.slider('/fx/filtermix', 0.8, TouchOSCScale(0, 1), { |v| ~filter.set(\amp, v) } );
~to.button('/fx/filtermoda', 1, { |v| ~filtermod.set(\a, v) });
~to.button('/fx/filtermodb', 0, { |v| ~filtermod.set(\b, v) });
~to.button('/fx/filtermodc', 0, { |v| ~filtermod.set(\c, v) });
~to.slider('/fx/delay', 0.2,TouchOSCScale(0, 1), { |v| ~delay.set(\delaytime, v) } );
~to.slider('/fx/decay', 1, TouchOSCScale(0, 5), { |v| ~delay.set(\decaytime, v) } );
~to.slider('/fx/delaymix', 0.2, TouchOSCScale(0, 1), { |v| ~delay.set(\amp, v) } );
~to.slider('/fx/reverbwet', 0.33,TouchOSCScale(0, 1), { |v| ~reverb.set(\mix, v) } );
~to.slider('/fx/reverbroom', 0.5,TouchOSCScale(0, 1), { |v| ~reverb.set(\room, v) } );
~to.slider('/fx/reverbdamp', 0.5,TouchOSCScale(0, 1), { |v| ~reverb.set(\damp, v) } );
~to.slider('/fx/reverbmix', 0.2, TouchOSCScale(0, 1), { |v| ~reverb.set(\amp, v) } );
// note - the three LFOs have different rate ranges
~to.slider('/lfos/afreq', 0.5,TouchOSCScale(0.001, 2), { |v| ~lfoa.set(\freq, v) } );
~to.slider('/lfos/aamp', 0, TouchOSCScale(0, 1), { |v| ~lfoa.set(\amp, v) });
~to.slider('/lfos/bfreq', 0.5,TouchOSCScale(0.01, 20), { |v| ~lfob.set(\freq, v) } );
~to.slider('/lfos/bamp', 0, TouchOSCScale(0, 1), { |v| ~lfob.set(\amp, 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) });
2023-09-30 08:21:29 +00:00
// 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)
});
2023-04-09 02:12:36 +00:00
)