Is there a way to get the CTRLR Release version from a LUA method? #646
-
Hi, Is there a way to state something like :
It would help giving both syntaxes for sending messages without getting the crashes. Thanks! Damien |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 5 replies
-
Not helping much probably but isn't the only place where the CTRLR version numbers is found, is in the about section? So, in the about section it fetches the version number with, i think: ScopedPointer instanceVersion. And I don't think instance version is bound to Lua. But it also seems to be tied to ctrlrRevision (But ctrlrRevision points to the cmake setup, while instanceVersion probably takes the number from the projucer when compiling.) Not behind my computer, so a bit hard to dig deeper into it 😕 |
Beta Was this translation helpful? Give feedback.
-
The variable for Ctrlr Version is "ctrlrRevision". |
Beta Was this translation helpful? Give feedback.
-
Something like this? local major, minor = utils.getVersionMajor(), utils.getVersionMinor() major = tonumber(major) minor = tonumber(minor) if major > 4 then if minor > 3 then .... |
Beta Was this translation helpful? Give feedback.
-
Looks good! I'm thinking the MemoryBlock addition would work anyway on 5.3 versions? |
Beta Was this translation helpful? Give feedback.
-
Also you should be able to do this:
|
Beta Was this translation helpful? Give feedback.
-
Here's a class that can automate the process. i.e the user doesn't have to worry about which version they are on and adjust in every callback. Because the class is initialised in the constructor, it is loaded across the session and never needs a cll to the class constructor again. It covers all possible types of Midi Message (that I can think of) including an empty parameter: It can recognize Constructor when panel loads:constructor = function(--[[ CtrlrInstance --]] type) mySend = Send mySend:_init() end Class DefinitionSend = {} Send.__index = Send setmetatable( Send, { __call = function(cls, ...) local self = setmetatable({}, cls) self:_init(...) return self end } ) function Send:_init() self.version = self.getMinorVersion() self.threshold=3 -- usually would be 3 ie is version 5.3.* or 5.6.* ?? -- this class will probably barf on Ctrlr versions 6.* end function Send:sendMessage(message) if type(message) == "table" then if self.version > self.threshold then panel:sendMidiMessageNow(CtrlrMidiMessage(MemoryBlock(message))) console("sent raw table with MB added " .. self.version) else panel:sendMidiMessageNow(CtrlrMidiMessage(message)) console("sent raw table " .. self.version) end elseif type(message) == "string" then panel:sendMidiMessageNow(CtrlrMidiMessage(message)) console("sent string possible (hexString(1) " .. self.version) elseif type(message) == "userdata" then panel:sendMidiMessageNow(CtrlrMidiMessage(message:toHexString(1))) console("sent raw MemoryBlock " .. self.version) else console("illegal entry die silently " .. self.version) return end end function Send:getMinorVersion() return utils.getVersionMinor() end function Send:getMajorVersion() return utils.getVersionMajor() end function Send:debug() console("self.version " .. self.version) end In a callback function that sends sysex:myMethod = function(--[[ CtrlrModulator --]] mod --[[ number --]], value --[[ number --]], source) if panel:getBootstrapState() then return end console(mod:getVstIndex() .. "") mySend:sendMessage({0xf0, 0, 0, value, 0xf7}) mySend:sendMessage({0xb0, 0x07, value}) mySend:sendMessage(MemoryBlock({0xf0, 0, 0, value, 0xf7})) mySend:sendMessage("F0 00 00 7f f7") local m= MemoryBlock("F0 00 00 63 f7") mySend:sendMessage(m:toHexString(1)) mySend:sendMessage(m) mySend:sendMessage() -- die silently mySend:debug() end EDIT: (slight refactoring) |
Beta Was this translation helpful? Give feedback.
Something like this?