HISE Logo Forum
    • Categories
    • Register
    • Login

    Sampler Loop Start / End Point - change with sliders?

    Scheduled Pinned Locked Moved General Questions
    9 Posts 4 Posters 380 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.
    • DanHD
      DanH
      last edited by

      @Christoph-Hart I saw some code from a thread recently which looks like it could be used to control the Sampler Loop point from sliders - is this possible? I'm trying to link Sampler1.LoopEnd to a knob callback (unsuccessfully!). Loop on / off would be great as well. Here's the code below:

      /** Select all samples in the current samplemap
          ".*" is Regex and means everything.
      */
      const var allSamples = Sampler.createSelection(".*");
      
      /** You'll get an array of all samples, which you can iterate */
      for(s in allSamples)
      {
          /** Just multiply all sample properties with 2 */
          s.set(Sampler.LoopStart, parseInt(s.get(Sampler.LoopStart)) * 2);
          s.set(Sampler.LoopEnd, parseInt(s.get(Sampler.LoopEnd)) * 2);
          s.set(Sampler.SampleEnd, parseInt(s.get(Sampler.SampleEnd)) * 2);
      }
      
      /** This needs to be called after a sample manipulation op
          in order to refresh the UI. */
      Sampler.refreshInterface();
      
      DanHD LindonL 2 Replies Last reply Reply Quote 0
      • DanHD
        DanH @DanH
        last edited by

        @Christoph-Hart Whadayathink?!

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

          It might work, although you need to be aware that changing the loop points will kill all voices and cause a streaming buffer refresh (because the loop point might intersect with the preload buffer range or other edge cases), so it's not something that you could automate as musical parameter.

          DanHD 1 Reply Last reply Reply Quote 0
          • DanHD
            DanH @Christoph Hart
            last edited by

            @Christoph-Hart Ok that's encouraging...

            Any clues to how I'd write a callback would be very welcome :)

            1 Reply Last reply Reply Quote 0
            • LindonL
              Lindon @DanH
              last edited by

              @DanH said in Sampler Loop Start / End Point - change with sliders?:

              s.set(Sampler.LoopStart, parseInt(s.get(Sampler.LoopStart)) * 2);
              s.set(Sampler.LoopEnd, parseInt(s.get(Sampler.LoopEnd)) * 2);
              s.set(Sampler.SampleEnd, parseInt(s.get(Sampler.SampleEnd)) * 2);

              you probably want to think about what you are doing here:

                  s.set(Sampler.SampleEnd, parseInt(s.get(Sampler.SampleEnd)) * 2);
              

              essentially :
              "please set the end of the sample to 2 x the length of the sample"

              HISE Development for hire.
              www.channelrobot.com

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

                
                inline function onKnob1Control(component, value)
                {
                    for(s in Sampler1.createSelection(".*"))
                    {
                        local l = parseInt(s.get(Sampler.SampleEnd));
                        s.set(Sampler.LoopEnd, value * l);
                    }
                };
                
                Content.getComponent("Knob1").setControlCallback(onKnob1Control);
                
                const var Sampler1 = Synth.getSampler("Sampler1");
                
                ustkU DanHD 2 Replies Last reply Reply Quote 0
                • ustkU
                  ustk @Christoph Hart
                  last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • DanHD
                    DanH @Christoph Hart
                    last edited by

                    @Christoph-Hart Thank you very much, there's no way in a million years I was going to get that lol!

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

                      This post is deleted!
                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post

                      24

                      Online

                      1.8k

                      Users

                      12.0k

                      Topics

                      104.1k

                      Posts