AppData Folder || My Custom presets dont compile....
-
@Chazrox
.js
files in the project's Scripts folder that are included in your script. -
@d-healey oh, so instead of writing to AppData, should I be just writing to an object in an .include?
If I want those to be "factory settings" AND I want the user to be able to add their own presets, how do I go about that?concat the arrays of keys is my guess....
How do I disable being able to delete the "factory settings"?
Current script:
//-------------------------- FILE & OBJECT DECLARATION ------------------------ // File path for saving/loading ----> const var SynthAndFXPresetsFile = FileSystem.getFolder(FileSystem.AppData).getChildFile("KeyzieSynthAndFXPresets.json"); // Declare object to hold presets ----> reg SynthAndFXPresets = {}; // LOAD OBJECT AND POPULATE COMBOBOX ------------------------------------------------------------------------------- if (SynthAndFXPresetsFile.isFile()) { // Load object IN ----> SynthAndFXPresets = SynthAndFXPresetsFile.loadAsObject(); // Extract keys from object ----> var keyListSynth = []; for (s in SynthAndFXPresets) keyListSynth.push(s); // Set Combobox items with extracted keys ----> vpSynthPresets.set("items", keyListSynth.join("\n")); }
-
@Chazrox factory presets go in an include, user presets go in app data.
You can check where the preset is coming from to know if it's a factory one.
-
I dont know if this is the best way but it works.
// Load object IN ----> SynthAndFXPresets = SynthAndFXPresetsFile.loadAsObject(); // Extract keys from object ----> var keyListSynth = []; var factorykeyListSynth = FactorySynthPresets; for (s in SynthAndFXPresets) keyListSynth.push(s); for (k in factorykeyListSynth) { keyListSynth.push(k); Console.print(k); } vpSynthPresets.set("items", keyListSynth.join("\n"));
-
@d-healey can you please just check my homework here please. I think im routing something wrong but I dont see it......yet....
This is my viewport control script:
inline function onvpSynthPresetsControl(component, value) { Console.print(value); // GET BY INDEX IN CURRENT LIST ------>GET VALUE reg currentSynthPreset = vpSynthPresets.get("items").split("\n")[vpSynthPresets.getValue()]; Console.print(value + "name is " + currentSynthPreset + "CURRENTLY SELECTED VPSYNTH"); //Create a list to hold all presets combined. local allSynthPresetsNOW = []; // Declare both lists. // Factory in Local Object local factorySynthPresetsNOWB = FactorySynthPresets; // User in AppData Folder local presetData = {}; presetData = SynthAndFXPresetsFile.loadAsObject(); // Push User Presets to combined list. for (p in presetData) { allSynthPresetsNOW.push(p); } // Push Factory Presets to combined list. for (f in factorySynthPresetsNOWB) { allSynthPresetsNOW.push(f); } allSynthPresetsNOW.sortNatural(); // Check 'if preset exists' load presets data from combined list 'allSynthPrestsNOW'. if (allSynthPresetsNOW) btnHPF.setValue(allSynthPresetsNOW[currentSynthPreset][0]); btnLPF.setValue(allSynthPresetsNOW[currentSynthPreset][1]); btnReverb.setValue(allSynthPresetsNOW[currentSynthPreset][2]); btnDelay.setValue(allSynthPresetsNOW[currentSynthPreset][3]); btnLPFMod.setValue(allSynthPresetsNOW[currentSynthPreset][4]); knbHPF.setValue(allSynthPresetsNOW[currentSynthPreset][5]); knbLPF.setValue(allSynthPresetsNOW[currentSynthPreset][6]); knbReverbAmount.setValue(allSynthPresetsNOW[currentSynthPreset][7]); knbLPF1ModSpeed.setValue(allSynthPresetsNOW[currentSynthPreset][8]); knbLPF1ModSpeedIntensity.setValue(allSynthPresetsNOW[currentSynthPreset][9]); knbReverbSize.setValue(allSynthPresetsNOW[currentSynthPreset][10]); knbWaveForm.setValue(allSynthPresetsNOW[currentSynthPreset][11]); knbDelay.setValue(allSynthPresetsNOW[currentSynthPreset][12]); knbDelayTimes.setValue(allSynthPresetsNOW[currentSynthPreset][13]); btnChorus.setValue(allSynthPresetsNOW[currentSynthPreset][14]); btnPhase.setValue(allSynthPresetsNOW[currentSynthPreset][15]); knbChorusAmount.setValue(allSynthPresetsNOW[currentSynthPreset][16]); knbPhaseAmount.setValue(allSynthPresetsNOW[currentSynthPreset][17]); btnShapeFX.setValue(allSynthPresetsNOW[currentSynthPreset][18]); knbShapeFXAmount.setValue(allSynthPresetsNOW[currentSynthPreset][19]); btnShapeFX.changed(); knbShapeFXAmount.changed(); btnChorus.changed(); btnPhase.changed(); knbChorusAmount.changed(); knbPhaseAmount.changed(); knbDelay.changed(); knbDelayTimes.changed(); btnHPF.changed(); btnLPF.changed(); btnReverb.changed(); btnDelay.changed(); btnLPFMod.changed(); knbHPF.changed(); knbLPF.changed(); knbReverbAmount.changed(); knbLPF1ModSpeed.changed(); knbLPF1ModSpeedIntensity.changed(); knbReverbSize.changed(); knbHPF.sendRepaintMessage(); knbLPF.sendRepaintMessage(); knbWaveForm.changed(); knbReverbAmount.sendRepaintMessage(); knbLPF1ModSpeed.sendRepaintMessage(); knbLPF1ModSpeedIntensity.sendRepaintMessage(); knbReverbSize.sendRepaintMessage(); }; Content.getComponent("vpSynthPresets").setControlCallback(onvpSynthPresetsControl);
*** Im just gonna talk this out here...
- grab current preset name.
- create an empty object to hold 'combined' keys.
- declare both objects. 'factory presets' and 'user presets'.
- loop/grab key/names from both objects and push them to 'combined' preset names.
- .sortNatural() 'combined' preset list.
- Check if 'preset/name/key' exists.
- if object exists, load values by 'preset name'[viewport value] // Should match sorted list.
As far as my brain can figure out right now, this should work...but obviously not.
-
reg
variables only go inon init
. Uselocal
withininline functions
.You need curly braces
// Check 'if preset exists' load presets data from combined list 'allSynthPrestsNOW'. if (allSynthPresetsNOW)
The contents of that if statement looks very hard to maintain.
-
@d-healey how do I combine two objects?
-
@Chazrox That can be difficult - I have a whole thread on it somewhere. How many levels deep do you need to combine?
-
@d-healey
Im WILLING! lol//This is the situation I need, atleast as best as I understood your question. objectA[i] + objectB[i] = objectC;
-
What is in objectA and objectB? Give me some dummy data.
-
const var FactoryPresets = { [ "Default": [0,0,0,0], "Rockin": [9,9,9,9] ]}; const var UserSavedPresets = { [ "Dummy1": [0,0,0,0], "Dumber1": [9,9,9,9] ]}; // I need this.... const var AllPresetsCombined = {[ "Default": [0,0,0,0], "Rockin": [9,9,9,9], "Dummy1": [0,0,0,0], "Dumber1": [9,9,9,9] ]};
this is an actual preset in my FactorySettings
"DEFAULT": [ 1.0, 0.0, 0.0, 0.0, 0.0, 382.0, 20.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
-
@Chazrox You have too many square brackets there, but I get the idea. You can combine these with a loop.
Here's an example:
inline function combineObjects(objA, objB) { local result = {}; for (x in objA) result[x] = objA[x]; for (x in objB) result[x] = objB[x]; return result; }
If both objects contain an entry with the same key, the one from obj B will be the one that's used.
-
@d-healey That worked great!
ok noooooow im done.
**I have 3 other menus.
lol
-
C Chazrox has marked this topic as solved