Hey there! I am running a setup that is receiving the MIDI data from a Sensel Morph in Bela using SuperCollider. Basically I want to receive MPE XYZ data for up to five fingers. Apparently all of this is too much for Bela, as pretty often NoteOff messages are missed, when I start MIDIdefs for all three directions. If I am leaving out one of them, I get reliable NoteOn and NoteOff messages, also when running the same code on my MacBook.

Do you have any ideas how to tackle this? For example is there a way to slow down the frame rate of the incoming messages in the MIDIdef?

Here is my code - counting up the n in the loop is intentional, as I am storing the synths into an array counting up from 0, but the channel of the incoming fingers start at 1.

~sensel = 5.collect({
    arg n;
    n = n+1; 

    MIDIdef.noteOn("\noteOn" ++ n, {
	arg vel, nn, chan, src;
	~notes[chan-1] = Synth.new(
	\tone, 
            [
		\freq, nn.midicps,
		\amp, vel,
		\gate, 1,
		\bend, 0,
	    ]
	);
    }, chan: n);

    MIDIdef.noteOff("\noteOff" ++ n, {
   	arg vel, nn, chan, src;
	~notes[chan-1].set(\gate, 0);
	~notes[chan-1] = nil;
    }, chan: n);

    MIDIdef.bend(("pitch" ++ n).asSymbol, {
	arg val, chan, src;
	~notes[chan-1].set(\pitch, val);
    }, chan: n);
	
    MIDIdef.cc(("bend" ++ n).asSymbol, {
	arg val, num, chan, src;
	~notes[chan-1].set(\bend, val);
    }, 74, chan: n);
	
    MIDIdef.touch(("touch" ++ n).asSymbol, {
	arg val, chan, src;
	~notes[chan-1].set(\amp, val);
    }, chan: n);
});
    5 days later

    could you do some tests with puredata on Bela instead of SC? do you get missing note offs as well?

    Well, I am afraid I am not so fluent in Pure Data as in I've some stuff already written in SuperCollider that I would like to use afterwards. Or do you mean just for the sake of finding out if it is hardware or software related?

    chk Do you have any ideas how to tackle this?

    Not really ...

    chk For example is there a way to slow down the frame rate of the incoming messages in the MIDIdef?

    I don't think that can be done easily on the Sc or Linux side, can that be done on the sensel side?
    How often are MIDI messages coming in? If they are hundreds per second per each touch, I could see how under moderate to high CPU usage you may get some buffer overruns, causing some messages to be lost. Most notably, you'd notice the note off getting lost, but some CCs may be lost, too.

      giuliomoro I don't think that can be done easily on the Sc or Linux side

      I mean, it can be done in Linux but it requires a decent amount of effort and it may be too late to be effective. Not sure about doing it in Sc (check Sc docs for that), but it would suffer the same issue. Doing it on the Sensel side would definitely be the right thing to do.

      18 days later

      Apparently it is not possible to slow down the messages coming from the Sensel side, the SenselApp generally allows a lot of things layout-wise, but not decreasing the framerate of the controller, unfortunately. Any other thoughts or ideas? This is soooo annoying 🙁

      do you have an idea of what the current frame rate is? How often does the sensel send messages? I assume bend, pitch and aftertouch are the ones that are being sent more often.

      Also, how are you opening the MIDI device in Supercollider? Can you show the code for that?

      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 });

        @jarm do you know if frame rate reduction can be achieved with your code above?

        • jarm replied to this.
        • chk likes this.

          chk out that the standard FPS of the sensel is 125

          I see that that's the standard scanning rate, is it also the standard rate at which BEND and AFTERTOUCH MIDI messages are sent?

          Can these settings not be changed via the Sensel App?

          @jarm one thing I don't understand and maybe you can help with given your existing experience: is the API something that can be used alongside with or should be used alternatively to the USB MIDI setup? For instance, is it reasonable (and/or possible) to have the device work as USB MIDI while at the same time connecting to it via the API to adjust the scan rate and/or scan detail? How does the sensel library connect to the device? USB or some other protocol?

          Maybe @LFSaw can also help here?

          • jarm replied to this.

            giuliomoro @jarm one thing I don't understand and maybe you can help with given your existing experience: is the API something that can be used alongside with or should be used alternatively to the USB MIDI setup? For instance, is it reasonable (and/or possible) to have the device work as USB MIDI while at the same time connecting to it via the API to adjust the scan rate and/or scan detail? How does the sensel library connect to the device? USB or some other protocol?

            I'm travelling at the minute and can't answer very well, sorry. Check also here: https://forum.sensel.com/

            this seems like a good place to look: https://github.com/sensel/sensel-api/blob/master/sensel-install/disable-serial-executables/README.md

            By being able to use both API and MIDI at the same time, you could issue an API command to e.g.: reduce the scan rate and see if that affects the rate of data sent via MIDI.

            Although that sounds like it is partly contradicting this https://forum.sensel.com/t/is-it-possible-to-change-to-highspeed-mode-from-sensel-app/638/18

            Maybe you are better off posting on the sensel forum asking explicitly about reducing the frame rate of CC and TOUCH messages sent via MIDI.

            Thank you very much for your pointers and hints! I will be looking into these in the next one or two weeks and will come back with results, hopefully.