About half of the touchosc stuff is now working

feature-multitrack
Mike Lynch 2023-04-09 15:10:04 +10:00
parent dfc508ee02
commit 7149bca2e3
4 changed files with 128 additions and 178 deletions

View File

@ -21,4 +21,33 @@
- modulate grain level in time with playback
- sync LFOs to playback
TODO list - touchosch
URL TO SC
grains/buflen Y Y
grains/reset Y Y
grains/record0..3 Y Y
grains/mode0..3 Y Y
grains/speed0..3 Y Y
grains/dust Y Y
grains/slope Y Y
grains/back Y Y
grains/trigger Y Y
grains/speedlock
grains/speedquant
grains/mix0 Y
grains/mix1 Y
grains/mix2 Y
grains/mix3 Y
trackselect
track/record
track/mode
track/speed
track/size
track/blur
track/mix
track/pan
track/track
track/jitter

View File

@ -4,67 +4,41 @@
OSCdef.freeAll;
~to.button('/record', 1, { | v | ~bufrecorder.set(\record, v) });
~to.button('/reset', 0, { | v |
if( v > 0, {
var sp = ~to.v('/grains/speed')[0];
~buflen = ~to.v('/grains/buflen');
~granulators.do({|g, i| g.reset(~buflen) }
~granulators.do({|g, i| g.reset(~buflen) });
~playbacklfo.set(\speed, sp / ~buflen);
});
});
~to.button('/track', 0, { |v|
var buffer = ~frippbuffers[v];
if( buffer.isNil.not, {
[ "set track to", v, buffer ].postln;
~bufrecorder.set(\record, 0.0);
~bufrecorder.set(\mix, 0.0); // stop unselected track fading out
~bufrecorder = ~bufrecorders[v];
~bufrecorder.set(\record, ~to.v('/record'));
~granulator = ~granulators[v];
~to.v_('/grainfx/mix', 0); // will always be 0 because we turned it off
// ~granulator.get(\amp, { | v | ~to.v_('/grainfx/gain', v) });
// ~granulator.get(\blur, { | v | ~to.v_('/grains/blur', v) });
// ~granulator.get(\size, { | v | ~to.v_('/grains/size', v) });
// ~granulator.get(\pan, { | v | ~to.v_('/grainfx/pan', v) });
// ~granulator.get(\track, { | v | ~to.v_('/grainfx/track', v) });
// ~granulator.get(\jitter, { | v | ~to.v_('/grainfx/jitter', v) });
// todo - set the grainmode based on what this one has
}, {
[ "Bad track index", v ].postln;
});
});
// ~to.button('/trackselect', 0, { |v|
// var buffer = ~frippbuffers[v];
// if( buffer.isNil.not, {
// [ "set track to", v, buffer ].postln;
// ~bufrecorder.set(\record, 0.0);
// ~bufrecorder.set(\mix, 0.0); // stop unselected track fading out
// ~bufrecorder = ~bufrecorders[v];
// ~bufrecorder.set(\record, ~to.v('/record'));
// ~granulator = ~granulators[v];
// ~to.v_('/grainfx/mix', 0); // will always be 0 because we turned it off
// // ~granulator.get(\amp, { | v | ~to.v_('/grainfx/gain', v) });
// // ~granulator.get(\blur, { | v | ~to.v_('/grains/blur', v) });
// // ~granulator.get(\size, { | v | ~to.v_('/grains/size', v) });
// // ~granulator.get(\pan, { | v | ~to.v_('/grainfx/pan', v) });
// // ~granulator.get(\track, { | v | ~to.v_('/grainfx/track', v) });
// // ~granulator.get(\jitter, { | v | ~to.v_('/grainfx/jitter', v) });
// // todo - set the grainmode based on what this one has
// }, {
// [ "Bad track index", v ].postln;
// });
// });
~to.slider('/feedback', 0, TouchOSCScale(0, 0.25), { |v|
~bufrecorder.set(\feedback, v) } );
~to.button('/grains/bpm', "~", {});
~tapper = TapBeats();
~to.button('/grains/tap', 0, { | v, t |
if( v > 0, {
~tapper.tap(t);
if( ~tapper.bpm.isNil.not, {
~to.v_('/grains/bpm', ~tapper.bpm.round(1));
})
})
});
~to.button('/grains/bpmsend', 0, { | v |
if( ~tapper.bpm.isNil.not, {
var bl = ~beatsperbar * ~tapper.bpm;
~to.v_('/grains/buflen', bl);
~to.v_('/reset', 1);
});
});
// 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
@ -72,75 +46,74 @@ OSCdef.freeAll;
~to.slider('/grains/buflen', ~buflen, TouchOSCScale(0.1, 10.0), {});
// this is a write-only control to display where the buffer playback is at
~to.button('/grains/record0', 0, { | v | ~granulators[0].record(v) });
~to.button('/grains/record1', 0, { | v | ~granulators[1].record(v) });
~to.button('/grains/record2', 0, { | v | ~granulators[2].record(v) });
~to.button('/grains/record3', 0, { | v | ~granulators[3].record(v) });
~to.slider('/grains/buffer', 0, TouchOSCScale(0, 1), {});
~to.button('/grains/mode0', 0, { |v| ~setmode.value(0, v) });
~to.button('/grains/mode1', 0, { |v| ~setmode.value(1, v) });
~to.button('/grains/mode2', 0, { |v| ~setmode.value(2, v) });
~to.button('/grains/mode3', 0, { |v| ~setmode.value(3, v) });
)
~to.xy('/grains/speed', [ 1, 120 ], TouchOSCScale(0, 2), TouchOSCScale(0, 640), { | v |
~playbacklfo.set(\speed, v[0] / ~buflen);
~trigger.set(\freq, v[1]);
});
(
~to.slider('/grains/speed0', 1, TouchOSCScale(0, 2), { |v| ~possynths[0].set(\speed, v) });
~to.slider('/grains/speed1', 1, TouchOSCScale(0, 2), { |v| ~possynths[1].set(\speed, v) });
~to.slider('/grains/speed2', 1, TouchOSCScale(0, 2), { |v| ~possynths[2].set(\speed, v) });
~to.slider('/grains/speed3', 1, TouchOSCScale(0, 2), { |v| ~possynths[3].set(\speed, v) });
)
~to.button('/grains/mode', 0, { |v|
var mode = ~modes[v];
if( mode.isNil.not, {
[ "granulator is", ~granulator ].postln;
~granulator.posb_(mode[1]);
~playbacklfo = mode[0];
~playbacklfob = mode[1];
~playbacklfo.set(\speed, ~to.v('/grains/speed')[0] / ~buflen);
}, {
[ "Bad mode index", v ].postln;
});
});
(
~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) });
)
~to.button('/grains/speedquant', 0, { |v|
});
(
~to.button('/grains/speedquant', 0, { |v| });
~to.slider('/grains/step', 4, TouchOSCScale(1, 8), { |v|
~grainstep.set(\steps, v.floor);
});
~to.slider('/grains/trigger', 120, TouchOSCScale(0, 640), { |v| ~trigger.set(\freq, v) });
~to.button('/grains/dust', 0, { |v| ~trigger.set(\dust, v) });
~to.button('/grains/back', 0, { |v| ~pitch.set(\dir, if( v > 0, { -1 }, { 1}))});
~to.button('/grains/slope', 1, { |v| ~pitch.set(\track, v) });
)
// Page 2: track
// ~to.slider('/track/mix', 0.25, TouchOSCScale(0, 1), { |v| ~granulator.mix_(v);
// });
~to.button('/grains/dust', 0, { |v| ~trigger.set(\dust, v) });
~to.slider('/grains/blur', 0, TouchOSCScale(0, 0.25), { |v| ~granulator.blur_(v) });
~to.slider('/grains/size', 0.1, TouchOSCScale(0, 0.5),{ |v| ~granulator.size_(v) });
// Page 2: grainfx
~to.slider('/grainfx/mix', 0.25, TouchOSCScale(0, 1), { |v| ~granulator.mix_(v);
});
~to.slider('/grainfx/gain', 0.5, TouchOSCScale(0, 1), { |v| ~granulator.gain_(v) } );
~to.slider('/grainfx/pt', 0.75, TouchOSCScale(0, 1), { |v| ~grainmixer.set(\passthrough, v) } );
~to.button('/grainfx/back', 0, { |v| ~pitch.set(\dir, if( v > 0, { -1 }, { 1}))});
~to.button('/grainfx/slope', 1, { |v| ~pitch.set(\track, v) });
~to.slider('/grainfx/pan', 0, TouchOSCScale(-1, 1), { |v| ~granulator.pan_(v) });
~to.slider('/grainfx/track', 0.5, TouchOSCScale(-1, 1), { |v| ~granulator.track_(v) });
~to.slider('/grainfx/jitter', 0.25, TouchOSCScale(0, 1), { |v| ~granulator.jitter_(v) });
~to.button('/grainfx/chorus', 0, { |v| ~pitch.set(\chorus, v) });
~to.slider('/grainfx/detune', 0, TouchOSCScale(0, 0.059), { |v| ~pitch.set(\detune, v) });
~to.slider('/grainfx/pitch', 0, TouchOSCScale(-2, 2), { |v| ~pitch.set(\pitch, v.round) });
~to.button('/grainfx/quant', 1, { |v|
// ~pitch.set(\quant, v);
// just re-call the value setter for harmonics when toggled
~to.v_('/grainfx/harmonics', ~to.v('/grainfx/harmonics'));
});
~to.slider('/grainfx/harmonics', 2, TouchOSCScale(0.1, 4), { |v|
if(~to.v('/grainfx/quant') > 0, {
~pitch.set(\harmonics, v.round);
},
{
~pitch.set(\harmonics, v);
});
});
// ~to.slider('/grainfx/pan', 0, TouchOSCScale(-1, 1), { |v| ~granulator.pan_(v) });
// ~to.slider('/grainfx/track', 0.5, TouchOSCScale(-1, 1), { |v| ~granulator.track_(v) });
// ~to.slider('/grainfx/jitter', 0.25, TouchOSCScale(0, 1), { |v| ~granulator.jitter_(v) });
//
//
// ~to.slider('/grains/blur', 0, TouchOSCScale(0, 0.25), { |v| ~granulator.blur_(v) });
// ~to.slider('/grains/size', 0.1, TouchOSCScale(0, 0.5),{ |v| ~granulator.size_(v) });
//
//
// ~to.button('/grainfx/chorus', 0, { |v| ~pitch.set(\chorus, v) });
// ~to.slider('/grainfx/detune', 0, TouchOSCScale(0, 0.059), { |v| ~pitch.set(\detune, v) });
// ~to.slider('/grainfx/pitch', 0, TouchOSCScale(-2, 2), { |v| ~pitch.set(\pitch, v.round) });
//
// ~to.button('/grainfx/quant', 1, { |v|
// // ~pitch.set(\quant, v);
// // just re-call the value setter for harmonics when toggled
// ~to.v_('/grainfx/harmonics', ~to.v('/grainfx/harmonics'));
// });
//
// ~to.slider('/grainfx/harmonics', 2, TouchOSCScale(0.1, 4), { |v|
// if(~to.v('/grainfx/quant') > 0, {
// ~pitch.set(\harmonics, v.round);
// },
// {
// ~pitch.set(\harmonics, v);
// });
// });
(
~to.slider(
'/fx/filterfreq',
10000, TouchOSCScaleExp(100, 10000), { |v| ~filter.set(\freq, v) }

View File

@ -13,10 +13,6 @@ Server.killAll;
Granulator.init(s);
(
// set up four position buffers with synths
@ -25,23 +21,20 @@ Granulator.init(s);
[ "reverse", \pos_reverse ],
[ "sine", \pos_sine ],
[ "step", \pos_step ],
[ "random", \pos_rand ]
[ "random", \pos_random ]
];
~granulators = Array.new(4);
~posb = Array.new(4);
~possynth = Array.new(4);
~possynths = Array.new(4);
(0..3).do({
var pb = Bus.control(s, 1), ps;
~posb.add(pb);
ps = Synth(\pos_saw, [ \out, pb ]);
~possynth.add(ps);
~possynths.add(ps);
});
)
(
(0..3).do({ |i|
var pb = ~posb.at(i);
@ -50,64 +43,24 @@ Granulator.init(s);
)
~granulators[1].record(1.0);
~possynth[0].set(\speed,200);
(
~setmode = {
arg track, mode;
var synth = ~modes[mode][1];
~possynths[track].get(\speed, { | speed |
~possynths[track].free;
~possynths[track] = Synth(synth, [\out, ~posb[track], \speed, speed]);
});
}
)
~granulators[0].gain(1);
("./interface.scd").loadRelative;
~g3 = Granulator.new(4, ~recordb, ~granulatorb, ~playbacklfob, ~triggerb, ~pitchb);
~g.recorder.set(\record, 1.0);
~makebuffers.value();
(
~bufrecorders = Array.new(~ntracks);
~frippbuffers.do({
| buffer, index |
~bufrecorders.add(Synth.new(
\fripp_record,
[
\in, ~recordb,
\record, 0.0,
\buffer, buffer
],
s,
\addToTail
))
});
~bufrecorder = ~bufrecorders[0];
// the granulators
~granulators = Array.new(~ntracks);
~grainmodes = Array.fill(~ntracks, 0);
~frippbuffers.do({
| buffer, index |
[ "Grain synth: ", buffer, index ].postln;
~granulators.add(Synth.new(
\grainsynth,
[
\out, ~granulatorb,
\buffer, buffer,
\blen, ~buflen,
\posb, ~playbacklfob,
\triggerb, ~triggerb,
\pitchb, ~pitchb,
\modb, ~lfob,
\size, 0.1
],
s
))
});
~granulator = ~granulators[0];
)

View File

@ -7,12 +7,7 @@
~buflen = 4.0;
~beatsperbar = 4;
~posb0 = Bus.control(s, 1);
~posb1 = Bus.control(s, 1);
~posb2 = Bus.control(s, 1);
~posb3 = Bus.control(s, 1);
SynthDef(\pos_sin, {
SynthDef(\pos_sine, {
arg out, speed=1;
Out.kr(out, 0.5 + SinOsc.kr(speed * 0.5, 0, 0.5));
}).add;
@ -33,7 +28,7 @@ SynthDef(\pos_step, {
Out.kr(out, stepwise / steps);
}).add;
SynthDef(\pos_rand, {
SynthDef(\pos_random, {
arg out=5, speed=1;
Out.kr(out, 0.5 + WhiteNoise.kr(0.5));
}).add;