Home › Forums › General › Using Ctrlr › Toggle two SysEx strings
- This topic has 11 replies, 3 voices, and was last updated 3 years, 9 months ago by
goodweather.
-
AuthorPosts
-
October 19, 2016 at 11:24 pm #70144
Hi everyone,
I couldn’t find it anywhere on the forums so I will post my question here.
Is there a simple way to make a toggle button for two SysEx strings.
I want it to be like this
on(1) = F0 41 12 3A 12 70 01 09 01 05 F7
off(0) = F0 41 12 3A 12 70 01 09 00 06 F7Is this possible whitout LUA?
Kind regards
October 20, 2016 at 11:19 am #70145Hi Pulse,
to my knowledge this is not possible without Lua, but with Lua it is a dead easy task. I will post the code this evening when I’m at home.
-
This reply was modified 7 years, 1 month ago by
Possemo.
October 21, 2016 at 10:28 am #70153Hi Poss, was chatting with Pulse and proposed him to post this question on the forum as I thought that maybe it is possible to use the sysex Midi properties of the component for that. I now how to get the value of the button in the sysex string (explained by Atom in his Getting started doc) but don’t think it is possible to make a calculation on one byte (second to last byte would be 06 – button value).
Hi Pulse, here is the code and instructions I spoke in our chat…
– Check my Step by Step guide for some introduction to Lua and some references
– Open your panel then open Lua editor (in Panel menu)
– Create a method isPanelReady()-- -- Check if the panel is not busy to load or receiving a program -- isPanelReady = function() if panel:getBootstrapState() == false and panel:getProgramState() == false then return (true) else return (false) end end
– Save and compile
– Create a method Mute_OnChange with luaModulatorValueChange selected in the Initialize from template combo-- -- Called when a modulator value changes -- @mod http://ctrlr.org/api/class_ctrlr_modulator.html -- @value new numeric value of the modulator -- Mute_OnChange = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value, --[[ number --]] source) -- No action if the panel is in bootstrap or program states if not isPanelReady() then return end if value==1 then -- Mute ON msg = CtrlrMidiMessage({0xF0, 0x41, 0x12, 0x3A, 0x12, 0x70, 0x01, 0x09, 0x01, 0x05, 0xF7}) else -- Mute OFF msg = CtrlrMidiMessage({0xF0, 0x41, 0x12, 0x3A, 0x12, 0x70, 0x01, 0x09, 0x00, 0x06, 0xF7}) end panel:sendMidiMessageNow(msg) end
– Save and compile
– Select your toggle and select the Mute_OnChange method in the property Called when the modulator value changeShould work fine 🙂
Good luck!October 21, 2016 at 10:49 am #70154Hi Goodie, sorry Pulse I was too tired yesterday. I wanted to give you the code now but goodweather was faster. I would have done it the same way, I maybe would have shortended the script to the max like this:
Mute_OnChange = function(mod, value) if value==1 then -- Mute ON panel:sendMidiMessageNow(CtrlrMidiMessage("F0 41 12 3A 12 70 01 09 01 05 F7")) else -- Mute OFF panel:sendMidiMessageNow(CtrlrMidiMessage("F0 41 12 3A 12 70 01 09 00 06 F7")) end end
I only insert checks like isPanelReady() and getBootstrapState() when I run into problems. But it surely is not a bad thing to do it as a preventive measure.
-
This reply was modified 7 years, 1 month ago by
Possemo.
October 22, 2016 at 10:07 am #70175Well, I’m putting isPanelReady in all _OnChange and _OnClick methods otherwise you get soon or later issues…
Also, I’m avoiding putting too many functions in functions even if it works perfectly. More a visual matter and more for code readability.Now, to shorten even further the code, you can just have everything in one line in fact…
Mute_OnChange = function(mod, value) panel:sendMidiMessageNow(CtrlrMidiMessage(string.format("F0 41 12 3A 12 70 01 09 %.2x %.2x F7", value, 6-value))) end
Have a nice w-e 🙂
October 22, 2016 at 2:03 pm #70176Thanks for the help guys!
I will have a lot of reading to do now. Let’s get into that LUA. I have 17 different buttons with this functionality to make for my panel 🙂
Kind regards
October 25, 2016 at 8:01 am #70183Hi Goodie, now that’s really short! Very smart, I like short code.
October 25, 2016 at 7:17 pm #70185😉
November 10, 2016 at 9:52 am #70248Hey Possemo,
Your code seems to be working very nicely. I don’t know why goodweathers code isn’t working for me but none the less the button is working! 😀
Thanks a lot for the help!
Kind regards
March 3, 2020 at 12:14 pm #117152Is there a simple way to make a toggle button for two SysEx strings.
I want it to be like this
on(1) = F0 41 12 3A 12 70 01 09 01 05 F7
off(0) = F0 41 12 3A 12 70 01 09 00 06 F7
Is this possible whitout LUA?the question is old but maybe someone else will have the same question.
Answer is yes, use msb/lsb in uiButton:sysex: F0 41 12 3A 12 70 01 09 ms ls F7 (ms = msb, ls=lsb)
button content : value = ms*16 + ls
OFF = 6 (= 0x06 = 0*16 + 6)
ON = 21 (= 0x15 = 1*16 + 5)March 4, 2020 at 11:49 am #117182Is there a simple way to make a toggle button for two SysEx strings.
I want it to be like this
on(1) = F0 41 12 3A 12 70 01 09 01 05 F7
off(0) = F0 41 12 3A 12 70 01 09 00 06 F7
Is this possible whitout LUA?the question is old but maybe someone else will have the same question.
Answer is yes, use msb/lsb in uiButton:sysex: F0 41 12 3A 12 70 01 09 ms ls F7 (ms = msb, ls=lsb)
button content : value = ms*16 + ls
OFF = 6 (= 0x06 = 0*16 + 6)
ON = 21 (= 0x15 = 1*16 + 5)Very nice! Didn’t know that!
March 4, 2020 at 9:20 pm #117197Yes indeed! Very good proposal and a new thing I didn’t know 🙂
-
This reply was modified 7 years, 1 month ago by
-
AuthorPosts
- The forum ‘Using Ctrlr’ is closed to new topics and replies.