I'm using midicontroller in as described here
One of the thing not described on that page but in som etopics on the forum here is that you can use a shorthand "^13" to map CC 13 to 0-1 value. Very handy, and usefull while live coding.
I want to do another thing though. Suppose:
d1 $ sound "bd*4" but I want to map the 4 to my controller and have it range from 0-16, meaning I would have to do some math first.
I found this thread, with a partial solution, but it doesn't really work.
I get I should work with an intermediary variable, from that post like:
setI "divider" $ (cI 5 "13")
but then I still want to do some math so something like
setI "divider" $ (cI 5 "13")*4
to finally put into my pattern
d1 $ sound "bd*divider"
but obviously that does not work. Midi input works fine if I just use the "^29" to map 0-1 values in like in
It's been a while since I looked at the code but I think it's because the pattern embedding is done by the scheduler, which means having one reactive variable referring to another one sadly doesn't work.
well they put me in the right direction anyway
I made some simple calculations in supercollider, and I can use the midi CCs inside patterns now!
I defined ^iCC to return an int from 0-15 and ^dCC returns a zero or a power of 2
~divs = [0, 1, 2, 4, 8, 16, 32, 64];
cc = MIDIFunc.cc({ |val, num, chan, src|
var divindex, divs;
divindex = (val / 16).floor.asInteger;
divindex = divindex.clip(0, 7); // Safety: Ensure the index never goes outside the bounds of our list (0 to 3)
divs = ~divs[divindex];
osc.sendMsg("/ctrl", num.asString, val/127);
osc.sendMsg("/ctrl", "i" ++ num.asString, ((val / 8) ).floor.asInteger;);
osc.sendMsg("/ctrl", "d" ++ num.asString, divs);
"d: %".format(val, divs).postln;
"i: %".format(val, ((val / 8)).floor.asInteger;).postln;
});
The only downside is I have to switch to supercollider to define my Math, but using some sensible defaults I don't think a lot will be needed later on.
but I can do