HISE Logo Forum
    • Categories
    • Register
    • Login

    Print array index

    Scheduled Pinned Locked Moved Scripting
    19 Posts 3 Posters 1.9k 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.
    • Dan KorneffD
      Dan Korneff
      last edited by

      Almost got it figured out.... 😀

      Dan Korneff - Producer / Mixer / Audio Nerd

      1 Reply Last reply Reply Quote 0
      • Dan KorneffD
        Dan Korneff
        last edited by Dan Korneff

        ugh... I'm so close, but my code is crashing hise :(
        I can't post a snippit cause the xml crashes on open... but here's the code from the interface file:
        Does anything look whack enough to bring down HISE?

        Content.makeFrontInterface(500, 300);
        
        const var Sampler = Content.getComponent("Sampler");
        const var Sampler2 = Content.getComponent("Sampler2");
        const var Gain = Content.getComponent("Gain");
        const var Pan = Content.getComponent("Pan");
        const var SamplerGain = Content.getComponent("SamplerGain");
        const var SamplerPan = Content.getComponent("SamplerPan");
        const var Sampler2Gain = Content.getComponent("Sampler2Gain");
        const var Sampler2Pan = Content.getComponent("Sampler2Pan");
        
        //create arrays
        
        const var SamplerSelectButtonArray =      [
                                                Content.getComponent("Sampler"),
                                                Content.getComponent("Sampler2")
                                            ];
                                       
        const var ControlSelectButtonArray = [
                                                Content.getComponent("Gain"),
                                                Content.getComponent("Pan")
                                            ];
                                       
        const var GainSliderArray =         [
                                                Content.getComponent("SamplerGain"),
                                                Content.getComponent("Sampler2Gain")
                                            ];
                                            
        const var PanSliderArray =         [
                                                Content.getComponent("SamplerPan"),
                                                Content.getComponent("Sampler2Pan")
                                            ];
                                            
        const var empty = []
                                            
                                            
        // Gain page index
        inline function showPageGain(pageIndex)
        {
            for(k in GainSliderArray[0]) 
            {
                k.showControl(pageIndex == 0);
            }
            
            for(k in GainSliderArray[1]) 
            {
            
                k.showControl(pageIndex == 1);
            }
            
                for(k in empty) 
            {
            
                k.showControl(pageIndex == 2);
            }
        }
        
        // Pan page index
        inline function showPagePan(pageIndex)
        {
            for(k in PanSliderArray[0]) 
            {
                k.showControl(pageIndex == 0);
            }
            
            for(k in PanSliderArray[1]) 
            {
            
                k.showControl(pageIndex == 1);
            }
            
                for(k in empty) 
            {
            
                k.showControl(pageIndex == 2);
            }
        }
                                   
        inline function buttonCallback(component, value)
        {
            if(value)
            {
                local x = SamplerSelectButtonArray.indexOf(component);
                local y = ControlSelectButtonArray.indexOf(component);
                
                            if(x == true)
                        
                    {
                        showPageGain(y);}
                    else
                        {showPageGain(2);
                    }
                    
                    
                    if(y == true)
                    {
                        showPagePan(y);}
                        
                    else
                        {showPagePan(2);
                    }
                
            }
        }
        
        
        for(a in SamplerSelectButtonArray)
            a.setControlCallback(buttonCallback);
            
        for(b in ControlSelectButtonArray)
            b.setControlCallback(buttonCallback);
        function onNoteOn()
        {
        	
        }
        function onNoteOff()
        {
        	
        }
        function onController()
        {
        	
        }
        function onTimer()
        {
        	
        }
        function onControl(number, value)
        {
        	
        }
        
        

        Dan Korneff - Producer / Mixer / Audio Nerd

        1 Reply Last reply Reply Quote 0
        • Dan KorneffD
          Dan Korneff
          last edited by

          looks like this is causing it:

          if(x == true)
                          
                      {
                          showPageGain(y);}
                      else
                          {showPageGain(2);
                      }
                      
                      
                      if(y == true)
                      {
                          showPagePan(y);}
                          
                      else
                          {showPagePan(2);
                      }

          Dan Korneff - Producer / Mixer / Audio Nerd

          1 Reply Last reply Reply Quote 0
          • Christoph HartC
            Christoph Hart
            last edited by

            Which HISE version are you using? I remember fixing a crash a few weeks ago that happened when you try to iterate over an object that isn't iteratable (eg. a module reference obtained by Content.getComponent() et al.), which is exactly what you trying to do with:

            for(k in GainSliderArray[0]) 
            {
                k.showControl(pageIndex == 0);
            }
            

            This is not how the for(... in ...) loop works. You want to iterate over the array, not the first element of it, so you need to remove the array subscription from the iterated object:

            for(k in GainSliderArray) 
            {
                k.showControl(pageIndex == 0);
            }
            
            Dan KorneffD 1 Reply Last reply Reply Quote 0
            • Dan KorneffD
              Dan Korneff
              last edited by

              I've gotten much closer to the goal.... just one thing left. Switching between Sampler1 and Sampler2 doesn't update my display until I select the Gain/Pan button. Any suggestions?

              HiseSnippet 1808.3oc6Z8+aSaDE2tslQxZPvD+v9kIYg1jR0JsIlBrIDhzlRYUiRiZJnIMwPGNWROUm6rNeoqYnJs+G1+H6OA9Sh+C1d2Y63yoNo1PJaikHDDe26Kededu676tPKNyEGDv3FlkNbnO1vbYq1CohiZdDhPM1caCyqZIvABaGisF5iBBvcLLMW7IxYMKsjg5y6dzVHOD0EmLjgwKXDW7SI8IhjQa03GIdd6f5fOjzWS5MZrqKi1j4wF.HYQqZF9H2iQ8vOCIEaAKCSqG2gHX71BD.GCyk1h0YX6iX+JMT9WPBHu1CKentQavPgCuCyqiDwxQMZdDwqSq3HNvvv7JsRh+ECi+aZsGoCYz3I7v0USXmngNeXtvzfWcc3UK+vyTCdKEBuaX01kS7EIyHw1masKUf4cQPJPGVgxZrvStlUSFHAUrVezw3c3vCizn5cqUaU66Tq1JOnR4JkgDAjtOAwsai566g41OzNV4dXQSVeeFEdn5shl+VR8NmVNWjZNiomrjZh5HmbL4aglr3vbYipo5DMYxV6o4xDQl.ejGW6LYe6jCm6D68JkWecWNFpEsQbNZXP5DKxy60CDB3Yvh+bkx1S3yEj1W88TSm2CUCIlBqlhPlrRuL6J91XOrqXKEEsoj+.ZR8YJb0ri6JJWlOKIC0KPDclP5TNyKKl3ClDtvb4LI29AD7RtstDks8Hcv7Tk.yvpfPdXlEAYFFNW9ggyGi3nNjsubCiYa4T1IiK8fv4RNJv88Ep8.dYd0MeRs95gu+2G54ylP6fOsRYB0iPw1cGPcEDF0N.ZmpELuTvpRA2UJGDruIzKcY7pGCJm4x2UhfxaRPzwqIsXzFcIFz9gOzV0JjTlyB+mLbfyzcPtbS8y4lJkOK7s2p1axCa.xcwjQ55tYOWLU6+gPESsnYbJIrmllxtafSOT0Md0wpPoq2.bB4P5VMdjw3g0WO.qpzIHncc6S0.ur7Gf5D6QXMUh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7JDUTO+TwzRWeoUHbska1a+oQ6BK9+91ElF0E28pM3ct3e444ksTa0aKaG4eJnd.af.ZyH9U8VP+.sgdfbw5cErfrSivmqEez91XZG0C+E7IZx5wsPHmrd7jFtwlBhsnuqNNq4hXp7MGptf8flS7zKoCfNsjPBdglQfJo1W9RnkjLGLVazI3vcXBwyDamZOhaKFPlv5H4lNVOn.8dpc30OkZ9bJr07lOm2747lOm2747lOm2747lOm2747lOm0Me9wHn6ib4rW4F9COIC8qpFAP.U8ek3RV6Ie1td7u0jLY0Gdu2qbckqptMjtxVCmBqwcJrFaTXMtag03dEVi6WXM9tongrIiMGHX8C2i0v3uoArm2C
              
              Content.makeFrontInterface(500, 300);
              
              const var Sampler = Content.getComponent("Sampler");
              const var Sampler2 = Content.getComponent("Sampler2");
              const var Gain = Content.getComponent("Gain");
              const var Pan = Content.getComponent("Pan");
              const var SamplerGain = Content.getComponent("SamplerGain");
              const var SamplerPan = Content.getComponent("SamplerPan");
              const var Sampler2Gain = Content.getComponent("Sampler2Gain");
              const var Sampler2Pan = Content.getComponent("Sampler2Pan");
              
              //create arrays
              
              const var allbuttons = [
                                      Content.getComponent("Sampler"),
                                      Content.getComponent("Sampler2"),
                                      Content.getComponent("Gain"),
                                      Content.getComponent("Pan")
                                      ];
              
              const var SamplerSelectButtonArray =      [
                                                      Content.getComponent("Sampler"),
                                                      Content.getComponent("Sampler2")
                                                  ];
                                             
              const var ControlSelectButtonArray = [
                                                      Content.getComponent("Gain"),
                                                      Content.getComponent("Pan")
                                                  ];
                                             
              const var Samp1GainSliderArray =         [
                                                      Content.getComponent("SamplerGain")
                                                  ];
                                                  
              const var Samp2GainSliderArray =         [
                                                      Content.getComponent("Sampler2Gain")
                                                  ];
                                                  
              const var Samp1PanSliderArray =         [
                                                      Content.getComponent("SamplerPan")
                                                  ];
                                                  
              const var Samp2PanSliderArray =         [
                                                      Content.getComponent("Sampler2Pan")
                                                  ];
                                                  
              const var empty = []
                                                  
                                                  
              // Gain page index
              inline function showPageGain(pageIndex)
              {
                  for(k in Samp1GainSliderArray) 
                  {
                      k.showControl(pageIndex == 0);
                  }
                  
                  for(k in Samp2GainSliderArray) 
                  {
                  
                      k.showControl(pageIndex == 1);
                  }
                  
              
              }
              
              // Pan page index
              inline function showPagePan(pageIndex)
              {
                  for(k in Samp1PanSliderArray) 
                  {
                      k.showControl(pageIndex == 0);
                  }
                  
                  for(k in Samp2PanSliderArray) 
                  {
                  
                      k.showControl(pageIndex == 1);
                  }
                  
              
              }
                                         
              inline function buttonCallback(component, value)
              {
                  if(value)
                  {
                      //set variable x 
                      var x = SamplerSelectButtonArray.indexOf(component);
              Console.print(x);
                      
                  }
              }
              for(a in allbuttons)
                  a.setControlCallback(buttonCallback);
              
                  
              
              inline function onGainControl(component, value)
              {
              	if(value)
                  {
                      showPageGain(x);}
                  else if(1-value)
                    {  showPageGain(2);
                  }
              };
              
              Content.getComponent("Gain").setControlCallback(onGainControl);
              
              
              inline function onPanControl(component, value)
              {
              		if(value)
                  {
                      showPagePan(x);}
                  else if(1-value)
                    {  showPagePan(2);
                  }
              };
              
              Content.getComponent("Pan").setControlCallback(onPanControl);
              
              
              
              

              Dan Korneff - Producer / Mixer / Audio Nerd

              1 Reply Last reply Reply Quote 0
              • Dan KorneffD
                Dan Korneff @Christoph Hart
                last edited by

                @christoph-hart The build is May3 2018. I'll update to the latest today.

                Dan Korneff - Producer / Mixer / Audio Nerd

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

                  @dustbro The latest is in the develop branch but there might be bugs.

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

                  Dan KorneffD 1 Reply Last reply Reply Quote 1
                  • Dan KorneffD
                    Dan Korneff
                    last edited by

                    Finally figured it out!

                    Content.makeFrontInterface(500, 300);
                    
                    const var Sampler = Content.getComponent("Sampler");
                    const var Sampler2 = Content.getComponent("Sampler2");
                    const var Gain = Content.getComponent("Gain");
                    const var Pan = Content.getComponent("Pan");
                    const var SamplerGain = Content.getComponent("SamplerGain");
                    const var SamplerPan = Content.getComponent("SamplerPan");
                    const var Sampler2Gain = Content.getComponent("Sampler2Gain");
                    const var Sampler2Pan = Content.getComponent("Sampler2Pan");
                    
                    //create arrays
                    
                    
                    
                    const var SamplerSelectButtonArray =      [
                                                            Content.getComponent("Sampler"),
                                                            Content.getComponent("Sampler2")
                                                        ];
                                                   
                    const var ControlSelectButtonArray = [
                                                            Content.getComponent("Gain"),
                                                            Content.getComponent("Pan")
                                                        ];
                                                   
                    const var Samp1GainSliderArray =         [
                                                            Content.getComponent("SamplerGain")
                                                        ];
                                                        
                    const var Samp2GainSliderArray =         [
                                                            Content.getComponent("Sampler2Gain")
                                                        ];
                                                        
                    const var Samp1PanSliderArray =         [
                                                            Content.getComponent("SamplerPan")
                                                        ];
                                                        
                    const var Samp2PanSliderArray =         [
                                                            Content.getComponent("Sampler2Pan")
                                                        ];
                                                        
                    const var empty = []
                                                        
                                                        
                    // Gain page index
                    inline function showPageGain(pageIndex)
                    {
                        for(k in Samp1GainSliderArray) 
                        {
                            k.showControl(pageIndex == 0);
                        }
                        
                        for(k in Samp2GainSliderArray) 
                        {
                        
                            k.showControl(pageIndex == 1);
                        }
                        
                        
                        
                    
                    }
                    
                    // Pan page index
                    inline function showPagePan(pageIndex)
                    {
                        for(k in Samp1PanSliderArray) 
                        {
                            k.showControl(pageIndex == 0);
                        }
                        
                        for(k in Samp2PanSliderArray) 
                        {
                        
                            k.showControl(pageIndex == 1);
                        }
                        
                    
                    }
                    
                    
                    
                    inline function ControlsCallback(component, value)
                    {
                        if(value)
                        {
                    
                    //set variable y 
                    var y = ControlSelectButtonArray.indexOf(component);
                    
                            if (y == 0)
                               { showPageGain(x);}
                               else (showPageGain(3));
                               
                               if (y == 1)
                            {
                                showPagePan(x);
                            }
                            else (showPagePan(3));
                        }
                    }
                    for(a in ControlSelectButtonArray)
                        a.setControlCallback(ControlsCallback);
                        
                        
                                               
                    inline function SamplerCallback(component, value)
                    {
                        if(value)
                        {
                                    //set variable x 
                    var x = SamplerSelectButtonArray.indexOf(component);
                    
                            
                    
                          if (y == 0)
                            {
                                
                                showPageGain(x);
                            }
                            else (showPageGain(3));
                            
                        if (y == 1)
                            {
                                showPagePan(x);
                            }
                            
                            else (showPagePan(3));
                        }
                    }
                    for(a in SamplerSelectButtonArray)
                        a.setControlCallback(SamplerCallback);

                    Dan Korneff - Producer / Mixer / Audio Nerd

                    1 Reply Last reply Reply Quote 1
                    • Dan KorneffD
                      Dan Korneff @d.healey
                      last edited by

                      @d-healey Overall functionality of the newest version is quite more stable than what I was using. Keeping my eyes open for bugs as you suggested.

                      Dan Korneff - Producer / Mixer / Audio Nerd

                      1 Reply Last reply Reply Quote 1
                      • Christoph HartC
                        Christoph Hart
                        last edited by

                        Good to know ;)

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

                        26

                        Online

                        1.7k

                        Users

                        11.8k

                        Topics

                        102.3k

                        Posts