Solved C++ Buffers, and using the Hise interpolator?
-
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.
-
-
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...
-
@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 simpleT*
pointer and asize
. Almost any container in the world will give you access to the raw data. Here's astd::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());
-
This post is deleted! -
-
This post is deleted!