HISE Logo Forum
    • Categories
    • Register
    • Login

    [SOLVED] Changing Key Colors with Samplemaps

    Scheduled Pinned Locked Moved General Questions
    3 Posts 2 Posters 323 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.
    • S
      Soundavid
      last edited by Soundavid

      Hi, I have an Instrument with different Samplemaps that change with Radio Buttons, these Buttons Change the Samplemap and the image, I try to colour the Keyboard putting the code in this Callback but I have to double click the button to make this function work on the Keys. I tried putting the code in a hidden Slider, Panel but have the same result, I also tried a timer and it works but I don't like that timer running and sometimes glitching the Key Colours, some ideas?

      This is my code

      inline function changeInst(component, value)
      {
      	
          if (value)
          {
              local idx = instButtons.indexOf(component);
      
              for (i = 0; i < insts.length; i++)
              {
                  insts[i].showControl(false);
                  Sampler1.loadSampleMap(Samplemap[idx]);
                  
              }
                
              for (i = 0; i < 127; i++)
              {
               Engine.setKeyColour(i, Colours.withAlpha(Colours.black, 0.6));
                                 	    
               	if (Sampler.asSampler().isNoteNumberMapped(i))
               	{
      	         Engine.setKeyColour(i, Colours.withAlpha(Colours.dodgerblue, 0.4));
               	}
                     
              }  
      
              insts[idx].showControl(true);
          }
      
      }
      

      I have "Sampler" Referencing Child Synth and "Sampler1" Referencing Sampler in order to make this work.

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

        @Soundavid My first guess (without any investigation) is that your re-colouring triggers before the new sample map has finished loading, therefore it won't detect the note numbers as being mapped/unmapped at the point your loop runs. If you put the key colouring code in a preload callback you might get better results.

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

        S 1 Reply Last reply Reply Quote 1
        • S
          Soundavid @d.healey
          last edited by

          @d-healey You were Right! I tried this code in a hidden Panel and works Perfectly! Thanks man.

          ScriptPanel1.setLoadingCallback(function(isPreloading)
          {
          	if(!isPreloading)
          	for (i = 0; i < 127; i++)
          	{
          
          	Engine.setKeyColour(i, Colours.withAlpha(Colours.black, 0.6));
          	                   	    
          	if (Sampler.asSampler().isNoteNumberMapped(i))
          	Engine.setKeyColour(i, Colours.withAlpha(Colours.dodgerblue, 0.4));
          	
          	}  
          });
          
          1 Reply Last reply Reply Quote 1
          • First post
            Last post

          27

          Online

          1.8k

          Users

          11.9k

          Topics

          104.0k

          Posts