Midi Key Source Activation with Optional Latching

81 views
Skip to first unread message

Scott Stanley

unread,
Mar 9, 2016, 11:30:15 PM3/9/16
to Lightjams
I am configuring a Midi Keyboard and am building a control grid the same width as the number of keys (starting at note 0).  Using midi 16,69, I would like to control whether the keys latch, or work in piano mode. 

I tried this : 
switch(midi.control(16,69),0,midi.note(1,x+1),toggle(midi.note(1,x+1)))

But for some reason when midi(16,69) isnt 0, it still wants to function like a toggle.which is weird. Plus the values persists.

I then tried this
switch(midi.control(16,69),0,midi.note(1,x+1),latch(midi.note(1,x+1),midi.note(1,x+1)))

Which almost works, but the values persist from even when it's not latched, so any key I've touched is lit with it's last value

Anyone have any ideas on how to accomplish this so when I toggle on the latch key the source isn't activated by default? 

Mathieu

unread,
Mar 10, 2016, 12:12:57 AM3/10/16
to Lightjams
Hi Scott,

>> But for some reason when midi(16,69) isnt 0, it still wants to function like a toggle.

Maybe I'm missing something but the formula says exactly this. The last value of the switch function is the default value (no other cases match). So when the midi control isn't 0, that means the default value is returned, which is toggle(midi.note(1,x+1)).

For the 2nd question, you want a way to reset everything when you switch to the toggle mode, right?

It's a bit late here, so I may be hallucinating, but this seems to do the job:

switch(midi.control(16,69), 0,midi.note(1,x+1), 100*counter(0, 1, onBeat(midi.note(1,x+1)), 0, midi.control(16,69)==0))

Instead of using the toggle function, you can use the counter which can be resetted. So each time the midi control goes to 0, the counter also goes to 0.

Cheers,
Mathieu

Scott Stanley

unread,
Mar 10, 2016, 12:26:55 AM3/10/16
to Lightjams
That did the job!!

In the first instance, even if midi control was 0, the midi key would operate in a toggle.. i typo'd.. s/isn't/is  -- which is what I found odd. 

Your suggestion is exactly what I need though-- Thank you! ;)
Reply all
Reply to author
Forward
0 new messages