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<GlobalCables::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.
-
@Orvillain
data.sampleRate
should be populated with the file samplerate if the audio buffer comes from an external file. -
@Christoph-Hart said in Getting the sample rate for an externalData object?:
@Orvillain
data.sampleRate
should be populated with the file samplerate if the audio buffer comes from an external file.Dohhhh. I was trying data.getSampleRate() - my mistake!
Is there anywhere where that sort of thing is documented Chris? If not, where should it be? I can get the ball rolling.
-
-
@Christoph-Hart haha, My Funky summary, lol that autogenerator has gone crazy...
-
Cool thanks! I'm still figuring out how all of this interfaces, but getting there and making good progress!