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

#4441
Cramp
Participant
    • Topics: 11
    • Replies: 66
    • Total: 77
    "atom":1qhay9jr wrote:
    the properties have special names those visible in the properties pane are only friendly names, have a look here http://ctrlrv4.svn.sourceforge.net/view … rlrIDs.xml for mappings, the cc number will be midiMessageCtrlrNumber, but this is the property of the midi message object not the modulator or the component you should use the getMidiMessage() method of the modulator object to get it’s midi message object.[/quote:1qhay9jr]

    ok, I created two LUA scritps – one is assigned to Single FIlter knob modulator and another one to Multi Filter Knob modulator.

    Firstly, they were also haven’t display the visualization as I requested, I checked your CtrlR ID values and found out that I used[b:1qhay9jr] "uiImageResource"[/b:1qhay9jr] which did nothing for me instead of using the right ones as shown in your ID table – [b:1qhay9jr]"uiImageButtonResource"[/b:1qhay9jr] or [b:1qhay9jr]"uiImageSliderResource"[/b:1qhay9jr]. So that is clear for me know.

    1st script – works fine – visualizations working properly
    [code:1qhay9jr]FilterSwitch = function(modulator, newValue)

    — Images for filters on of are sixfold_selection_filteroff and sixfold_selection_filter
    — Images for filte slope are led_three_upward2 and led_three_upward_off
    — Images for Slider nord_led_pot_full_off and nord_led_pot_full

    — Slider FilterFreq2 in Single Mode CC is 114 and in Multu Mode CC is 59

    — filterslope modulator
    fs = panel:getModulatorByName("FilterSlope")

    — Single Filter Type modulator
    sft = panel:getModulatorByName("FilterType")

    — Multi Filter Type and Led Modulators
    mft = panel:getModulatorByName("FilterEnvCtrl")
    mftl = panel:getModulatorByName("FilterEnvCtrlLed")

    — Filter Freq Dist slider
    ff = panel:getModulatorByName("FilterFreq2")

    filtermode=1

    if filtermode == 1 then
    z = sft:getComponent()
    z:setPropertyString ("uiImageButtonResource" , "sixfold_selection_filter")
    z = fs:getComponent()
    z:setPropertyString ("uiImageButtonResource" , "led_three_upward2")
    z = ff:getComponent()
    z:setPropertyString ("uiImageSliderResource" , "nord_led_pot_full_off")
    z = mft:getComponent()
    z:setPropertyString ("uiImageButtonResource" , "sixfold_selection_filteroff")
    end


    — Enabling Dist Slider if DIST LP (58) is Selected on Filter Type

    if newValue == 5 then
    z = ff:getComponent()
    z:setPropertyString ("uiImageSliderResource" , "nord_led_pot_full")
    fs:setModulatorValue(1, false, true, true)
    else
    z = ff:getComponent()
    z:setPropertyString ("uiImageSliderResource" , "nord_led_pot_full_off")
    fs:setModulatorValue(2, false, true, true)
    end


    — Disabling Filter Slope if BR (35) is Selected on Filter Type

    if newValue == 3 then
    z = fs:getComponent()
    z:setPropertyString ("uiImageButtonResource" , "led_three_upward_off")
    else
    z = fs:getComponent()
    z:setPropertyString ("uiImageButtonResource" , "led_three_upward2")

    end
    end[/code:1qhay9jr]

    2nd script -visualizations working properly as well
    [code:1qhay9jr]–
    — Called when a modulator value changes
    — @modulator http://ctrlr.org/api/class_ctrlr_modulator.html
    — @newValue new numeric value of the modulator

    FilterSwitch2 = function(modulator, newValue)
    — Images for filters on of are sixfold_selection_filteroff and sixfold_selection_filter
    — Images for filte slope are led_three_upward2 and led_three_upward_off
    — Images for Slider nord_led_pot_full_off and nord_led_pot_full

    — Slider FilterFreq2 in Single Mode CC is 114 and in Multu Mode CC is 59

    — filterslope modulator
    fs = panel:getModulatorByName("FilterSlope")

    — Single Filter Type modulator
    sft = panel:getModulatorByName("FilterType")

    — Multi Filter Type and Led Modulators
    mft = panel:getModulatorByName("FilterEnvCtrl")

    — Filter Freq Dist slider
    ff = panel:getModulatorByName("FilterFreq2")

    filtermode=2

    if filtermode == 2 then
    if fs ~= nil and sft ~= nil and ff ~= nil and mft ~= nil and mftl ~= nil then
    z = fs:getComponent()
    z:setPropertyString ("uiImageButtonResource" , "led_three_upward_off")
    z = sft:getComponent()
    z:setPropertyString ("uiImageButtonResource" , "sixfold_selection_filteroff")
    z = ff:getComponent()
    z:setPropertyString ("uiImageSliderResource" , "nord_led_pot_full")
    z = mft:getComponent()
    z:setPropertyString ("uiImageButtonResource" , "sixfold_selection_filter")

    — Assign to FilterFreq2 CC number 59

    xx=ff:getMidiMessage()

    end
    else
    if fs ~= nil and sft ~= nil and ff ~= nil and mft ~= nil and mftl ~= nil then
    z = fs:getComponent()
    z:setPropertyString ("uiImageButtonResource" , "led_three_upward2")
    z = sft:getComponent()
    z:setPropertyString ("uiImageButtonResource" , "sixfold_selection_filter")
    z = ff:getComponent()
    z:setPropertyString ("uiImageSliderResource" , "nord_led_pot_full_off")
    z = mft:getComponent()
    z:setPropertyString ("uiImageButtonResource" , "sixfold_selection_filteroff")
    filtermode=1

    — Assign to FilterFreq2 CC number 114

    end
    end

    end[/code:1qhay9jr]
    But if you may see there is a code within that 2nd script . I tried to call method you have suggested to get modulator MIDI message.
    [code:1qhay9jr]
    — Assign to FilterFreq2 CC number 59

    xx=ff:getMidiMessage()
    [/code:1qhay9jr]

    This code gives an error
    [img:1qhay9jr]http://dl.dropbox.com/u/4202790/error2.png[/img:1qhay9jr]

    Seems it is not registered in CtrlR.
    I wonder is there any other way to set the CC value to modulator using LUA code? I wish I could find an examples. But nothing

    Ctrlr