@Orvillain
3d59f862-0879-4207-8770-9f6729fd3a8b-image.png
huh... well I got SOMETHING in there...
This is just chatGPT chod, but it has given me the above. The issue is... it doesn't update immediately, I have to switch the selected display buffer in the node using the external icon button.
// ==================================| Third Party Node Template |==================================
#pragma once
#include <JuceHeader.h>
namespace project
{
using namespace juce;
using namespace hise;
using namespace scriptnode;
// ==========================| The node class with all required callbacks |==========================
template <int NV> struct LoadAudio: public data::base, public data::display_buffer_base<true>
{
// Metadata Definitions ------------------------------------------------------------------------
SNEX_NODE(LoadAudio);
struct MetadataClass
{
SN_NODE_ID("LoadAudio");
};
// set to true if you want this node to have a modulation dragger
static constexpr bool isModNode() { return false; };
static constexpr bool isPolyphonic() { return NV > 1; };
// set to true if your node produces a tail
static constexpr bool hasTail() { return false; };
// set to true if your doesn't generate sound from silence and can be suspended when the input signal is silent
static constexpr bool isSuspendedOnSilence() { return false; };
// Undefine this method if you want a dynamic channel count
static constexpr int getFixChannelAmount() { return 2; };
// Define the amount and types of external data slots you want to use
static constexpr int NumTables = 0;
static constexpr int NumSliderPacks = 0;
static constexpr int NumAudioFiles = 1;
static constexpr int NumFilters = 0;
static constexpr int NumDisplayBuffers = 1;
AudioBuffer<float> originalBuffer;
int originalSampleRate;
int originalNumSamples;
bool bufferNeedsUpdate = false;
// Scriptnode Callbacks ------------------------------------------------------------------------
void prepare(PrepareSpecs specs) override
{
display_buffer_base<true>::prepare(specs);
if (rb != nullptr)
{
rb->setActive(true);
if (bufferNeedsUpdate && originalBuffer.getNumChannels() > 0)
{
updateBuffer(originalBuffer.getReadPointer(0), originalNumSamples);
bufferNeedsUpdate = false;
}
}
}
void reset()
{
}
void handleHiseEvent(HiseEvent& e)
{
}
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());
}
}
template <typename T> void processFrame(T& data)
{
}
int handleModulation(double& value)
{
return 0;
}
void setExternalData(const ExternalData& data, int index) override
{
display_buffer_base<true>::setExternalData(data, index);
if (data.isNotEmpty())
{
originalBuffer = data.toAudioSampleBuffer();
originalSampleRate = data.sampleRate;
originalNumSamples = originalBuffer.getNumSamples();
bufferNeedsUpdate = true; // β
delay actual update
}
}
// Parameter Functions -------------------------------------------------------------------------
template <int P> void setParameter(double v)
{
if (P == 0)
{
// This will be executed for MyParameter (see below)
jassertfalse;
}
}
void createParameters(ParameterDataList& data)
{
{
// Create a parameter like this
parameter::data p("MyParameter", { 0.0, 1.0 });
// The template parameter (<0>) will be forwarded to setParameter<P>()
registerCallback<0>(p);
p.setDefaultValue(0.5);
data.add(std::move(p));
}
}
};
}