What does this do?

Posts
-
RE: Get Num items in Combobox?
@d-healey That worked. Was confusing at first but I get it now.
-
RE: DisplayBuffer in compiled network causing crash
@dane-zone idk if by setting it in projucer is any different but I use that tag in my HISE project settings 'preprocessors' and it works fine. "NUM_MAX-CHANNELS =24" is exactly what Im using under EXTRA DEFINITIONS OSX.
-
VIEWPORT || How can I .getItemText() or something similar??
Im trying to script a "delete" preset button but I need to get the item name of the selected index of my viewPort panel. Does anybody know how?
Here's my delete script that doesnt get passed getting the name. This same script works for combobox but I switched it to a viewport panel and I cant get it to work without getting the name.
please help
Thanks!inline function onbtnSynthDeletePresetControl(component, value) { if (!value) return; //------------------------------------------------------------------- local selectedIndex = vpSynthPresets.getValue(); Console.print(selectedIndex); if (selectedIndex <= 0) return; //------------------------------------------------------------------- // Get preset name //-----------------THIS HERE NOT WORKING----------------------// reg presetNameToDelete = vpSynthPresets.getItemText(); // THIS NOT WORKING HERE Console.print(presetNameToDelete); if (!isDefined(SynthAndFXPresetsFile[presetNameToDelete])) return; //------------------------------------------------------------------- Engine.showYesNoWindow("Delete Preset", "Are you sure you want to delete \"" + presetNameToDelete + "\"?", function(result) // nested callback { var thisValueNOW = vpSynthPresets.getValue(); if (result) // IF 'YES' { var newPresets = {}; for (k in SynthAndFXPresets) { if (k != presetNameToDelete) newPresets[k] = SynthAndFXPresets[k]; } //------------------------------------------------------------------- SynthAndFXPresets = newPresets; //------------------------------------------------------------------- SynthAndFXPresetsFile.writeObject(SynthAndFXPresets); //------------------------------------------------------------------- var keyListSynth = []; // Create array for key names for (k in SynthAndFXPresets) // Get key names from .json object keyListSynth.push(k); // Push names to array //------------------------------------------------------------------- vpSynthPresets.set("items", keyListSynth.join("\n")); // Populate Combobox //------------------------------------------------------------------- vpSynthPresets.setValue(thisValueNOW + 1); // Set to preset previous //------------------------------------------------------------------- lblSynthNameToSave.set("text", ""); // Clear text } }); }; Content.getComponent("btnSynthDeletePreset").setControlCallback(onbtnSynthDeletePresetControl);
-
RE: Get Num items in Combobox?
@d-healey How do I get the itemText of the currently selected index of a viewport panel? Im gonna use a viewport instead of combobox.
-
RE: Get Num items in Combobox?
@Christoph-Hart Thanks! I'll check that. That sounds way easier.
-
RE: Helper Function Logic....Placement?
@d-healey I figured it out and it only took reading the entire script from top to bottom an back all the way up to the top to find this....
I changed the namespace name and now everything works fine. dang I hate when its something like this. Thanks for the help!
**This just raised a question as well.... if the name of the external file and the name of the namespace doesnt have to be the same, that would make a namespace just a holder of some sort?
and/or I just dont know enough about includes.
-
RE: Helper Function Logic....Placement?
@d-healey said in Helper Function Logic....Placement?:
What's going on here?
setting panel data for other functions to read like my paint functions.
its a mess in here at the moment. but i'll def clean it up. i've been doing the most trying to fix this but im def making a mess.
-
RE: Helper Function Logic....Placement? posted in Scripting
-
RE: Helper Function Logic....Placement?
@d-healey
The timer is just a hacky attempt to see if I can get it to work.Im trying to get my combobox to update after a drop a new file. The combobox searches the appData folder for .mid files and populates the combobox items list.
I want it to happen here somewhere. Someplaces I drop it, it doesnt do anything...in another spot, it duplicates everything in the combobox like 3-4 times and if I keep going it just stacks up.
can you suggest where to put .updateMidiFilesComboBox(); ?
inline function onpnlMIDIFilesFileDrop_B(obj) { //Console.print(trace(obj) + "TRACE TRACE TRACE"); // HOVER STATE local prevHover = this.data.hover ? 1 : 0; this.data.hover = (obj.hover && !obj.drop) ? 1 : 0; if ((this.data.hover ? 1 : 0) != prevHover) { this.repaint(); } // HOVER CHECK if (obj.hover && !obj.drop) { this.data.text = "Drop to load!"; this.data.dropped = false; this.changed(); return; } if (!obj.drop || obj.fileName == undefined) { return; } // PARSE BASE NAME local full = obj.fileName; local slash = Math.max(full.lastIndexOf("/"), full.lastIndexOf("\\")); local dot = full.lastIndexOf("."); //============ Console.print("full contains:" + full); //============= if (dot < 0) { dot = full.length; } local base = full.substring(slash + 1, dot); this.data.filename = base; // paint() this.data.fileName = base; // sync Console.print("BASE__" + base); // HIDE RANGE SLIDER WHILE NO EVENTS RangeSlider.set("visible", 0); // LOAD MIDI PLAYER TRACK 1 MIDIPlayer1.setFile(full, true, true); if (MIDIPlayer1.setTrack != undefined) MIDIPlayer1.setTrack(1); // START POLLING EVENTS midiRangeTimer.stopTimer(); midiRangeTimer.startTimer(50); // ----------------------------------------------------------- // COPY DROPPED FILE INTO AppData // ----------------------------------------------------------- local original = FileSystem.fromAbsolutePath(full); //=========== Console.print("Original contains:" + original); Console.print("Original is defined ==:" + (original != undefined)); Console.print("Original is a file ==:" + (original != undefined)); //=========== local filename = full.substring(slash + 1 ); if (original != undefined) { Console.print(filename + "IS DEFINED"); Console.print("ORIGINAL__" + original); local appDataDir = FileSystem.getFolder(FileSystem.AppData); local newFile = appDataDir.getChildFile(base + ".mid"); original.copy(newFile); newFile.move(appDataDir); Console.print("NEWNEWNEW" + newFile); Console.print("Saved copy to AppData: " + base); } setAnalysisWindowFull(); disableAllChords(); disableAllChords(); // UI flags this.data.text = "Loaded"; this.data.dropped = true; this.data.hover = false; this.changed(); this.repaint(); knbSmartStrength.changed(); pnlCustomMidiPanel.sendRepaintMessage(); pnlCustomMidiRipView.sendRepaintMessage(); Console.print("DROP PANEL B WAS USED"); }
-
RE: Helper Function Logic....Placement?
@d-healey Heres my exact use case...
I have a file drop panel that saves a copy of a midi files to the app data folder.
I just want the combobox to reflect the added items.I tried adding namespace.updateMidiFilesComboBox();
and
just .updateMidiFilesComboBox();
but both give the error that '.updateMidiFilesComboBox' expression is not a function (both ways)
hence me trying to figure out how to jump around namespaces rn...
I've tried calling this function FROM the end of the panel drop function but that gives the same error hence me trying a timer callback.// This is in a namespace const var appDataDir2 = FileSystem.getFolder(FileSystem.AppData); var midiFiles = FileSystem.findFiles(appDataDir2, "*.mid", false); cmbMidiFiles.set("items", ""); inline function updateMidiFilesComboBox() { for (i = 0; i < midiFiles.length; i++) { Console.print(midiFiles[i]); cmbMidiFiles.addItem(midiFiles[i].toString(Filename).replace("/Users/user/Library/Application Support/MANGO WORLD/KEYZIE V29/", "").replace(".mid")); } Console.print("PANEL MIDI MIDI" + trace(pnlMIDIFiles)); } updateMidiFilesComboBox();
//this is in onInit const var midiComboBoxTimer = Engine.createTimerObject(); midiComboBoxTimer.setTimerCallback(function(component, value) { updateMidiFilesComboBox(); }); midiComboBoxTimer.startTimer(200);
-
RE: Helper Function Logic....Placement?
@d-healey aww that was a typo just right here. in my code its proper. what about the structure of the whole thing and the way the code flows? Does it reach my helper on interface script?
Sorry I feel like I wasted your time with that stupid typo.
-
RE: Helper Function Logic....Placement?
interface { inline function myHelper() } // Need to do this call } namespace SomeFunctions { inline function SystemFunction() { myHelper(); } } }
-
RE: Helper Function Logic....Placement?
@d-healey What if you're inside of a namespace, and you have a function calling to a helper on onInit. Does that need special method?
-
RE: Helper Function Logic....Placement?
@d-healey That just opened my mind to so much. Crucial fact. Thanks guys!