Global Variable issue. It's drive me crazy.

Home Forums General Programming Global Variable issue. It's drive me crazy.

This topic contains 12 replies, has 3 voices, and was last updated by  daimondamps 1 week, 4 days ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #83397

    daimondamps
    Participant
    • Topics: 7
    • Replies: 42
    • Total: 49

    Hi , I’ve created the panel where global variable k0 is imortant to proper initialize first lua scripts requesting some MIDI dumps.

    The problem is that this variable cannot be set at panel load . It seems that it is always has 0 value when ctrlr is loading a panel.

    This variable is responsible to store a mapped value from combobox.
    I have put this line in the script to initialize a variable after panel is loaded:

    panel:setGlobalVariable(0,50)

    but it is still have zero value.

    EDIT: This variable is used in sysex formula of a lot of modulators as k0. The problem is these modulators are not updated with k0 value(k0 byte is for them always 0) after load until I switch combobox to change k0 value. But I want to set this value at startup that modulators have some start value.

    I have tried to initialize combobox value at init but with the same results.
    Any help?

    • This topic was modified 2 weeks ago by  daimondamps.
    #83399
    Possemo
    Possemo
    Participant
    • Topics: 11
    • Replies: 350
    • Total: 361
    • ★★

    a working syntax for setting global variables:

    panel:setProperty(“panelGlobalVariables”,m1..”:”..m2..”:”..m3, false)

    This sets the first three global vars, add more if needed. m1, m2, m3 are variables you can use plain numbers as well.

    Btw. on what kind of panel are you working on? Is it downloable somewhere?

    #83401

    human fly
    Participant
    • Topics: 117
    • Replies: 985
    • Total: 1102
    • ★★★★

    this tells me that i don’t fully understand what a global
    variable is, in the context described by Possemo.

    but what do i know? so far i just called something local
    if i want it local, or not if i want it accessible from
    another script.

    would it be any use to you to have a table of values that
    you assign at startup? just have a script to send values
    to your modulators – or is that not what you need?

    #83403

    daimondamps
    Participant
    • Topics: 7
    • Replies: 42
    • Total: 49

    a working syntax for setting global variables:

    panel:setProperty(“panelGlobalVariables”,m1..”:”..m2..”:”..m3, false)

    Thank you 🙂 You saved my life.
    Still I have some strange issue that this variable k0 is resseted back to 0 . I have to track this down.

    Btw. on what kind of panel are you working on? Is it downloable somewhere?

    I’m working on Kemper Profiling Amplifier FX editor (see the pic) .
    You can download it here : https://www.dropbox.com/s/86d5ds3d0z55fzu/KPA_FX_EDITOR_1_11.bpanelz?dl=0
    or executable version here : https://www.dropbox.com/s/t0rp7lwqprwlmpw/KPA_FX_EDITOR_1_11.rar?dl=0
    I will upload this panel to github when I finish .
    Yest I know – it’s ugly but my priority was to have all the controls on one screen.

    I have another problem : how to enable the user to enter mapped value in uiFixedImageSlider?
    There was a topic about this but noone answered.

    Typed Values in uiFixedImageSlider

    this tells me that i don’t fully understand what a global
    variable is

    We are talking about predefined build in global variables k0 , k1 ….k16 that you can use in midi predefined messages for modulators or you can us it for value calculation for example without using a LUA.

    • This reply was modified 1 week, 6 days ago by  daimondamps.
    • This reply was modified 1 week, 6 days ago by  daimondamps.
    • This reply was modified 1 week, 6 days ago by  daimondamps.
    Attachments:
    You must be logged in to view attached files.
    #83408
    Possemo
    Possemo
    Participant
    • Topics: 11
    • Replies: 350
    • Total: 361
    • ★★

    your panel looks nice to me. I just don’t want to help people who are selling their panels. When your panel is fininshed I would publish it here on the Ctrlr site. You will get more help when everybody can see that you are not making business with your panels.

    btw. global vars are called k0 to k9, then next one is ka, kb etc. up to kf then it goes on with o0, o1 etc. up to of. Very strange naming convention… I don’t know what’s the next one after of.

    about the fixed values: this is probably a bug in the fixed slider. It just does not react as expected. What you could do is making another box (an uiLabel) and set the fixed slider by a Lua script according to what is entered in the uiLabel.

    #83409

    daimondamps
    Participant
    • Topics: 7
    • Replies: 42
    • Total: 49

    Yes my panel is free for all , only small donate button for guitar players who want to buy me a beer 🙂
    I have published this version in closed FB group and on the Kemper user forum (where I was banned for posting supper top secret hidden SysexMessages 😛 ) https://www.kemper-amps.com/forum/index.php/Thread/19728-KPAEditor-Community-Project-vst-standalone-win-mac-linux-based-on-http-ctrlr-org/?postID=423418#post423418

    Dropbox is not a good solution. It would be great if you could publish it on ctrlr site when i finish.

    One more question. I’m using “query device” method to have up-to date values for modulators. It is just timer that periodically ask device for dumps of modulators values. I’m assign retrivet values to modulators via script.
    The problem is sometimes when user change modulator on a panel in the same time it recive message with different value (from past time ) and the modulator is getting back to that value. Now First solution was to write script wchich will be muting MIDI input and resseting query timer when the user is using any modulator.
    But when I’m using this script with the property
    luaPanelModulatorValueChanged it is triggered also when modulator is changed via the recivedMidi lua script.

    How to avoid that .What are yours solutions to remedy such situations?

    • This reply was modified 1 week, 6 days ago by  daimondamps.
    • This reply was modified 1 week, 6 days ago by  daimondamps.
    • This reply was modified 1 week, 6 days ago by  daimondamps.
    • This reply was modified 1 week, 6 days ago by  daimondamps.
    #83414
    Possemo
    Possemo
    Participant
    • Topics: 11
    • Replies: 350
    • Total: 361
    • ★★

    Hah, you get banned for publishing sysex. I haven’t heard that before. They probably intend to make their own software solution and then sell it to customers who already paid a lot for the hardware ;-). Nice manufacturers such as Yamaha provide a comprehensive sysex implementation chart.

    I see the problem with updating modulators. Well, a timer is either running or stopped. I don’t see what you can do to avoid problems when moving sliders at the same time. I guess you want to be able to display the values when your are moving knobs on the hardware panel. My idea of this is: when you are working on the hardware panel you won’t need the Ctrlr panel. When you are going back to the Ctrlr panel there is a button called something like “get values” or “get editbuffer” to update the Ctrlr panel with the values from the hardware panel. But this is probably not what you wanted to hear.

    #83415

    daimondamps
    Participant
    • Topics: 7
    • Replies: 42
    • Total: 49

    No – they are makers of Acces Virus. Unlimited free updates and software . But they dont like if someone post some sysex stuff because their whole device is based on MIDI . Files (profile of the amps) are in fact MIDI files. RigManager(software for managing Rig files) is based on MIDI via USB. I was trying to convice them to publih USB driver which will expose MIDI ports. Hell – I have done it by myself with usblib and https://www.tobias-erichsen.de/software/virtualmidi.html . I ask Atom to implement usblib in CTRLR and he done this. But USBLIB is blocking their driver for communication with their software RigManager. So i don’t published this for other users.

    They added some feature which will be sending CC messages when user changes something in the device(which have a bug now so its not working) . I think I can use that and get rid of query method. Just initial dump.

    • This reply was modified 1 week, 6 days ago by  daimondamps.
    • This reply was modified 1 week, 6 days ago by  daimondamps.
    • This reply was modified 1 week, 6 days ago by  daimondamps.
    #83419
    Possemo
    Possemo
    Participant
    • Topics: 11
    • Replies: 350
    • Total: 361
    • ★★

    Sorry I still don’t get the point why this should’t be allowed, but no problem. Btw. Sysex is part of the MIDI standard. What you call MIDI file is probably encapsulated sysex in a DAW compatible file format.

    #83420

    daimondamps
    Participant
    • Topics: 7
    • Replies: 42
    • Total: 49

    They publish some beta version of the firmware. And in past times there was a hidden sysexes to enable new delays for example. Some user found a “bug” which enable those new delays and I looked at preset midi file and concluded sysex (nrpn and value) to enable those new features. I’ve published this on this guy thread . They wanted to show this at NAMM as a new feature so I think they were angry that someone posted this. Voila!! 😛 That was my stupid mistake.

    • This reply was modified 1 week, 6 days ago by  daimondamps.
    #83430
    Possemo
    Possemo
    Participant
    • Topics: 11
    • Replies: 350
    • Total: 361
    • ★★

    Ah ok I see, well you couldn’t know that. Btw.: nrpn’s are not sysex. All Sysex messages begin with f0 and end with f7. Nrpn’s are a kind of special CC’s. But that may be nitpicking.

    #83433

    human fly
    Participant
    • Topics: 117
    • Replies: 985
    • Total: 1102
    • ★★★★

    NRPNs are part of the MIDI spec’ same as any other
    data normally published for a device. they’re classed
    as MIDI CC’s afaik.

    you could have got all the data from the device by sending
    it a data request message.

    unless you were privy to some confidential information about
    a forthcoming product or firmware update, it seems hard to
    justify a ban.

    #83436

    daimondamps
    Participant
    • Topics: 7
    • Replies: 42
    • Total: 49

    Ah ok I see, well you couldn’t know that. Btw.: nrpn’s are not sysex. All Sysex messages begin with f0 and end with f7. Nrpn’s are a kind of special CC’s. But that may be nitpicking.

    In KPA NRPNS can be accesed with sysex messages.

    Ok – I’ve found that latest nightly build do not work for me. I’ve downoaded latest recommended version from main site and it is working now with global variables.

    Next thing. Im working for something like FirsTimeRun Window where the user Can set devices only once.
    I will be runing this script in after panel loaded callback.

    What this script does – it checks if panelMidiInputDevice is “– None” then lists avaliable MIDI devices and put it in combobox in modal window.
    When user select in and out device and click ok- it wil set those choices as
    panelMidiInputDevice property for example. And this is almost working.

    The thing is Restricted Instance don’t save these setting on exit, and my script is triggered on every run.

    Here’s code that i have:

    if panel:getProperty("panelMidiOutputDevice")=="-- None" or panel:getProperty("panelMidiInputDevice")=="-- None" then
    
    		saMidiInputDevices = StringArray()
    		for i=0,(utils.getMidiInputDevices():size()) do
    			saMidiInputDevices:set(i, utils.getMidiInputDevices():get(i))
    		end
    
    		saMidiOutputDevices = StringArray()
    		for i=0,(utils.getMidiOutputDevices():size()) do
    			saMidiOutputDevices:set(i, utils.getMidiOutputDevices():get(i))
    		end
    
    		
    
    		modalWindow = AlertWindow("\nFirst time run setup.\nPlease select you MIDI Input and Otput Device", " ", AlertWindow.InfoIcon)
    		modalWindow:addButton("    OK    ", 1, KeyPress(KeyPress.returnKey),KeyPress())
    		modalWindow:addButton("Cancel", 0, KeyPress(KeyPress.escapeKey),KeyPress())
    		modalWindow:addComboBox ("cmbMidiInputDevices", saMidiInputDevices, "MIDI Input Device")
    		modalWindow:addComboBox ("cmbMidiOutputDevices", saMidiOutputDevices, "MIDI Output Device")
    		modalWindow:addTextBlock ("Program will be closed to save changes.")
    
    		ret = modalWindow:runModalLoop()
    
    		if ret == 1 then
    
    			panel:setPropertyString("panelMidiInputDevice",modalWindow:getComboBoxComponent("cmbMidiInputDevices"):getText())
    			panel:setPropertyString("panelMidiOutputDevice",modalWindow:getComboBoxComponent("cmbMidiOutputDevices"):getText())
    			panel:setPropertyString("panelMidiControllerDevice",modalWindow:getComboBoxComponent("cmbMidiInputDevices"):getText())
    
    			--panel:setProgramState(true)
    			--stateData:setProperty("MIDIin", modalWindow:getComboBoxComponent("cmbMidiInputDevices"):getText(), nil)
    			--stateData:setProperty("MIDIout", modalWindow:getComboBoxComponent("cmbMidiOutputDevices"):getText(), nil)
    
    		end
    
    		modalWindow:setVisible (false)
    
    end
    
    end
    • This reply was modified 1 week, 4 days ago by  daimondamps.
Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.

There is currently 0 users and 24 guests online
No users are currently active
Forum Statistics
Threads: 2,099, Posts: 14,729, Members: 7,421
Most users ever online was 5 on March 28, 2018 6:11 pm
Do NOT follow this link or you will be banned from the site!