HISE Logo Forum
    • Categories
    • Register
    • Login

    C++ Buffers, and using the Hise interpolator?

    Scheduled Pinned Locked Moved Solved Scripting
    5 Posts 2 Posters 267 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.
    • griffinboyG
      griffinboy
      last edited by griffinboy

      Probably a question for @Christoph-Hart

      I'm having a lot of issues trying to use the hise interpolator in C++ with my own custom buffer.
      The juce and C++ buffers don't seem to be compatible with the interpolator. What is the ideal array type I should use if I want to interface with the snex interpolators?

      using InterpolatorType = index::hermite<index::unscaled<double, index::clamped<0, false>>>;
      

      I am currently using this to resample the external data buffer, for which I have a span:

      span<dyn<float>, 2> sample;              // Stereo sample data.
      
      void setExternalData(const ExternalData& ed, int index)
              {
                  // Reference the external sample data to the internal sample buffers.
                  sampleData = ed;
                  ed.referBlockTo(sample[0], 0);
                  ed.referBlockTo(sample[1], 1);
              }
      

      And that works fine

      // Perform interpolation.
                          InterpolatorType idx(voice.position);
                          float sampleValue = (sample[0][idx] + sample[1][idx]) * 0.5f * voice.velocity;
      
                          // Accumulate sample contributions.
                          sampleSumLeft += sampleValue;
                          sampleSumRight += sampleValue;
      
                          // Advance the voice position by delta.
                          voice.position += voice.delta;
      

      But I'm having a great amount of trouble doing the same thing for a custom buffer.

      I've been attempting to use heap and then make a span that references it, and I've also tried to create a span referencing a regular vector array, and a dyn span that refrences a span. But it's not been turning out well! don't really understand the procedure for declaring and using these properly.

      This is all part of my sampler, which I've been having a horrible time trying to put together.

      griffinboyG 1 Reply Last reply Reply Quote 0
      • griffinboyG griffinboy marked this topic as a question on
      • griffinboyG
        griffinboy @griffinboy
        last edited by

        @griffinboy @Christoph-Hart

        Could you perhaps demonstrate how to end up at a dyn span from nothing?
        Do we start out as a different type of array and then create a span from that?
        If we want the size of the buffer to be dynamic is that possible?

        Or last of all, should I just make my own interpolator and forget about all this...

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

          @griffinboy the SNEX API has three main container types and if you want to use the index template for interpolating / safe access you need to use them. They differ in their ability to change their size dynamically and whether or not they "own" the data:

          • span: owns the data, compile time size (allocated on creation)
          • dyn: doesn't own the data, only refers to it
          • heap: owns the data, but allocates it dynamically

          The easiest entry into this would be creating a dyn<T> container with a simple T* pointer and a size. Almost any container in the world will give you access to the raw data. Here's a std::vector<float> example:

          std::vector<float> x;
          x.push_back(1.0f);
          x.push_back(1.0f);
          x.push_back(1.0f);
          
          dyn<float> snexContainer(x.data(), x.size());
          
          griffinboyG 2 Replies Last reply Reply Quote 1
          • griffinboyG
            griffinboy @Christoph Hart
            last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • griffinboyG griffinboy has marked this topic as solved on
            • griffinboyG
              griffinboy @Christoph Hart
              last edited by griffinboy

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

              21

              Online

              1.8k

              Users

              11.9k

              Topics

              104.0k

              Posts