How does a custom c++ interface with one of its display buffers?
-
I am working on a custom node. I am taking in external audio data and processing it with a downsampler, a gate, and a high-pass filter.
I want to plot the result of my processing chain to the display buffer. But I don't know how.
This node is an offline node - it doesn't process frames. Well... actually that is not true... it does, but only for parameter debouncing. It processes the loaded audio in full, rather than frames or blocks; though I don't think this is really relevant to the question, it is just some background.
-
Yeah it's possible. Take a look at the source for external data
You can write to display buffers. But we warned, these are ring buffers and so personally I've had issues with it wrapping and having the wrong size, stuff like that. Christoph can probably set you straight. But the methods for writing into the data slot are in this header I think!
-
@griffinboy said in How does a custom c++ interface with one of its display buffers?:
Yeah it's possible. Take a look at the source for external data
You can write to display buffers. But we warned, these are ring buffers and so personally I've had issues with it wrapping and having the wrong size, stuff like that. Christoph can probably set you straight. But the methods for writing into the data slot are in this header I think!
Groovy, cheers!! I can't really suss it out.
I don't need the buffer to update with the processFrame method or anything like that. I just want to effectively set its size once, and blat a bunch of data into it. I tried accessing the ring buffer using 'rb' like this:
if (auto lock = DataReadLock(this)) { if (rb != nullptr) { rb->write(env.data(), static_cast<int>(env.size())); } } But it doesn't like the data I'm trying to feed it.
-
I resorted to ChatGPT. This compiles:
// === Write to display buffer === if (auto* ringBuffer = dynamic_cast<SimpleRingBuffer*>(this->externalData.obj)) { DataWriteLock lock(this); // Required to write safely auto& targetBuffer = ringBuffer->getWriteBuffer(); const int numSamples = static_cast<int>(env.size()); // Resize to match env targetBuffer.setSize(1, numSamples, false, false, true); for (int i = 0; i < numSamples; ++i) targetBuffer.setSample(0, i, env[i]); }
But I don't get any data displaying in the display buffer; whether I look at embedded or the 0th external slot.
-
I ended up piping data through a global cable and plotting it to a scriptPanel - it is pretty good actually!!!
But I would like to know how to utilise the display buffers directly on the node.