Forum
    • Categories
    • Register
    • Login

    Delay / preloading when moving loop handles or toggling reverse on my custom sampler

    Scheduled Pinned Locked Moved General Questions
    9 Posts 4 Posters 52 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.
    • K
      Kenny Roads
      last edited by

      Hi everyone,

      I’m building a custom sampler in HISE and I’ve run into a problem that I can’t seem to solve.
      I’m not a professional programmer, trying to learn using claude so maybe I’m missing something obvious.

      I’ve created a custom waveform panel where the waveform of the loaded sample is drawn, and I have some basic features implemented, two loop handles, a start handle, and a reverse button.
      Everything seems to work visually, but the issue is the preloading delay.

      Whenever I move one of the loop handles from one point to another or even enabling the loop mode, the Sampler shows the message “preloading”, and it takes about 1–2 seconds for the new region to update.

      During that time the audio actually cuts out if I’m holding a note.
      So if I’m pressing a key, move the handle, and let it go, the sound stops for around 1–1.5 seconds until the preload finishes.

      The same thing also happens when I press reverse.
      When I toggle reverse, the sampler changes mode and again it takes about 1–2 seconds before it updates.
      Until then, the audio either stops or hiccups.

      I want the loop handles and the reverse toggle to behave in real-time while playing, but at the moment everything freezes for a moment because of the preloading.

      Imp: Each preset has around 100–150 WAV files, so I’m guessing that changing loop positions forces HISE to reload everything.
      But I’m not sure if this is normal behavior or if my setup is wrong.

      Is there a way to avoid this preloading delay?

      Can loop position changes update instantly without reloading the whole sample map?

      Do I need to prepare / store my samples differently?

      Or is there some setting or scripting approach that makes this smoother?

      Thanks in advance!

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

        @Kenny-Roads You could try disabling DFD (load the full sample into memory) and see if that solves it.

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

        K 2 Replies Last reply Reply Quote 0
        • K
          Kenny Roads @David Healey
          last edited by

          @David-Healey

          Hi David, thanks for the suggestion!
          I tried disabling DFD:
          Set PreloadSize="-1" directly in the Stereolith.xml file
          Also tried via script: Sampler.setAttribute(7, -1)
          But the preloading delay still occurs for loop and reverse changes.

          Moving the custom Start Handle (via Modulator): No delay
          Enable/Move Loop Handles with single sample: Small delay (~0.2s)
          Enable/Move Loop Handles with preset (~100 samples): Long delay (~1-2s)
          Toggle Reverse: Same pattern as loop handles
          So even with just one sample, moving the loop handles still triggers preloading it's just much faster because there's only one file to process.
          This suggests that preloading on loop/reverse property changes is fundamental HISE behavior, not something that can be disabled via PreloadSize settings.
          My loop code applies changes to all samples:
          var sounds = Sampler.createSelection(".*");for (i = 0; i < sounds.length; i++) { sounds[i].set(Sampler.LoopStart, loopStart); sounds[i].set(Sampler.LoopEnd, loopEnd); sounds[i].set(Sampler.LoopEnabled, true);}

          Is this preloading behavior unavoidable when changing loop/reverse properties? Or
          could using a modulator for loop points (like SampleStartMod works for start position) avoid this issue?

          Thanks for any guidance!

          ulrikU 1 Reply Last reply Reply Quote 0
          • OrvillainO
            Orvillain
            last edited by

            As far as I know, based on conversations with Christophe, this stuff is unavoidable. If you want any of these seamless start/end/loop/direction changes, you need to write a custom sampler from scratch in c++ or SNEX, and use it in scriptnode.

            Musician - Instrument Designer - Sonic Architect - Creative Product Owner
            Crafting sound at every level. From strings to signal paths, samples to systems.

            K 1 Reply Last reply Reply Quote 0
            • ulrikU
              ulrik @Kenny Roads
              last edited by

              @Kenny-Roads Maybe if you work with Buffers instead, you can reverse them, cut them up using Buffer.getSlice() etc..
              Maybe it will decrease the delay times?

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

              K 1 Reply Last reply Reply Quote 0
              • K
                Kenny Roads @ulrik
                last edited by

                @ulrik

                Thanks for the suggestion! I researched the Buffer approach with getSlice() and it sounds promising for instant loop/reverse control.
                However, my instrument has 100+ samples with velocity layers, pitch tracking, round robin, etc. Switching to a Buffer-based playback system would mean losing all the built-in Sampler features and having to rebuild them manually in scriptnode/SNEX.
                For now, I found that setting "Purge All" to "Lazy" in the Disk I/O Settings gives a noticeable improvement not instant, but much faster than before.
                Maybe in the future I'll explore the Buffer/SNEX route for a simpler instrument where instant loop control is critical. Thanks for the idea!

                ulrikU 1 Reply Last reply Reply Quote 1
                • K
                  Kenny Roads @Orvillain
                  last edited by

                  @Orvillain

                  Thanks for confirming this! Good to know it's unavoidable with the built-in Sampler.
                  I looked into the custom sampler / SNEX / Buffer approach, but rebuilding all that from scratch in C++ or SNEX would be a massive undertaking for my skill level.
                  However, I found a partial workaround: Setting "Purge All" to "Lazy" in the Disk I/O Settings makes the loop/reverse changes noticeably faster. Not instant like a custom solution would be, but a decent compromise for now.
                  Thanks for the info!

                  1 Reply Last reply Reply Quote 0
                  • ulrikU
                    ulrik @Kenny Roads
                    last edited by

                    @Kenny-Roads Ok, I understand, that would be a massive work

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

                    1 Reply Last reply Reply Quote 0
                    • K
                      Kenny Roads @David Healey
                      last edited by

                      @David-Healey

                      Hey David, I found that using lazy load in the purge solves the problem. To a large extent, the pre-load time becomes negligible, just like when I have one sample loaded with -1 preload size. I think it’s the best solution for now.

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

                      22

                      Online

                      2.1k

                      Users

                      13.0k

                      Topics

                      112.5k

                      Posts