Quantised speed controls are back

feature-synchronisation
bombinans 2023-10-25 15:19:31 +11:00
parent 4f4132fdcc
commit 9f7b83a44e
2 changed files with 29 additions and 35 deletions

View File

@ -14,6 +14,7 @@
~granulators = Array.new(4); ~granulators = Array.new(4);
~grainmodes = [ 0, 0, 0, 0 ]; // keep track of mode so don't swap if not needed ~grainmodes = [ 0, 0, 0, 0 ]; // keep track of mode so don't swap if not needed
~speeds = [ 1, 1, 1, 1 ]; // hacky speed quantisation
~posb = Array.new(4); ~posb = Array.new(4);
~rectriggerb = Array.new(4); ~rectriggerb = Array.new(4);
~patterns = Array.new(4); ~patterns = Array.new(4);
@ -35,14 +36,10 @@
}); });
// set up the Patterns which drive the position synths // set up the Patterns which drive the position synths
(0..3).do({ |i| (0..3).do({ |i|
~patterns.add(~makePattern.value(i, 0)); ~patterns.add(~makePattern.value(i, 0, ~speeds[i]));
}); });
// play the four patterns
// to-do - will these need separate tempoclocks?
(0..3).do({|i| (0..3).do({|i|
~players.add(~patterns[i].play(~tc, quant: ~beatsperbar)) ~players.add(~patterns[i].play(~tc, quant: ~beatsperbar))
}); });
@ -53,15 +50,29 @@
~grainmodes[track] = mode; ~grainmodes[track] = mode;
~players[track].stop; ~players[track].stop;
~patterns[track].free; ~patterns[track].free;
~patterns[track] = ~makePattern.value(track, mode); ~patterns[track] = ~makePattern.value(track, mode, ~speeds[track]);
~players[track] = ~patterns[track].play(~tc, quant: ~beatsperbar); ~players[track] = ~patterns[track].play(~tc, quant: ~beatsperbar);
}); });
}; };
~setspeed = {
arg track, speed;
[ "setspeed", track, speed ].postln;
if( ~speeds[track] != speed, {
~speeds[track] = speed;
~players[track].stop;
~patterns[track].free;
~patterns[track] = ~makePattern.value(track, ~grainmodes[track], ~speeds[track]);
~players[track] = ~patterns[track].play(~tc, quant: ~beatsperbar);
});
};
~makePattern = { ~makePattern = {
arg track, mode; arg track, mode, speed;
var ptrig, ppos, synth = ~modes[mode][1]; var ptrig, ppos, synth = ~modes[mode][1];
[ "makePattern", ~track, ~buflen ].postln; // note: trigger is going off the base tempoclock, not the playback speed - I think this is
// the right thing to do but I'm not sure yet
ptrig = Pbind( ptrig = Pbind(
\instrument, \trigger, \instrument, \trigger,
\dur, ~beatsperbar, \dur, ~beatsperbar,
@ -69,8 +80,8 @@
); );
ppos = Pbind( ppos = Pbind(
\instrument, synth, \instrument, synth,
\dur, ~beatsperbar, \dur, ~beatsperbar / speed,
\length, ~buflen, \length, ~buflen / speed,
\out, ~posb[track] \out, ~posb[track]
); );
Ppar([ptrig, ppos]); Ppar([ptrig, ppos]);

View File

@ -36,25 +36,6 @@ OSCdef.freeAll;
}; };
// control ganging is hella laggy, do it in TouchOSC
// ~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 // 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 // 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. // is the currently selected track, set its touchosc control to 0.
@ -89,11 +70,13 @@ OSCdef.freeAll;
~to.button('/grains/mode1', 0, { |v| ~setmode.value(1, v) }); ~to.button('/grains/mode1', 0, { |v| ~setmode.value(1, v) });
~to.button('/grains/mode2', 0, { |v| ~setmode.value(2, v) }); ~to.button('/grains/mode2', 0, { |v| ~setmode.value(2, v) });
~to.button('/grains/mode3', 0, { |v| ~setmode.value(3, v) }); ~to.button('/grains/mode3', 0, { |v| ~setmode.value(3, v) });
//
// ~to.slider('/grains/speed0', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(0, v) }); // needs work
// ~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/speed0', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(0, ~quantspeed.value(v)) });
// ~to.slider('/grains/speed3', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(3, v) }); ~to.slider('/grains/speed1', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(1, ~quantspeed.value(v)) });
~to.slider('/grains/speed2', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(2, ~quantspeed.value(v)) });
~to.slider('/grains/speed3', 1, TouchOSCScale(0, 2), { |v| ~setspeed.value(3, ~quantspeed.value(v)) });
~to.slider('/grains/passthrough', 0.75, TouchOSCScale(0, 1), { |v| ~grainmixer.set(\passthrough, v) }); ~to.slider('/grains/passthrough', 0.75, TouchOSCScale(0, 1), { |v| ~grainmixer.set(\passthrough, v) });
@ -105,7 +88,7 @@ OSCdef.freeAll;
~to.button('/grains/lock', 0, { |v| ~speedlock = v }); ~to.button('/grains/lock', 0, { |v| ~speedlock = v });
~to.button('/grains/quant', 0, { |v| ~speedquant = v }); ~to.button('/grains/quant', 1, { |v| ~speedquant = v });
~to.button('/grains/metronome', 0, { |v| ~to.button('/grains/metronome', 0, { |v|
if( v == 1, { if( v == 1, {