Forum
    • Categories
    • Register
    • Login

    How do i remove numbers and underscore

    Scheduled Pinned Locked Moved Scripting
    16 Posts 4 Posters 1.3k 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.
    • David HealeyD
      David Healey @ThinkTank
      last edited by David Healey

      @ThinkTank

      replace("_");

      for (var i = 0; i < sampleMapNames.length; i++) {

      The var should not be there, I smell ChatGPT.

      A for in loop is probably better here. Gets it down to two lines

      for (name in sampleMapNames)
      	displayNames.push(name.replace("_"));
      

      Free HISE Bootcamp Full Course for beginners.
      YouTube Channel - Public HISE tutorials
      My Patreon - HISE tutorials

      1 Reply Last reply Reply Quote 0
      • David HealeyD
        David Healey @ThinkTank
        last edited by

        @ThinkTank Oh I just saw you want to remove the number as well. One moment...

        Free HISE Bootcamp Full Course for beginners.
        YouTube Channel - Public HISE tutorials
        My Patreon - HISE tutorials

        ThinkTankT 1 Reply Last reply Reply Quote 0
        • David HealeyD
          David Healey
          last edited by

          for (name in sampleMapNames)
          	displayNames.push(name.substring(name.indexOf("_") + 1, name.length));
          

          Free HISE Bootcamp Full Course for beginners.
          YouTube Channel - Public HISE tutorials
          My Patreon - HISE tutorials

          CyberGenC 1 Reply Last reply Reply Quote 0
          • ThinkTankT
            ThinkTank @David Healey
            last edited by

            @d-healey

            I was just about to mention it, thanks a ton for the help.
            You are spot on with ChatGPT, im trying to make it my mentor, but it gets a ton of stuff wrong still 😰

            Without problems that test the limits of your abilities, you can not expand them.

            David HealeyD 1 Reply Last reply Reply Quote 0
            • David HealeyD
              David Healey @ThinkTank
              last edited by David Healey

              @ThinkTank said in How do i remove numbers and underscore:

              im trying to make it my mentor,

              It's the other way around, you have to mentor ChatGPT, it doesn't know when it makes a mistake.

              Just posted the solution above your response.

              Free HISE Bootcamp Full Course for beginners.
              YouTube Channel - Public HISE tutorials
              My Patreon - HISE tutorials

              ThinkTankT 2 Replies Last reply Reply Quote 0
              • ThinkTankT
                ThinkTank @David Healey
                last edited by

                @d-healey

                Thanks a bunch, that's true haha. I'm giving ChatGPT a lot of scolding with these scripts.

                Without problems that test the limits of your abilities, you can not expand them.

                1 Reply Last reply Reply Quote 0
                • ThinkTankT
                  ThinkTank @David Healey
                  last edited by

                  @d-healey

                  It never really worked, not sure why. But now im just hiding them with panels 😂

                  Without problems that test the limits of your abilities, you can not expand them.

                  David HealeyD 1 Reply Last reply Reply Quote 0
                  • David HealeyD
                    David Healey @ThinkTank
                    last edited by

                    @ThinkTank said in How do i remove numbers and underscore:

                    not sure why.

                    Try and figure it out. Solving these problems is how you get more proficient at scripting. If you sidestep it now you won't have a solution the next time it happens.

                    Free HISE Bootcamp Full Course for beginners.
                    YouTube Channel - Public HISE tutorials
                    My Patreon - HISE tutorials

                    ThinkTankT 1 Reply Last reply Reply Quote 0
                    • ThinkTankT
                      ThinkTank @David Healey
                      last edited by

                      @d-healey

                      True, and i also forgot i can not hide the name when i click the combobox and it drops down 😧
                      The struggle is real.

                      Without problems that test the limits of your abilities, you can not expand them.

                      David HealeyD 1 Reply Last reply Reply Quote 0
                      • David HealeyD
                        David Healey @ThinkTank
                        last edited by

                        @ThinkTank said in How do i remove numbers and underscore:

                        The struggle is real.

                        Every is hard before it is easy. But it doesn't take much practice for things to start getting easier and there is lots of documentation and help available.

                        Free HISE Bootcamp Full Course for beginners.
                        YouTube Channel - Public HISE tutorials
                        My Patreon - HISE tutorials

                        DanHD 1 Reply Last reply Reply Quote 0
                        • DanHD
                          DanH @David Healey
                          last edited by DanH

                          @d-healey @ThinkTank I haven't used ChatGBT for HISE at all but I can imagine it creates mutant script that kind of works until it causes problems further down the line that you have no idea how to solve.

                          I'd say ask the forum first for help, as you will benefit from the experienced coders like @d-healey and your code will have a much better chance of working 😆

                          DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                          https://dhplugins.com/ | https://dcbreaks.com/
                          London, UK

                          ThinkTankT 1 Reply Last reply Reply Quote 0
                          • ThinkTankT
                            ThinkTank @DanH
                            last edited by

                            @DanH

                            Absolutely correct!
                            Its a mess to work with, i have to do the research for it and come up with solutions about 90% of the time.

                            However i now got it working.

                            If anyone else has this problem, here is the code:

                            // Layer A
                            const var pianos = Content.getComponent("pianos");
                            
                            const var sampleMapNames = Sampler.getSampleMapList(); // Assuming this is the correct function name
                            
                            // Remove numerical prefixes from sample map names
                            const var displayNames = [];
                            for (name in sampleMapNames)
                                displayNames.push(name.substring(name.indexOf("_") + 1, name.length));
                            
                            // Sort Array
                            displayNames.sort();
                            
                            pianos.set("items", displayNames.join("\n"));
                            
                            inline function onpianosControl(component, value)
                            {
                              
                                Sampler1.asSampler().loadSampleMap(sampleMapNames[value - 1]);
                            }
                            
                            pianos.setControlCallback(onpianosControl);
                            

                            Without problems that test the limits of your abilities, you can not expand them.

                            1 Reply Last reply Reply Quote 0
                            • CyberGenC
                              CyberGen @David Healey
                              last edited by

                              @d-healey Sorry for the old topic revival but how about in this case, I need to remove the wildcard {PROJECT_FOLDER} and the ".wav" extension from some audio files. I can do one or the other but don't know how to do both at the same time. Here is what I have so far:

                              	const var Convolutions = Engine.loadAudioFilesIntoPool();
                              
                              	const var IRs = [];
                              	
                              
                              for (Convolution in Convolutions)
                              {
                              	IRs.push(Convolution.replace("{PROJECT_FOLDER}"));
                              
                              }
                              
                              David HealeyD 1 Reply Last reply Reply Quote 0
                              • David HealeyD
                                David Healey @CyberGen
                                last edited by David Healey

                                @CyberGen

                                You can chain it.

                                IRs.push(Convolution.replace("{PROJECT_FOLDER}").replace("next thing to replace"));

                                Free HISE Bootcamp Full Course for beginners.
                                YouTube Channel - Public HISE tutorials
                                My Patreon - HISE tutorials

                                CyberGenC 1 Reply Last reply Reply Quote 1
                                • CyberGenC
                                  CyberGen @David Healey
                                  last edited by

                                  @d-healey worked like a charm... Thank you!

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

                                  24

                                  Online

                                  2.1k

                                  Users

                                  13.0k

                                  Topics

                                  112.6k

                                  Posts