first steps in Lua – what am i doing wrong?

Home Forums General Programming first steps in Lua – what am i doing wrong?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #722
    Hecticcc
    Participant
      • Topics: 25
      • Replies: 160
      • Total: 185
      • ★★

      I have been reading up on how to use Lua in Ctrlr to archieve various mechanics but i am a programming noob…
      I have adapted some code i found here to try to assign a value coming from IncDecbuttons to a UIbutton but although it throws no errors it does not do what i hoped it would…

      I want this to do the following:

      I use a IncDecbutton to select a preset on my emu 6400 classic, and i want the UIbutton to add a new voice inside this selected preset (on this sampler a preset contains voices, those voices contain the sample zones).
      I try to make the UIbutton listen to the IncDecbutton to get the current preset number, this way i can add a voice in any selected preset.
      Once i get this working i will know how to do the same thing for adding sample zones etc…

      This is the code i (try to) use:

      [code:1ug9ucge]SelectVoice = function(modulator, newValue)

      select = panel:getModulatorByName("select preset"):getModulatorValue()
      add = panel:getModulatorByName("add voice to preset")

      add:setModulatorValue(select, true, true, true)

      end[/code:1ug9ucge]

      For whoever is interested i also attached the work-in-progress panel, it has some basic lfo/env/tuning/cord settings for now so its already a bit usable.

      #4806
      msepsis
      Participant
        • Topics: 219
        • Replies: 732
        • Total: 951
        • ★★★

        Hi Hecticc,

        Instead try this approach:
        [code:1ttinwel]
        SelectVoice = function(modulator, newValue)

        –get the value of unique name "select preset" and assign it to variable "select"
        select = panel:getModulatorByName("select preset"):getModulatorValue()

        –set the value of "add voice to preset" to the value of "select"
        panel:getModulatorByName("add voice to preset")setModulatorValue(select, false, true, false)
        end
        [/code:1ttinwel]

        I might suggest that instead of using the incDec style button to send the program changes to the synth that you use a uiSlider. I have noticed some unpredictable results when using getModulatorValue to get the value of an incDec button.

        If you would like to see how to make your own inc/dec buttons w/ Lua feel free to download my monstrumWave demo panel as I did exactly that.

        At the top of the panel there’s a big black program change knob and two buttons just below the knob for Decrease/Increase.
        The "decrease" button gets the value of the program change knob, decreases the value by one if the current program is greater than 1.
        The "increase" button gets the value of the program change knob, increases the value by one if the current program is less than 128.

        Finally, if you want to hide the uiSlider that actually sends the program change message simply move it off the canvas <img decoding=” title=”Smile” />

        that should get you rollin <img decoding=” title=”Smile” />

        Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen

        #4807
        Hecticcc
        Participant
          • Topics: 25
          • Replies: 160
          • Total: 185
          • ★★

          Thank you for pointing me in the right direction, and for the warning regarding the weird behavior. I will look into your panel to see how you make this work and translate this to my panel.

          Will be so cool when I get it to work, the emu samplers rock hard but are tedious to program from the front panel, once I get this working it will be even more badass <img decoding=” title=”Smile” />

        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 82 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