Re: Changing Images – what could be wrong in that LUA code

Home Forums General Programming Changing Images – what could be wrong in that LUA code Re: Changing Images – what could be wrong in that LUA code

#4448
atom
Keymaster
  • Topics: 159
  • Replies: 2945
  • Total: 3104
  • ★★★★★

Sure, here is how i change a CC number from 32 to 64
[code:1r0lycey]

— Called when a modulator value changes
— @modulator http://ctrlr.org/api/class_ctrlr_modulator.html
— @newValue new numeric value of the modulator

changeControllerNumber = function(modulator, newValue)

— we’re attaching this method to a button with a true/false state

— first let’s get the modulator we want to change
mod = panel:getModulatorByName("filterCutoff")

if mod ~= nil then

— we got the modulaotr, now let’s see if it has a valid MIDI message attached

midi = mod:getMidiMessage()
if midi ~= nil then

— allright we have all the data we need, now depending on the button state
— we’ll set the controller number

if newValue == 1 then
midi:setPropertyInt ("midiMessageCtrlrNumber", 32)
else
midi:setPropertyInt ("midiMessageCtrlrNumber", 64)
end
end
end
end
[/code:1r0lycey]

Ctrlr