HISE Logo Forum
    • Categories
    • Register
    • Login

    Get length / duration of sample in samples

    Scheduled Pinned Locked Moved Scripting
    11 Posts 5 Posters 875 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.
    • Casey KolbC
      Casey Kolb
      last edited by

      Hey all, I've been searching for an API call to get the length of each sample within a sampler, but have yet to find one. There are so many other properties options available (see this post), but I can't seem to find a function for getting the total duration in samples.

      I discovered this in the core HISE code getSampleLength() but it might serve a different purpose.

      Essentially, I need a way to set the sample ends to a percentage of the total length of each sample. Any suggestions? Thanks!

      Casey Kolb
      Founder & CEO of Lunacy Audio
      Composer | Producer | Software Developer

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

        SampleEnd - SampleStart?

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

          @Christoph-Hart Will that work if you've previously set the sample start or end to a range that isn't the sample's full length? I'm thinking you'd need to make sure they always started at the min/max you would ever need and then keep track of any changes you make after.

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

          A 1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey @Casey Kolb
            last edited by

            @Lunacy-Audio

            I discovered this in the core HISE code getSampleLength() but it might serve a different purpose.

            That function is for audio processors, not for individual samples. Samples use properties with the .get command but sample length isn't an available property so it would need to be implemented.

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

            1 Reply Last reply Reply Quote 0
            • Casey KolbC
              Casey Kolb
              last edited by

              Ah yes, that makes sense. Thanks guys.

              @Christoph-Hart Yes that would do it, but would yield inaccurate results in the case that the user changes the sample start first.

              @d-healey Agreed. Sounds like I'll need to track all the sample lengths in an array the instant a sample map is loaded using the method @Christoph-Hart mentioned above.

              Appreciate the responses!

              Casey Kolb
              Founder & CEO of Lunacy Audio
              Composer | Producer | Software Developer

              1 Reply Last reply Reply Quote 0
              • B
                benosterhouse @Christoph Hart
                last edited by

                @Christoph-Hart
                Searching SampleEnd or SampleStart in the manual I don't come up with anything.
                How would you get those via script?

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

                  These are the basics of setting sample properties programatically:

                  Link Preview Image
                  Fun with Regex

                  This is an advanced feature that I just implemented (and you need at least version 0.984 for this). You can now change the properties of individual sample so...

                  favicon

                  Forum (forum.hise.audio)

                  However the API has been extended to support Javascript-style loops so I recommend using this syntax instead:

                  for(s in Sampler.createSelection(".*"))
                      s.set(Sampler.SampleEnd, 12000);
                  
                  1 Reply Last reply Reply Quote 0
                  • B
                    benosterhouse
                    last edited by

                    That's what I was looking for, Thanks.

                    1 Reply Last reply Reply Quote 0
                    • B
                      benosterhouse
                      last edited by benosterhouse

                      I just discovered you can set the SampleStart to a negative number and it will delay the start....
                      Would this be a wise thing to do?

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

                        @d-healey Do you know if there is a way to do this now? Just like you said the sample length is overwritten whenever SampleStart or SampleEnd is changed and I can't find a way to get at the original sample length. Even when loading custom samples I can't really figure out how to snatch it before initAfterSampleLoad() which is called every time the sample is updated.

                        I'm drawing on a panel on top of an AudioWaveform and need to find a way to calculate the relative position and size of the selected range within the total view. Resize the panel to only cover the selected range in other words.

                        Figured one way to do it was to work with the AudioWaveform, but getRangeStart() and getRangeEnd() return 0.

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

                          @audiolyf It's not something I've explored.

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

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

                          19

                          Online

                          1.7k

                          Users

                          11.8k

                          Topics

                          102.5k

                          Posts