Home › Forums › General › Programming › Lua in CTRLR 101
- This topic has 14 replies, 3 voices, and was last updated 12 years, 9 months ago by msepsis.
-
AuthorPosts
-
July 13, 2011 at 1:41 am #378
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)
endend[/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
July 13, 2011 at 8:12 am #2964[code:39jboomk]
m = CtrlrMidiMessage(pbOsc1:setModulatorValue(bend), pbOsc2:setModulatorValue(bend))
[/code:39jboomk]
that is weird what did you want to achieve here ?July 13, 2011 at 3:37 pm #2965move bend and both pbOsc1 and pbOsc2 follow.
Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen
July 13, 2011 at 4:21 pm #2966well 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})July 16, 2011 at 7:34 pm #2963ok. 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
July 16, 2011 at 7:58 pm #2967i 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.
July 17, 2011 at 3:26 am #2968haha. 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
July 17, 2011 at 6:39 am #2969i 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]
July 18, 2011 at 7:24 pm #2970Thanks 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
July 18, 2011 at 8:14 pm #2971you 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 PitchBendJuly 18, 2011 at 9:38 pm #2972ok. 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. ” title=”Confused” />
Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen
July 18, 2011 at 9:49 pm #2975well 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
July 19, 2011 at 12:41 am #2973ok 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
July 19, 2011 at 12:50 am #2976Ok. I think you meant something like this, Atom
this works now. finally moving the hell on ” 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
July 19, 2011 at 1:02 am #2974first line of the method not the method definition itself, but you get the picture.
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.