HISE Logo Forum
    • Categories
    • Register
    • Login

    Helper Function Logic....Placement?

    Scheduled Pinned Locked Moved Solved Scripting
    24 Posts 3 Posters 130 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 @d.healey
      last edited by

      @d-healey That just opened my mind to so much. Crucial fact. Thanks guys!

      @dannytaurus 🙏

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

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

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

          @Chazrox Where is the function call?

          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

            interface
            {
             
            inline function myHelper()
            }
                // Need to do this call }
            
               namespace SomeFunctions
               {
            
                    inline function SystemFunction()
                    {
            
                      myHelper();
            
                    }
            
               }
            }
            
            
            d.healeyD 1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey @Chazrox
              last edited by

              @Chazrox

              This code isn't valid

              interface
              {
              inline function myHelper();
              }
              

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

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

                  @Chazrox

                  Here's an example

                  namespace HelperFunctions
                  {
                      inline function doAThing()
                      {
                          Console.print("Hello World");
                      }
                  
                      doAThing();
                  }
                  
                  HelperFunctions.doAThing();
                  
                  

                  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 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);
                    
                    d.healeyD 1 Reply Last reply Reply Quote 0
                    • ChazroxC Chazrox marked this topic as a question
                    • d.healeyD
                      d.healey @Chazrox
                      last edited by

                      @Chazrox what's the timer for? Show me where you're calling it after the file drop.

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

                          @Chazrox said in Helper Function Logic....Placement?:

                          this.data.filename = base; // paint()
                          this.data.fileName = base;

                          What's going on here?

                          @Chazrox said in Helper Function Logic....Placement?:

                          disableAllChords();
                          disableAllChords();

                          And here?

                          I think you need to start by breaking that massive function into smaller more manageable sub functions. It's too chaotic at the moment.

                          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

                            @d-healey said in Helper Function Logic....Placement?:

                            It's too chaotic at the moment.

                            it is.

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

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

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

                                @Chazrox Yeah clean it up, remove the duplication, then we'll work on the combo box

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

                                  Screenshot 2025-09-02 at 1.58.12 AM.png

                                  Screenshot 2025-09-02 at 2.00.06 AM.png

                                  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.

                                  d.healeyD 1 Reply Last reply Reply Quote 0
                                  • ChazroxC Chazrox has marked this topic as solved
                                  • d.healeyD
                                    d.healey @Chazrox
                                    last edited by

                                    @Chazrox said in Helper Function Logic....Placement?:

                                    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?

                                    The two are unrelated, you can have multiple namespaces in a single file if you wanted to.

                                    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

                                      @d-healey Im learning.

                                      via GIPHY

                                      1 Reply Last reply Reply Quote 0
                                      • First post
                                        Last post

                                      34

                                      Online

                                      1.9k

                                      Users

                                      12.4k

                                      Topics

                                      108.2k

                                      Posts