HISE Logo Forum
    • Categories
    • Register
    • Login

    AppData Folder || My Custom presets dont compile....

    Scheduled Pinned Locked Moved Solved Scripting
    16 Posts 2 Posters 248 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ChazroxC
      Chazrox
      last edited by

      I have a custom preset menu that saves synth parameters. The parameters save and load successfully in HISE but they dont compile with the plugin. I also noticed there's a "Project AppData" Folder and a "HISE AppData" Folder. The one that my presets save to are the folder in my Application support/PluginNAME folder. What folder is best to save these menu presets in so that they compile and load with the plugin? The last DAW test I did, my custom menu presets names show up (probably only because they were last exported with the viewport already populated because when I press "save new preset" on my customMenu all the names clear out. I check the .json file for the presets menu that it creates and all of the parameters say undefined. How is that if they work fine in HISE? Is it a folder issue?

      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @Chazrox
        last edited by

        @Chazrox
        Use the app data folder for users to save and load their own presets.

        The only external data of that kind that's embedded in the plugin are script files. If you want to provide some default presets they need to be in scripts. The alternative is you bundle the presets with your installer and have the installer place them in the app data folder.

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        ChazroxC 1 Reply Last reply Reply Quote 0
        • ChazroxC
          Chazrox @d.healey
          last edited by Chazrox

          @d-healey

          What do you mean by this?

          @d-healey said in AppData Folder || My Custom presets dont compile....:

          need to be in scripts.

          d.healeyD 1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey @Chazrox
            last edited by

            @Chazrox .js files in the project's Scripts folder that are included in your script.

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            ChazroxC 1 Reply Last reply Reply Quote 1
            • ChazroxC
              Chazrox @d.healey
              last edited by Chazrox

              @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"));
              }
              
              d.healeyD 1 Reply Last reply Reply Quote 0
              • d.healeyD
                d.healey @Chazrox
                last edited by

                @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.

                Libre Wave - Freedom respecting instruments and effects
                My Patreon - HISE tutorials
                YouTube Channel - Public HISE tutorials

                ChazroxC 2 Replies Last reply Reply Quote 0
                • ChazroxC
                  Chazrox @d.healey
                  last edited by

                  @d-healey

                  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"));
                  
                  1 Reply Last reply Reply Quote 1
                  • ChazroxC
                    Chazrox @d.healey
                    last edited by Chazrox

                    @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...

                    1. grab current preset name.
                    2. create an empty object to hold 'combined' keys.
                    3. declare both objects. 'factory presets' and 'user presets'.
                    4. loop/grab key/names from both objects and push them to 'combined' preset names.
                    5. .sortNatural() 'combined' preset list.
                    6. Check if 'preset/name/key' exists.
                    7. 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.

                    d.healeyD 1 Reply Last reply Reply Quote 0
                    • d.healeyD
                      d.healey @Chazrox
                      last edited by

                      @Chazrox

                      reg variables only go in on init. Use local within inline 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.

                      Libre Wave - Freedom respecting instruments and effects
                      My Patreon - HISE tutorials
                      YouTube Channel - Public HISE tutorials

                      ChazroxC 1 Reply Last reply Reply Quote 0
                      • ChazroxC
                        Chazrox @d.healey
                        last edited by

                        @d-healey how do I combine two objects?

                        d.healeyD 1 Reply Last reply Reply Quote 0
                        • d.healeyD
                          d.healey @Chazrox
                          last edited by

                          @Chazrox That can be difficult - I have a whole thread on it somewhere. How many levels deep do you need to combine?

                          Libre Wave - Freedom respecting instruments and effects
                          My Patreon - HISE tutorials
                          YouTube Channel - Public HISE tutorials

                          ChazroxC 1 Reply Last reply Reply Quote 1
                          • ChazroxC
                            Chazrox @d.healey
                            last edited by Chazrox

                            @d-healey
                            Im WILLING! lol

                            //This is the situation I need, atleast as best as I understood your question. 
                            
                            objectA[i] + objectB[i] = objectC;
                            
                            
                            d.healeyD 1 Reply Last reply Reply Quote 0
                            • d.healeyD
                              d.healey @Chazrox
                              last edited by

                              @Chazrox

                              What is in objectA and objectB? Give me some dummy data.

                              Libre Wave - Freedom respecting instruments and effects
                              My Patreon - HISE tutorials
                              YouTube Channel - Public HISE tutorials

                              ChazroxC 1 Reply Last reply Reply Quote 0
                              • ChazroxC
                                Chazrox @d.healey
                                last edited by Chazrox

                                @d-healey

                                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
                                  ]
                                
                                d.healeyD 1 Reply Last reply Reply Quote 0
                                • d.healeyD
                                  d.healey @Chazrox
                                  last edited by

                                  @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.

                                  Libre Wave - Freedom respecting instruments and effects
                                  My Patreon - HISE tutorials
                                  YouTube Channel - Public HISE tutorials

                                  ChazroxC 1 Reply Last reply Reply Quote 0
                                  • ChazroxC
                                    Chazrox @d.healey
                                    last edited by Chazrox

                                    @d-healey That worked great! 🙏 ok noooooow im done. 🤣

                                    **I have 3 other menus. 😭 lol

                                    1 Reply Last reply Reply Quote 1
                                    • ChazroxC Chazrox has marked this topic as solved
                                    • First post
                                      Last post

                                    21

                                    Online

                                    1.9k

                                    Users

                                    12.4k

                                    Topics

                                    108.2k

                                    Posts