Thank you for your response!
I just found out that the standard FPS of the sensel is 125, and there is an API with which this maximum frame rate can be set: https://guide.sensel.com/api_adv/
I also found out that there is an implementation of this API on the Bela: https://github.com/jarmitage/bela-sensel
The last commit was 6 years ago though and time is running out over here... so I don't know if it's worth to go down that road...?
I am basically opening 5 MIDIdefs - for NoteOn, NoteOff, Bend (x value of the pad), CC74 (y value of the pad) and CC76 (z value of the pad). All MIDIdefs are generated for up to five fingers, so increasing the midi channel in the loop that creates the MIDIdefs.
This is the current state of the code, hope this is clear and clean so far!
s = Server.default;
s.waitForBoot({
SynthDef.new(\tone, {
var freq = \freq.kr(440);
var pitch = \pitch.kr(0);
var bend = \bend.kr(0);
var amp = \amp.kr(0);
var sig, env;
pitch = pitch.linlin(0.0, 16383.0, -30.0, 30.0);
bend = bend.linlin(0.0, 127.0, -8.0, 0.0);
amp = amp.linlin(0.0, 127.0, 0.0, 1.0);
sig = LFTri.ar(freq!2 * bend.midiratio * pitch.midiratio);
env = Env.adsr(0.1, 0.03, 0.7, 0.1).kr(Done.freeSelf, \gate.kr(0));
sig = sig * env;
sig = sig * amp;
Out.ar(0, sig);
}).add;
s.sync;
MIDIClient.init;
MIDIIn.connectAll;
~notes = Array.newClear(5);
~sensel = 5.collect({
arg n;
MIDIdef.noteOn("\noteOn" ++ n, {
arg vel, nn, chan;
~notes[chan] = Synth.new(
\tone, [
\freq, nn.midicps,
\amp, vel,
\gate, 1,
\bend, 0,
]
);
}, chan: n);
MIDIdef.noteOff("\noteOff" ++ n, {
arg vel, nn, chan;
~notes[chan].set(\gate, 0);
~notes[chan] = nil;
}, chan: n);
MIDIdef.bend(("pitch" ++ n).asSymbol, {
arg val, chan;
~notes[chan].set(\pitch, val);
}, chan: n);
MIDIdef.cc(("bend" ++ n).asSymbol, {
arg val, num, chan;
~notes[chan].set(\bend, val);
}, 74, chan: n);
MIDIdef.cc(("touch" ++ n).asSymbol, {
arg val, num, chan;
~notes[chan].set(\amp, val);
}, 76, chan: n);
});
});
ServerQuit.add({ 0.exit });