HISE Logo Forum
    • Categories
    • Register
    • Login

    Is this True and correct?

    Scheduled Pinned Locked Moved General Questions
    9 Posts 4 Posters 336 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.
    • G
      gryphonsegg
      last edited by

      I was wondering if this was true….

      Here’s a simplified example of how you might approach this in HISE. Note that you’ll need to replace the ... with the IDs of your sample maps, which are not provided in your question.

      This is a sketch of the code you might use:

      // Create the interface
      const var Interface = Content.addPanel("Interface", 0, 0);
      Interface.set("width", 500);
      Interface.set("height", 500);

      // Create the ComboBox
      const var ComboBox = Content.addComboBox("ComboBox", 0, 0);
      ComboBox.set("items", ["item", "item 2", "item 3"]);

      // Reference to the Sampler
      const var Sampler1 = Synth.getSampler("Sampler1");

      // Set up the ComboBox change callback
      ComboBox.setControlCallback(onComboBoxControl);

      inline function onComboBoxControl(component, value)
      {
      switch(value)
      {
      case 1: // "item"
      Sampler1.loadSampleMap("samplemap1");
      break;
      case 2: // "item 2"
      Sampler1.loadSampleMap("samplemap2");
      break;
      case 3: // "item 3"
      Sampler1.loadSampleMap("samplemap3");
      break;
      }
      }

      You would need to replace samplemap1, samplemap2, and samplemap3 with the IDs of your actual sample maps. Also, make sure your sampler’s name is Sampler1 as specified in the getSampler() method.

      This code creates a ComboBox with three items. When you select an item, it triggers the onComboBoxControl function, which loads a different sample map into the Sampler based on your selection.

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

        @gryphonsegg Looks reasonable but generally you should use the interface designer for your main interface script rather than adding components in the script. There are exceptions of course.

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

        G 1 Reply Last reply Reply Quote 0
        • G
          gryphonsegg @d.healey
          last edited by

          @d-healey I have chatGPT code interpreter some info to make this and this is what it spit out.

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

            This is the output of ChatGPT now? Oh boy, that's frightening.

            G 2 Replies Last reply Reply Quote 1
            • G
              gryphonsegg @Christoph Hart
              last edited by

              @Christoph-Hart
              yes it is! They just got a new code interpreter plugin and its pretty good I hear and now I can see it.

              1 Reply Last reply Reply Quote 0
              • G
                gryphonsegg @Christoph Hart
                last edited by

                @Christoph-Hart I could not get it to run however

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

                  @gryphonsegg

                  Ok I took a closer look

                  This won't work.

                  ComboBox.set("items", ["item", "item 2", "item 3"]);

                  I also think calling a ComboBox ComboBox has potential for issues.

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

                  G 1 Reply Last reply Reply Quote 0
                  • G
                    gryphonsegg @d.healey
                    last edited by

                    @d-healey so I tried this, still does not work. can you tell me why? If I knew I think my eyes would be opened a bit more.

                    HiseSnippet 1320.3oc4X02ZaaDF+jcTSsWWoszA6eFbX1e3BYo1oooiUF0INIkvhSL1okBiQ4hzY6iHcm3zoz3Mx2o8QXej52ftm6jjkjqRlqWa2XSPB54k6Q+tm2S5KENzvPgDYU6joATj0srGNkqlzcBgwQGrKx5118HgJpDGyZmoAjvPpKxxp5y0LrpsBx771msCwivcnYrPnWJXNzCY9LUF29c9Ilm29DW5IL+bZuYmCbD7tBOQDfmp1sPADmyHioGQzpUwFYci8bYJgbnhnngHqU1Q3Nc3Dwa3w5+RVH6TOplnMZHXnX16K7b0HV+Np6Dlma+z6cHBYY2OyKTM1Kbe6dLW1L9Ydi6XDfyNQd+gUkhvqZA309pfWIPxJGjVIFR20dnijEnxjnwyWXe.GBNiHfaOOTh0EU4cUr6J.M3p08ImQ2WBDyNQysZ0ZML7qG7z50e3CwckT.3X0DJtqv+TwNhKpCQjPE9bhD2aZJS7OhSMJw0MkayFYZzXMb6V5e.Kmwc8PppYClh5GBJ7yM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sj2MaeaUkx0iNL6.5ASl8xmRGBqYngDLy6yBJ8INRwqch+iKzX8lFN.J4l+eI0r6oowsS+yIrsasdKjOLq50NN5BguC7vkelMVhy7nk3LatDm4wKwY1ZINySVhy78W6YzqIrcjR3G2jDXzeu3DKq8lkXUE8mvy42Cg
                    
                    ulrikU 1 Reply Last reply Reply Quote 0
                    • ulrikU
                      ulrik @gryphonsegg
                      last edited by

                      @gryphonsegg as David said in the post above

                      MyComboBox.set("items", ["Piano", "Flute"]);
                      

                      will not work.

                      The items in a combobox is a string with a line break after each item like this were \n is the line break

                      MyComboBox.set("items", "Piano\nFlute");
                      

                      that is a bit cumbersome to write if you have a lot of items so, often you write them in an array but then you have to use .join to assemble them together to a string like this

                      MyComboBox.set("items", ["Piano", "Flute"].join("\n"));
                      

                      Hise Develop branch
                      MacOs 15.3.1, Xcode 16.2
                      http://musikboden.se

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

                      48

                      Online

                      1.7k

                      Users

                      11.7k

                      Topics

                      102.1k

                      Posts