HI,
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
d1 $ sound "bd*4"
# krush ("^29"*4)
How to use this in patterns?
You can do things like "bd*[^13]", but I can't think of a way of scaling that in tidal on the way in to mininotation.
It'd probably be easier to send a scaled version from supercollider, something like this should work:
cc = MIDIFunc.cc({ |val, num, chan, src|
osc.sendMsg("/ctrl", num.asString, val/127);
osc.sendMsg("/ctrl", "s" + num.asString, (val / 10) + 1);
});
Then you could do `"bd*[^s13]"`
1 Like
I guess the question is why this works:
setF "test" "<8 4>"
d1 $ sound "bd*[^test]"
and this doesn't:
setF "test2" ("^test" * 2)
d1 $ sound "bd*[^test2]"
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.
Ok,
trying to see where I can get with the supercolliderpath. But I cannot get your example to work...
when debugging I found that supercollider sends
RECEIVE | ENDPOINT([::ffff:127.0.0.1]:57120) ADDRESS(/ctrl) STRING(s 13) FLOAT(7.4)
so instead of "s13" I get an "s 13"
I had to correct
osc.sendMsg("/ctrl", "s" + num.asString, (val / 10) + 1);
to
osc.sendMsg("/ctrl", "s" ++ num.asString, (val / 10) + 1);
the extra + makes sure there is no space when concatenating. I'll see if I can do what I wanted to like this
Makes sense, sorry my supercollider skills are very weak !
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
d1 $ n "[^i29]*[^i49] [^i13]*4"
# s "kick"
so yeah that is definitely a step up for me.
1 Like