HISE Logo Forum
    • Categories
    • Register
    • Login

    How to get around max start offset is 65536?

    Scheduled Pinned Locked Moved Scripting
    offsetsampler
    17 Posts 5 Posters 315 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
      last edited by

      I'm working on a project where I need to be able to start playback at any point on the sample (fully loaded into RAM).

      My plan was to use Message.setStartOffset() but I'm running into this limit, presumably because the offset value is a uint16.

      Is there any way to workaround this limitation?

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

      A 1 Reply Last reply Reply Quote 0
      • A
        aaronventure @d.healey
        last edited by

        @d-healey said in How to get around max start offset is 65536?:

        presumably because the offset value is a uint16

        You're right.

        Link Preview Image
        HISE/hi_scripting/scripting/api/ScriptingApi.cpp at 961d7d903632982c4c315062271cf1318cee278b · christophhart/HISE

        The open source framework for sample based instruments - HISE/hi_scripting/scripting/api/ScriptingApi.cpp at 961d7d903632982c4c315062271cf1318cee278b · christophhart/HISE

        favicon

        GitHub (github.com)

        Link Preview Image
        HISE/hi_tools/hi_tools/HiseEventBuffer.cpp at 961d7d903632982c4c315062271cf1318cee278b · christophhart/HISE

        The open source framework for sample based instruments - HISE/hi_tools/hi_tools/HiseEventBuffer.cpp at 961d7d903632982c4c315062271cf1318cee278b · christophhart/HISE

        favicon

        GitHub (github.com)

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

          @Christoph-Hart Any reason this can't be changed to handle higher values?

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

          Christoph HartC 1 Reply Last reply Reply Quote 0
          • Christoph HartC
            Christoph Hart @d.healey
            last edited by

            @d-healey yup, the 64bit size limit of the HISE event type says no.

            Can you use the modulator? It's 0...1 value should map to the full sample start mod range of each sample. If you want to script it, use a voice start modulator in there that grabs the value you pass over using the event storage system.

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

              @Christoph-Hart said in How to get around max start offset is 65536?:

              Can you use the modulator?

              That might work, I will test and report back, thanks.

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

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

                @Christoph-Hart I don't think it will work in this situation. I'm porting over a Kontakt instrument - 😧

                In Kontakt this instrument uses the timemachine legato mode. So sample A plays, and then when you play sample B it starts playback from the current position of sample A.

                If all the samples were the same length then I think the modulator would work, but in this case they are not so, for example, I don't know what 2000ms into sample A translates to as 0 - 1 of sample B.

                Or perhaps there is a method I'm not seeing.

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

                Dan KorneffD Christoph HartC 2 Replies Last reply Reply Quote 0
                • Dan KorneffD
                  Dan Korneff @d.healey
                  last edited by

                  @d-healey Can you use getSampleLength() to calculate the 0-1 value?
                  Something like:

                  var totalSamples = currentSample.getSampleLength();
                  
                  var offsetSamples = (offsetMs * sampleRate) / 1000;
                  
                  var normalizedOffset = offsetSamples / totalSamples;
                  

                  And then use the normalizedOffset value for your modulator?

                  Dan Korneff - Producer / Mixer / Audio Nerd

                  d.healeyD 1 Reply Last reply Reply Quote 1
                  • d.healeyD
                    d.healey @Dan Korneff
                    last edited by

                    @Dan-Korneff how are you getting current sample?

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

                    SimonS 1 Reply Last reply Reply Quote 0
                    • SimonS
                      Simon @d.healey
                      last edited by

                      @d-healey I added a function to my fork to get sample length based on note/velocity in the map, I've found it very useful.

                      d.healeyD 1 Reply Last reply Reply Quote 0
                      • Christoph HartC
                        Christoph Hart @d.healey
                        last edited by Christoph Hart

                        @d-healey fair point. Could a method help that just multiplies the start offset for the sampler in question? This way you would loose a bit of precision but can yank the offset range into the dimension you need.

                        So if you need to start the sample at 100.000 offset which is beyond 65k, then you'll use

                        // Internally multiply the offsets by this amount
                        Sampler.setOffsetMultiplier(2);
                        
                        
                        // Later
                        local realOffset = 100000;
                        Message.setStartOffset(realOffset / 2); // 50k < 65k => all good
                        

                        it won't be 100% sample accurate anymore, but below a multiplication factor of 8 this shouldn't have any real world consequences.

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

                          @Christoph-Hart that might work, am I able to change it dynamically in on note on?

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

                          Christoph HartC 1 Reply Last reply Reply Quote 1
                          • Christoph HartC
                            Christoph Hart @d.healey
                            last edited by Christoph Hart

                            @d-healey yes but don‘t rely on the calls being always in order, if multiple notes are played in one buffer then it will use the latest value for the multiplier for all notes within that buffer.

                            d.healeyD 1 Reply Last reply Reply Quote 1
                            • d.healeyD
                              d.healey @Christoph Hart
                              last edited by

                              @Christoph-Hart Sounds promising, let's give it a try

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

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

                                @Simon said in How to get around max start offset is 65536?:

                                I added a function to my fork to get sample length based on note/velocity in the map, I've found it very useful.

                                There's actually a built in way to do this.

                                Although I'm not sure if it's usable for realtime... but maybe I could "cache" this info during init and retrieve it in the on note on callback perhaps... something for me to play with

                                const var Sampler1 = Synth.getSampler("Sampler1");
                                
                                const list = Sampler1.createSelectionWithFilter(function()
                                {
                                    return this.get(Sampler.Root) == 72 && this.get(Sampler.HiVel) > 20 && this.get(Sampler.RRGroup) == 1;
                                });
                                
                                Console.print(list[0].get(Sampler.SampleEnd));
                                

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

                                Christoph HartC 1 Reply Last reply Reply Quote 1
                                • Christoph HartC
                                  Christoph Hart @d.healey
                                  last edited by

                                  let's give it a try

                                  You're chances of this not interrupting your workflow will rise by 100% if you try to implement this yourself and hit me with a sweet pull request. My local branch is heads deep into the rewrite for the new group management system and the implementation should be pretty easy:

                                  All you need to do is to add the API method to the Sampler class and create a function in the ModulatorSampler::setStartOffsetMultiplier() class that stores the multiplier (ideally as an integer).

                                  Then in the voice start code, you need to modify this line here:

                                  Link Preview Image
                                  HISE/hi_core/hi_sampler/sampler/ModulatorSampler.cpp at 961d7d903632982c4c315062271cf1318cee278b · christophhart/HISE

                                  The open source framework for sample based instruments - HISE/hi_core/hi_sampler/sampler/ModulatorSampler.cpp at 961d7d903632982c4c315062271cf1318cee278b · christophhart/HISE

                                  favicon

                                  GitHub (github.com)

                                  to include the multiplication with the factor.

                                  d.healeyD 1 Reply Last reply Reply Quote 1
                                  • d.healeyD
                                    d.healey @Christoph Hart
                                    last edited by

                                    @Christoph-Hart Thank you

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

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

                                      Done - https://github.com/christophhart/HISE/pull/680

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

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

                                      26

                                      Online

                                      1.7k

                                      Users

                                      11.8k

                                      Topics

                                      102.6k

                                      Posts