Forum

    • Register
    • Login
    • Search
    • Categories

    Get length / duration of sample in samples

    Scripting Forum
    4
    9
    107
    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 Kolb
      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.healey 1 Reply Last reply Reply Quote 0
      • Christoph Hart
        Christoph Hart last edited by

        SampleEnd - SampleStart?

        d.healey B 2 Replies Last reply Reply Quote 0
        • d.healey
          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

          1 Reply Last reply Reply Quote 0
          • d.healey
            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 Kolb
              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 Hart
                  Christoph Hart last edited by

                  These are the basics of setting sample properties programatically:

                  https://forum.hise.audio/topic/64/fun-with-regex?_=1619473727777

                  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
                      • First post
                        Last post

                      20
                      Online

                      852
                      Users

                      5.7k
                      Topics

                      52.9k
                      Posts