Getting the sample rate for an externalData object?
Is it possible to get the sample rate for an externalData object?
We can do the following:
void setExternalData(const ExternalData& data, int index)
{
if (data.isNotEmpty())
{
auto buffer = data.toAudioSampleBuffer();
float sampleRate = 44100.0f; // Replace with actual rate if available
// down sampling and other pre-processing stages go here
hise::JSONObject obj;
obj[String("length")] = buffer.getNumSamples();
obj[String("RMS")] = buffer.getRMSLevel(0, 0, buffer.getNumSamples());
obj[String("knobValue")] = value;
this->sendDataToGlobalCable<:datacable>(obj);
}
}
But there does not seem to be a way to get the sample rate for either the data object or the buffer itself.
I’m writing a node that makes a copy of an audio buffer and downsamples it, but I would really like to track the sample-rate of the original file, so I can calculate the sample-rate of my downsampled audio.
Read more here: Source link
