Home › Forums › General › Programming › Panel Update LUA script
- This topic has 15 replies, 3 voices, and was last updated 12 years, 8 months ago by atom.
-
AuthorPosts
-
July 21, 2011 at 12:48 am #380
I’ve got the midi example tweaked to work with my panel for most everything I have in there. There’s one aspect that is not updating properly and I’m having trouble figuring out why. The problem occurs when I attempt to update the FX settings. The Effects unit has several possible choices of which effect is enabled, but they all share the same generic value for the parameters. THE FX code here is the important part. Here’s the code I currently have :
[code:12idefi7]
function assignValues(midiMessage)
console ("assignValues")
programData = midiMessage:getLuaData():getRange(7,389)console ("RAW DATA: ")
console (programData:toHexString(1))— Oscillator 1
panel:getModulatorByName("Osc 1 Octave"):setModulatorValue(programData:getByte(1), false, true, true)
panel:getModulatorByName("Osc 1 Semitone"):setModulatorValue(programData:getByte(2), false, true, true)
panel:getModulatorByName("Osc 1 Detune"):setModulatorValue(programData:getByte(3), false, true, true)
panel:getModulatorByName("Osc 1 Bend Range"):setModulatorValue(programData:getByte(4), false, true, true)— Edited for brevity
— FX 1
Need to program Effect Type value to "Enable" that effect based on this value.
panel:getModulatorByName("FX 1 Mix"):setModulatorValue(programData:getByte(129), false, true, true)
Assigns a variable for the 14 possible parameters used in effects
effect1Param1 = programData:getByte(130)
effect1Param2 = programData:getByte(131)
effect1Param3 = programData:getByte(132)
effect1Param4 = programData:getByte(133)
effect1Param5 = programData:getByte(134)
effect1Param6 = programData:getByte(135)
effect1Param7 = programData:getByte(136)
effect1Param8 = programData:getByte(137)
effect1Param9 = programData:getByte(138)
effect1Param10 = programData:getByte(139)
effect1Param11 = programData:getByte(140)
effect1Param12 = programData:getByte(141)
effect1Param13 = programData:getByte(142)
effect1Param14 = programData:getByte(143)fx1Type = programData:getByte(128)
fx2Type = programData:getByte(144)
console (string.format("FX 1 type byte value : %d", fx1Type)) — bug testing
console (string.format("FX 2 type byte value : %d", fx2Type)) — bug testing
console (string.format("Effect 1 Parameter 1 value : %d", effect1Param1)) — bug testingif fx1type == 0 then — all effects are bypassed, setting bypass buttons to ON
panel:getModulatorByName("Chorus 1 Bypass"):setModulatorValue(1, false, true, true)
panel:getModulatorByName("Flanger 1 Bypass"):setModulatorValue(1, false, true, true)
panel:getModulatorByName("Phaser 1 Bypass"):setModulatorValue(1, false, true, true)
panel:getModulatorByName("Overdrive 1 Bypass"):setModulatorValue(1, false, true, true)
panel:getModulatorByName("Triple FX 1 Bypass"):setModulatorValue(1, false, true, true)elseif fx1type == 1 then
panel:getModulatorByName("Chorus 1 Enable"):setModulatorValue(1, false, true, true)
panel:getModulatorByName("Chorus 1 Bypass"):setModulatorValue(0, false, true, true)
panel:getModulatorByName("Chorus 1 Speed"):setModulatorValue(effect1Param1, false, true, true)
panel:getModulatorByName("Chorus 1 Depth"):setModulatorValue(effect1Param2, false, true, true)
[/code:12idefi7]When I run this, I can see that the FX Type byte is correct, the parameter value for the effect is correct, except those modulators don’t get updated like the rest do. The code for Oscillator 1 works just fine, but not for effects. I’m guessing it’s something to do with the variables and assignments of those variables, but it looks like the values are what they’re supposed to be, the panel just doesn’t update for those. I get no errors from LUA indicating syntax problems or typos.
July 21, 2011 at 6:19 pm #2978Any ideas? Need more details?
July 21, 2011 at 6:46 pm #2979what type of components are thet (sliders, buttons?)
July 21, 2011 at 6:58 pm #2980Enable and Bypass are buttons, the parameters are mostly sliders except for a couple combo boxes. None of these get updated. There’s 5 different effects to select from on effects unit 1. The FX Type value (byte 128) determins which effect is enabled. 0 value is bypass, 1 Chorus, 2 Flanger, etc
I can see that FX Type value is correct, so based on that, the If / Elseif statements determine which of the effects gets it’s modulator’s updated. I can also see that I’m getting the right value for the first parameter (effect1Param1), but for some reason when telling it to update the appropriate modulator, like :
[code:a1wirk9f]
elseif fx1type == 1 then
panel:getModulatorByName("Chorus 1 Speed"):setModulatorValue(effect1Param1, false, true, true)
[/code:a1wirk9f]it doesnt’ get updated. And I don’t get an error either indicating I spelled or named somethign wrong, or put in the some wrong syntax.
July 21, 2011 at 7:02 pm #2981well i can’t see any errors in there, i can suggest adding more console() stuff to see what actually gets executed and whats not.
July 21, 2011 at 7:31 pm #2982I think I see everything I can see in the console at that point. I have the effect type, the parameter setting, unless I can see something for the line where it goes to the panel and updates the modulator for :
[code:15cpd6sp]panel:getModulatorByName("Chorus 1 Speed"):setModulatorValue(effect1Param1, false, true, true)[/code:15cpd6sp]
July 21, 2011 at 7:37 pm #2983well the best way is to do step by step
[code:2rzslim3]
mod = panel:getModulatorByName("whatever")
if mod ~= nil then
mod:setModulatorValue()
end
[/code:2rzslim3]can you send the panel ? maybe i can try to see what’s going on.
July 21, 2011 at 9:33 pm #2984I see what you’re doing there. I’ll try that and see what data I get. If it still looks right, I’ll link the bpanelz when I get home tonight.
July 21, 2011 at 10:15 pm #2985i just uploaded a new nightly build, there is an updated midi example that shows how to read and write programs to files, if you can please write one program to a file and attach that with your panel it will allow me to simulate receiving midi dumps on your panel.
July 22, 2011 at 12:48 am #2986I found my problem after doing more values to console testing.
my IF statements say fx1type instead of fx1Type …. :-p
But since I have your attention, I’ll ask here. What would be the way to tell a Tab to display/select tab "Whatever" when value x is received?
July 22, 2011 at 1:04 am #2987you can set it’s value just like any other component, the tabs are indexed from zero, so setting a value of 2 would switch to the 3 tab in a tabbed component
July 22, 2011 at 1:17 am #2988So if I had Tab Group "Effects" and I wanted it to pop over to tab 2 of that group, it would just be something like :
panel:getModulatorByName("Effects"):setModulatorValue(1, false, true, true)
**edit**
That doesn’t work. There’s no error b/c it’s valid, but it doesn’t display the Tab I’ve told it to select.July 22, 2011 at 10:32 am #2989Tabs still don’t receive midi, only send.
July 22, 2011 at 10:46 am #2990i’ll check that asap, i thought i did that but i must have missed something.
July 22, 2011 at 11:32 am #2991"dasfaker":1l04l2l9 wrote:Tabs still don’t receive midi, only send.[/quote:1l04l2l9]That maybe the case, but I’m not sending the Tab any midi. I’m telling LUA in script to change to the tab I’ve specified based on the Tab index and it doesn’t do it.
July 22, 2011 at 11:43 am #2992yes i found it, i missed one very important line of code, i added it and it works, i’ll re-do the builds asap.
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.