Home › Forums › General › Using Ctrlr › Global variable confusion
Tagged: global, global variable, modulator, osx
- This topic has 3 replies, 3 voices, and was last updated 8 years, 11 months ago by beely.
-
AuthorPosts
-
May 8, 2015 at 4:44 pm #46134
(Mac OSX 10.9.5, Ctrlr 5.3.85)
I’ve been having a lot of global variable confusion lately.
So I was using 5.2.x initially, and modulators linked to global variables was working fine – for instance, I had a knob that would select between four values, and that global variable it was linked to was used in other sysex messages for other knobs, so one filter cutoff knob could be targeted to the filter cutoff of Tones 1 to 4 on a Roland module. Great, worked well.
And as I tweaked the modulator, the global variables would update in the panel settings in real time, so I could watch it change, both in the settings for the knob, and in the global variables list in the overall panel settings.
Now I updated to 5.3, and was trying to do something else and having problems with global variables not seeming to react or even behave as I thought they did. And on loading my previous attempts, I can see now that changing knobs linked to modulators is not updating the global variable at all, whereas it previously did.
Is this broken in 5.3.85 on OSX? Or did something internally change and I need to update something in my settings/panels?
Edit: And now if I go back to 5.2.139, create a new panel, add a new slider and link it to global variable 0, as I move the slider, the global variable doesn’t change either. In fact, as I change the slider, the modulator value itself stays 0. I’m ?Confuzzled?
Is there something conceptual I am missing about modulator and global variables?
May 9, 2015 at 4:55 am #46236I haven’t had much luck with the global variables in the right pane.
Any variable declared in LUA appears to be global to the panel anyway, so I’m just using them and building the messages in LUA.
The Puppeteer
http://godlike.com.auMay 9, 2015 at 2:00 pm #46286Hi
Had trouble using glb var as i used itmod changeCallbak -> setGlobal
other mod changeCallbak -> getGlobalAs I said before to Puppeteer there is global(panel) Callback for glb var change
That’s working fineAttach mod to glb var and apply what you want in this panel script Callback
You can put complex expressions in it
-- -- Called when a global variable has changed it's value -- MyVariables = function( index, value) MySndGens = panel:getComponent("SoundGens") MyFilter = panel:getComponent("Filter") MyBufList = panel:getComponent("BufferList") vwEdtTab = panel:getModulatorByName("EditTab") if index == 5 then panel:getCanvas():repaint() --repaint all the panel elseif index == 0 and value == 0 then panel:setGlobalVariable(2,panel:getGlobalVariable(2)%4) -- return to the start else if index == 2 then local a = BigInteger(panel:getGlobalVariable(0)) a:setBitRangeAsInt(1,4,value) local b = BigInteger(1) b:setBitRangeAsInt(1,4,value) local c = a:getBitRangeAsInt(0,7) local d = b:getBitRangeAsInt(0,7) local e = (23 + c)%128 local f = (23 + d)%128 if c ~= d then panel:sendMidiMessageNow(CtrlrMidiMessage{0xF0,0x3E,0x10,0x00,0x17,d,f,0xF7}) end panel:sendMidiMessageNow(CtrlrMidiMessage{0xF0,0x3E,0x10,0x00,0x17,c,e,0xF7}) end if vwEdtTab ~= nil then CurrentSound() end if BufferToGet == nil then vwEdtTab:setModulatorValue(0,false,false,false) else vwEdtTab:setModulatorValue(1,false,false,false) end if MySndGens ~= nil then MySndGens:repaint() end if MyBufList ~= nil then MyBufList:repaint() end if MyFilter ~= nil then MyFilter:repaint() end end end
Apparently you can even set a global var in it :
“if index == 0 then panel:setGlobalVariable(2,MODEA)”currentsound() is a sub script with complex glb var expressions, it is not in the main scritp because I use it elsewhere for panel startup (important step)
function CurrentSound() local a0 = panel:getGlobalVariable(0) local a1 = panel:getGlobalVariable(1) local a2 = panel:getGlobalVariable(2) + 1 local a3 = panel:getGlobalVariable(3) + 1 local a4 = panel:getGlobalVariable(4) local a67 = panel:getGlobalVariable(6 +a0 ) if a1 == 1 then if a67 ~= a2 then BufferToGet = MyBuffers[a0+1].FDAT[a2] SBufIdx = a2 elseif a67 == a2 then if a4 == 0 then BufferToGet = nil SBufIdx = nil elseif a4 == 1 then if MyBuffers[a0+1].FDAT[a3] ~= nil then BufferToGet = MyBuffers[a0+1].FDAT[a3] else BufferToGet = nil end SBufIdx = a3 end end else BufferToGet = nil SBufIdx = nil end MultiMode = a0 return BufferToGet , SBufIdx , MultiMode end
in brief
if index ~= GlobalVariable(5) then
the script create 3 LUA variables I can use after elsewhere
if index == 2 I send one or two midi messages
if index == 0 then I set GlobalVariable(2) then the script restart ( a kind of loop)
then I send one or two midi messages !
That way the LUA variables created are always refreshed when you turn any knobs attached to glb var .you can still use panel:getGlobalVariable(index) if don’t want to use LUA variable to call the glob var valueIf that can help
May 10, 2015 at 4:59 pm #46462Hmm, ok then, not just me! 😉
Glad to know I’m not completely on the wrong page.Thanks for the suggestions – some of which are a bit over my head initially as I’ve only really spent a few hours in Ctrlr doing pretty straightforward things, but i will go through and see whether it helps as I try to figure out this thing and make it do what I want 🙂
-
AuthorPosts
- The forum ‘Using Ctrlr’ is closed to new topics and replies.