Lua in CTRLR 101

Home Forums General Programming Lua in CTRLR 101

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #378
    msepsis
    Participant
    • Topics: 219
    • Replies: 732
    • Total: 951
    • ★★★

    Ok, here’s a somewhat simple job I’m trying to get working, CTRLR is crashing a LOT lately trying to get something working… probably cause ctrlr doesn’t know what the hell I’m trying to tell it to do.

    So for a simple task I want to have one knob send its value to two others… in this case a "pitch" knob that works like pitchbend but operates by setting the pitch of both osc1 and osc2…

    Here’s my bastard of an attempt to write my first LUA script:
    [code:vzdstwo6]


    — OscPitchBend: 1 wheel drives 2 others

    OscPitchBend = function(modulator, newValue)
    bend = panel:getModulatorValue("pitchbend")
    pbOsc1 = panel:getModulatorByName("Osc1pitchBend")
    pbOsc2 = panel:getModulatorByName("Osc12pitchBend")

    if pitchbend~= nil then
    m = CtrlrMidiMessage(pbOsc1:setModulatorValue(bend), pbOsc2:setModulatorValue(bend))
    panel:sendMidiMessageNow(m)
    end

    end[/code:vzdstwo6]

    Not much time to spend at the moment troubleshooting this, It seems to be crashing ctrlr just by testing the syntax (bug icon) – is my code that bad? Odd that the sandbox crashes while testing this…. Atom, Some of the scripts you have attached to your demo panel are also crashing ctrlr here while testing the same way (the bug icon). (win32, ctrlr rev 617).. so testing Lua syntax in ctrlr is really unpredictable.

    thanks!

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

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

    [code:39jboomk]
    m = CtrlrMidiMessage(pbOsc1:setModulatorValue(bend), pbOsc2:setModulatorValue(bend))
    [/code:39jboomk]
    that is weird what did you want to achieve here ?

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

    move bend and both pbOsc1 and pbOsc2 follow.

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

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

    well it makes no sens, if you wish to create a midi message
    [code:3c5djj12]
    m = CtrlrMidiMessage ({0xb0, 0x01, 0x02})
    [/code:3c5djj12]
    that will create a midi message of type CC midi channel 1 (0xb0) CC number is 1 (0x01) and the value is 2 (0x02), what you are doing is passing two NIL values to the CtrlrMidiMessage constructor (pbOsc1:setModulatorValue(bend) does not return any value so nothing gets passed to the constructor of the CtrlrMidiMessage, also you need to pass an array of values to the constructor that is {xx,xx,xx})

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

    ok. but I don’t necessarily want to create a midi message as much as i want to pass a midi message from one knob’s position to two others… I have some time today to dink with this, I’ll post my results if/when i get this ironed out today so others can learn from it.

    Thanks Atom

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

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

    i don’t think i get what you are trying to do, pass a midi message from one knob’s position ? if you want to create some simple relation between slider values then you don’t need to create any midi messages.

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

    haha. ok. My panel has an osc1 and osc2 pitch wheels.

    I want to create a global pitch wheel which when moved sends duplicate parameter changes to the two osc1 and osc2 pitch wheels.

    so basically I want to "parent" one modulator’s modulatorValue to that of two other modulators.

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

    #2969
    netchose
    Participant
    • Topics: 15
    • Replies: 70
    • Total: 85

    i think someting like that

    [code:3ehofbxe]OscPitchBend = function(modulator, newValue)
    bend = panel:getModulatorValue("pitchbend")
    pbOsc1 = panel:getModulatorByName("Osc1pitchBend")
    pbOsc2 = panel:getModulatorByName("Osc12pitchBend")

    v=bend :getModulatorValue()

    pbOsc1 = setModulatorValue (v, true, true, true)
    pbOsc2 = setModulatorValue (v, true, true, true)

    end[/code:3ehofbxe]

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

    Thanks netchoose, something like that should work. I have:

    [code:urjldjio]
    OscPitchBend = function(modulator, newValue)
    bend = panel:getModulatorValue("PitchBend")
    pbOsc1 = panel:getModulatorByName("Osc1Pitch")
    pbOsc2 = panel:getModulatorByName("Osc2Pitch")

    pbOsc1 = setModulatorValue (bend, true, true, true)
    pbOsc2 = setModulatorValue (bend, true, true, true)

    end
    [/code:urjldjio]

    which is mysteriously spitting back a runtime error when testing the script w/ the bug icon (I notice most of the demo scripts atom posted also return runtime errors when checked, as mentioned previously in this thread)…

    anyway regardless of the runtime error this method doesn’t disable when rotating the "PitchBend" modulator on my panel which the above Lua script is attached to, great. but rotating the "PitchBend" modulator does nothing to the Osc1Pitch or Osc2Pitch modulators. .. probably something minor.

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

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

    you can’t do
    [code:ldl15fzk]
    value = setModulatorValue(whatever.....)
    [/code:ldl15fzk]
    this makes no sense, you need to call the setModulatorValue on an object
    [code:ldl15fzk]
    OscPitchBend = function(modulator, newValue)
    bend = panel:getModulatorValue("PitchBend")
    pbOsc1 = panel:getModulatorByName("Osc1Pitch")
    pbOsc2 = panel:getModulatorByName("Osc2Pitch")

    pbOsc1:setModulatorValue (bend, true, true, true)
    pbOsc2:setModulatorValue (bend, true, true, true)

    end
    [/code:ldl15fzk]
    assuming i understand what you want to do, that is set the value of the "Osc1Pitch" and "Osc2Pitcj" to the value of PitchBend

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

    ok. but still, sadly the code you gave above put on a modulator who’s unique name is "PitchBend" in a simple panel containing two other modulators who’s unique names are "Osc1Pitch" and "Osc2Pitch" still does nothing, and still the above code gives a Lua Runtime error. <img loading=” title=”Confused” />

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

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

    well ofcourse it will
    the first line must be
    [code:1kjijtmu]
    bend = panel:getModulatorByName("PitchBend"):getModulatorValue()
    [/code:1kjijtmu]

    the panel object does not have a getModulatorValue() method… simple

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

    ok but that’s not the first line of what you just posted two posts ago.. all I did was literally plug in what you gave me… hrm.

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

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

    Ok. I think you meant something like this, Atom
    this works now. finally moving the hell on <img loading=” title=”Smile” />

    [code:hthdvtvn]

    OscPitchBend = function(modulator, newValue)

    bend = panel:getModulatorByName("PitchBend"):getModulatorValue()
    pbOsc1 = panel:getModulatorByName("Osc1Pitch")
    pbOsc2 = panel:getModulatorByName("Osc2Pitch")

    pbOsc1:setModulatorValue (bend, true, true, true)
    pbOsc2:setModulatorValue (bend, true, true, true)

    end
    [/code:hthdvtvn]

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

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

    first line of the method not the method definition itself, but you get the picture.

Viewing 15 posts - 1 through 15 (of 15 total)
  • The forum ‘Programming’ is closed to new topics and replies.
There is currently 0 users and 63 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