Reply To: Global Variable issue. It's drive me crazy.

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

#83436
daimondamps
Participant
  • Topics: 8
  • Replies: 80
  • Total: 88

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 4 years, 1 month ago by daimondamps.
Ctrlr