Block-Based Processing in Third Party Node
-
Sorry for the dumb question, had a bit of brain fog the last few days
template <typename T> void process(T& data) { static constexpr int NumChannels = getFixChannelAmount(); // Cast the dynamic channel data to a fixed channel amount auto& fixData = data.template as<ProcessData<NumChannels>>(); // Create a FrameProcessor object auto fd = fixData.toFrameData(); while (fd.next()) { // Forward to frame processing processFrame(fd.toSpan()); } }
Where in here do we process full buffers of audio? I know we can do single sample processing but I'm not sure how to do block-based processing
-
// ch is a pointer to the begin of each channel for(auto ch: data) { // This gets you the array to the channel signal dyn<float> channel = data.toChannelData(ch); // access any sample channel[2] = 0.0f; // perform math operation on the entire // data (using SIMD where possible) channel *= 2.0f; // iterate over the sample for(auto& sample: channel) sample *= 0.5; }
-
@Christoph-Hart thank you, I'll give it a shot.
sidenote I almost have RTNeural working in HISE, if I can get this bit up and running I'll make a post in case anyone else wants to try out the ol neural synthesis :)
-
Hmm okay block-based & single sample processing achieve the same result, is there a method to push samples to a dyn array in a FIFO manner? Would that even be stable in the audio thread?
-
Nice. If you need to pass in the channel pointers to an external function from a library, there is also
void someExternalStuff(float** ptrs, int numSamples, int numChannels) { } float** ptrs = data.getRawDataPointers(); int numSamples = data.getNumSamples(); int numChannels = data.getNumChannels();
-
Sweet. RTNeural also supports SIMD, I assume that would play nicely with HISE?
Have you come across any compatibility issues with SIMD?
-
SIMD is just a way of calculating numbers and HISE (or any other host application) doesnt‘t care how a library produces its output.
Usually you just get the pointers and sample amount and pass that to the processing function of your library.
-
@Christoph-Hart said in Block-Based Processing in Third Party Node:
dyn<float> channel = data.toChannelData(ch); float** ptrs = data.getRawDataPointers();
Is there a way to cast or have these return as doubles?
-
No.
Can you set the library to use float numbers as signal? Usually every library allows to define the floating point type used for its signal (eg. Faust is using
FAUST_FLOT
which you can define to eitherfloat
(reasonable) ordouble
("yeah, 64bit signal precision for the ultimate transparent sound").If you need to feed it double numbers then it will become very annoying because you can't just cast the pointers to double pointers because the original source are still float numbers and you would have to introduce a working buffer that uses double numbers, copy the float numbers over, process the working buffer with your library and reverse all those steps to copy it back to the signal buffer.
-
Yeah RTNeural supports floats. I think the issue is with the type of Model I'm using -> I can get a guitar amp black box model working just fine, but the whole "predict the future" version isn't playing very nice :)
I'll keep messing around