Send simple CC# value when changing tabs.

Home Forums General Programming Send simple CC# value when changing tabs.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #69563
    Synthetech
    Participant
      • Topics: 13
      • Replies: 70
      • Total: 83

      Hey all again,

      Well I’ve been away so long that I’ve kinda forgotten how to use LUA/Ctrlr and could use some help again.

      I want to call a method when I change tabs.
      When I click on
      Tab 0,
      I want to send Midi Msg “Control Change #95/Value “1”.

      Tab 1,
      I want to send Midi Msg “Control Change #95/Value “127”.

      Tab 2,
      I want to send Midi Msg “Control Change #95/Value “2”.

      I assume I need to use code like,

      — Called when the current tab in an uiTabs component is changed

      currentTabChanged = function(modulator,currentTabIndex)
      console (string.format (“currentTabChanged tabIndex=%d”, currentTabIndex))
      l = getComponent(“label-current-tab”)
      if l ~= nil then
      l:setPropertyString (“uiLabelText”, string.format (“Current tab=%d”, currentTabIndex))
      end
      end

      and somehow put code like this in it..

      selectTimber1 = {0xB0; 0x5F, 0x01}
      panel:sendMidiMessageNow(CtrlrMidiMessage(selectTimber1))

      but I havent messed with code for so long that I am lost in how to do this 🙁

      can anyone help me get this to work. I’m hoping it’s very simple and all I need is a push in the right direction to get it to work..
      Thanks!

      • This topic was modified 7 years, 9 months ago by Synthetech.
      • This topic was modified 7 years, 9 months ago by Synthetech.
      #69567
      Synthetech
      Participant
        • Topics: 13
        • Replies: 70
        • Total: 83

        well I managed to dig in again and think I figured it out…


        — Called when the current tab in an uiTabs component is changed

        timbreSelect = function(mod, tabIndex)
        selectTimbre1 = {0xB0; 0x5F, 0x00}
        selectTimbre2 = {0xB0; 0x5F, 0x7F}
        selectTimbreSync = {0xB0; 0x5F, 0x01}

        if tabIndex==0 then
        panel:sendMidiMessageNow(CtrlrMidiMessage(selectTimbre1))

        elseif tabIndex==1 then
        panel:sendMidiMessageNow(CtrlrMidiMessage(selectTimbre2))

        elseif tabIndex==2 then
        panel:sendMidiMessageNow(CtrlrMidiMessage(selectTimbreSync))

        end
        end

        seems to output the CC msg as needed.. now I just need to verify it on the microKorg soon.
        I’m not sure if the above code is the most efficient, but it does appear to work.

        #69570
        goodweather
        Participant
          • Topics: 45
          • Replies: 550
          • Total: 595
          • ★★★

          Hi!
          Yes this should work. I’m using similar code to display some help on the current tab…
          You could also allocate your sysex to a single variable (msgTimbre for example) within each “if” then use sendMidiMessageNow outside at the end.
          Anyway Lua is executed fast so this won’t make any difference…
          Good luck!

        Viewing 3 posts - 1 through 3 (of 3 total)
        • The forum ‘Programming’ is closed to new topics and replies.
        There is currently 0 users and 50 guests online
        No users are currently active
        Forum Statistics
        Threads: 2,495, Posts: 17,374, Members: 77,605
        Most users ever online was 12 on January 22, 2019 3:47 pm
        Ctrlr