HISE Logo Forum
    • Categories
    • Register
    • Login

    Mark notes that contain samples by coloring keyboard keys

    Scheduled Pinned Locked Moved General Questions
    colorkeyboard
    34 Posts 6 Posters 2.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.
    • d.healeyD
      d.healey @gorangrooves
      last edited by

      @gorangrooves No problemo

      I still don't fully understand how you came up with the logic for the code.

      By reading lots of code and writing lots of code ;)

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

      J 1 Reply Last reply Reply Quote 1
      • J
        Jerems134 @d.healey
        last edited by

        @d-healey I've many sample maps on one sampler and all keys are coloured at the same time, have an idea to do with sample map ?

        //I've try replace 
        const var Sampler1 = Synth.getChildSynth("Sampler1");
        
        reg i;
        
        for (i = 0; i < 127; i++)
        {
            if (Sampler1.asSampler().isNoteNumberMapped(i))
                Engine.setKeyColour(i, Colours.withAlpha(Colours.blue, 0.3));
        }
        //by
        const var Sampler1 = Synth.getChildSynth("Sampler1");
        const var sampleMaps = Sampler.getSampleMapList();
        
        reg i;
        
        for (i = 0; i < 127; i++)
        {
        if (Sampler.getSampleMapList().isNoteNumberMapped(i))
                Engine.setKeyColour(i, Colours.withAlpha(Colours.blue, 0.3));
        }
        

        Not working

        d.healeyD ustkU 2 Replies Last reply Reply Quote 0
        • d.healeyD
          d.healey @Jerems134
          last edited by

          @Jerems134 I don't understand the question, could you rephrase it?

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

          1 Reply Last reply Reply Quote 0
          • ustkU
            ustk @Jerems134
            last edited by ustk

            @Jerems134 It is not the SampleMap you need to check but the sampler itself Sampler1.asSampler() assuming your sampler is called "Sampler1"
            Perform this each time you load a new sampleMap

            Can't help pressing F5 in the forum...

            1 Reply Last reply Reply Quote 1
            • J
              Jerems134
              last edited by Jerems134

              @d-healey @ustk On Sampler1 I have 2 sample maps loaded and I switch with presets/combo box.
              How to color keys only for samplemap1 and match coloured keys on samplemaps2 when I switch presets ?
              Actualy all keys from all sample maps are coloured no matter different sample maps mapping.
              They are layered.

              Full code :

              Content.makeFrontInterface(1200, 370);
              
              const var Panel1 = Content.getComponent("Panel1");
              const var Panel2 = Content.getComponent("Panel2");
              const var Button1 = Content.getComponent("Button1");
              
              //Tab button callback function
              inline function onButton1Control(component, value)
              
              {
                  if (value == 1) 
              	    Panel2.showControl(true);
              	    else
              	    Panel2.showControl(false);
              	};
              
              Content.getComponent("Button1").setControlCallback(onButton1Control);
              
              //Presets ComboBox Function
              //Sampler
              const var Sampler1 = Synth.getChildSynth("Sampler1");
              
              //Sample maps array
              const var sampleMaps = Sampler.getSampleMapList();
              
              //Combo box
              const var cmbSampleMap = Content.getComponent("cmbSampleMap");
              cmbSampleMap.set("items", sampleMaps.join("\n"));
              
              
              inline function oncmbSampleMapControl(component, value)
              {
              	Sampler1.asSampler().loadSampleMap(sampleMaps[value-1]);
              };
              
              Content.getComponent("cmbSampleMap").setControlCallback(oncmbSampleMapControl);
              
              //Coloured Keys
              //const var Sampler1 = Synth.getChildSynth("Sampler1");//(Repetiton)
              
              reg i;
              
              for (i = 0; i < 127; i++)
              {
                  if (Sampler1.asSampler().isNoteNumberMapped(i))
                      Engine.setKeyColour(i, Colours.withAlpha(Colours.blue, 0.3));
              }
              
              ustkU 1 Reply Last reply Reply Quote 0
              • ustkU
                ustk
                last edited by

                Add a hidden panel on the interface. Wrap your key colour code in the panel callback.
                Don't forget to enable saveInPreset so when you change preset the callback is called

                Can't help pressing F5 in the forum...

                1 Reply Last reply Reply Quote 0
                • ustkU
                  ustk @Jerems134
                  last edited by

                  @Jerems134 sorry you already have sample map selection in a callback so just place your code after that, no need for another panel…

                  Can't help pressing F5 in the forum...

                  J 1 Reply Last reply Reply Quote 0
                  • J
                    Jerems134 @ustk
                    last edited by

                    @ustk Key color code is working, but I use 1 sampler with 2 sample maps, I would like color each sample maps on the same sampler when I switch sample maps

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

                      @Jerems134 You mean you want to color blue keys to match the range of the loaded sample map? If so I'd use two hidden knobs, or a range slider, to set the range of keys to be colored and save this with your preset.

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

                      J 1 Reply Last reply Reply Quote 0
                      • J
                        Jerems134 @d.healey
                        last edited by Jerems134

                        @d-healey I’ve to set the range with knob or it’s just for saving preset ?
                        Its possible to make it automatic ?
                        I already have the code to save a preset. For now just the first samplemaps color the keys, when I change samplemap/preset, keyboard stay coloured like samplemap1, it dosent match with samplemap2.

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

                          Oh I get it now. You're only coloring the keys in on init, you need to recolour them each time a preset is loaded, try moving the loop into the combo box callback.

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

                          J 1 Reply Last reply Reply Quote 1
                          • J
                            Jerems134 @d.healey
                            last edited by Jerems134

                            @d-healey Trying this doesn't work, now all sample maps color keys at same time, no matter I change sample map

                            //Combo box
                            const var cmbSampleMap = Content.getComponent("cmbSampleMap");
                            cmbSampleMap.set("items", sampleMaps.join("\n"));
                            
                            
                            inline function oncmbSampleMapControl(component, value)
                            {
                            	Sampler1.asSampler().loadSampleMap(sampleMaps[value-1]);
                            };
                            reg i;
                            
                            for (i = 0; i < 127; i++)
                            {
                                if (Sampler1.asSampler().isNoteNumberMapped(i))
                                    Engine.setKeyColour(i, Colours.withAlpha(Colours.blue, 0.3));
                            }
                            Content.getComponent("cmbSampleMap").setControlCallback(oncmbSampleMapControl);
                            
                            1 Reply Last reply Reply Quote 0
                            • d.healeyD
                              d.healey
                              last edited by d.healey

                              As I said, try putting the loop inside the combobox callback function.

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

                              1 Reply Last reply Reply Quote 0
                              • J
                                Jerems134
                                last edited by Jerems134

                                @d-healey That's what I did ?! Maybe in the wrong place?
                                Look code sample

                                //Combo box
                                const var cmbSampleMap = Content.getComponent("cmbSampleMap");
                                cmbSampleMap.set("items", sampleMaps.join("\n"));
                                
                                
                                inline function oncmbSampleMapControl(component, value)
                                {
                                	Sampler1.asSampler().loadSampleMap(sampleMaps[value-1]);
                                };
                                //->
                                reg i;
                                
                                for (i = 0; i < 127; i++)
                                {
                                    if (Sampler1.asSampler().isNoteNumberMapped(i))
                                        Engine.setKeyColour(i, Colours.withAlpha(Colours.blue, 0.3));
                                }
                                Content.getComponent("cmbSampleMap").setControlCallback(oncmbSampleMapControl);
                                
                                ustkU 1 Reply Last reply Reply Quote 0
                                • ustkU
                                  ustk @Jerems134
                                  last edited by

                                  @Jerems134 nope it is not what you did, you closed the callback right before reg i;;)
                                  Also you need to reset the previous colour for all keys before applying the new one (especially if the range is not the same). Use any colour with an alpha value of 0

                                  Can't help pressing F5 in the forum...

                                  1 Reply Last reply Reply Quote 2
                                  • d.healeyD
                                    d.healey
                                    last edited by

                                    @ustk is correct, you need to place the loop between the braces {} of the function. You have placed it after the closing brace. Also you reg i isn't necessary here, so you can remove that.

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

                                    J 1 Reply Last reply Reply Quote 1
                                    • J
                                      Jerems134 @d.healey
                                      last edited by

                                      @ustk @d-healey Ok, I've put code in right place now, but all keys stay coloured.
                                      How to reset the previous colour ?
                                      Sorry I'm noob

                                      //Combo box
                                      const var cmbSampleMap = Content.getComponent("cmbSampleMap");
                                      cmbSampleMap.set("items", sampleMaps.join("\n"));
                                      
                                      
                                      inline function oncmbSampleMapControl(component, value)
                                      {
                                      	Sampler1.asSampler().loadSampleMap(sampleMaps[value-1]);
                                          if (Sampler1.asSampler().isNoteNumberMapped(i))
                                          Engine.setKeyColour(i, Colours.withAlpha(Colours.blue, 0.3));
                                      
                                      };
                                      
                                      
                                      Content.getComponent("cmbSampleMap").setControlCallback(oncmbSampleMapControl);
                                      
                                      ustkU 1 Reply Last reply Reply Quote 0
                                      • ustkU
                                        ustk @Jerems134
                                        last edited by

                                        @Jerems134 It is the entire for loop you need to move inside ;)

                                        Can't help pressing F5 in the forum...

                                        ustkU 1 Reply Last reply Reply Quote 0
                                        • ustkU
                                          ustk @ustk
                                          last edited by

                                          @ustk You also need to reset the key colors before the if statement in the for loop with an alpha colour value of 0

                                          Can't help pressing F5 in the forum...

                                          J 1 Reply Last reply Reply Quote 2
                                          • J
                                            Jerems134 @ustk
                                            last edited by

                                            @ustk @d-healey Ok it's working, thanks for your help !
                                            Solved with this code :

                                            //Combo box
                                            const var cmbSampleMap = Content.getComponent("cmbSampleMap");
                                            cmbSampleMap.set("items", sampleMaps.join("\n"));
                                            
                                            
                                            inline function oncmbSampleMapControl(component, value)
                                            {
                                            	Sampler1.asSampler().loadSampleMap(sampleMaps[value-1]);
                                            	for (i = 0; i < 127; i++)
                                            
                                             if (Sampler1.asSampler().isNoteNumberMapped(i))
                                                Engine.setKeyColour(i, Colours.withAlpha(Colours.blue, 0.3));
                                                else
                                               Engine.setKeyColour(i, Colours.withAlpha(Colours.white, 0.0));
                                            
                                            };
                                            
                                            1 Reply Last reply Reply Quote 3
                                            • First post
                                              Last post

                                            11

                                            Online

                                            1.7k

                                            Users

                                            11.8k

                                            Topics

                                            103.2k

                                            Posts