Migrating from AudioSampleBufer to AudioBuffer [SOLVED]

#1

Hello,

Am going through a video lecture that (most excellent forum user!) Xenakios pointed me to, but also the tutorial on Looping Audio with the Audio SampleBufferClass also still assumes use of the deprecated class, so to better understand, I have some questions:

  1. Is there any documentation on why AudioSampleBuffer was deprecated?

  2. Can you do everything you could do with AudioSampleBuffer in AudioBuffer (in exactly the same way?)

  3. Why does AudioBuffer take a template type? I just got lucky and assumed <float> but what else would you want to put in your AudioBuffer???

As always, a million thanks!

#2

The AudioSampleBuffer is in fact just an AudioBuffer<float>. Its name was given before the class was templated and kept for backward compatibility, afaik.

  1. It’s not deprecated, just a different name of the same thing
  2. obviously, see 1 :wink:
  3. You can use double, which is used if supportsDoublePrecisionProcessing() is set and theoretically for other types as well
#3

Thank you! So going forwards, better to use AudioBuffer<float> in new code?

#4

It doesn’t make a difference whether you use AudioBuffer<float> or AudioSampleBuffer. They are exactly the same. But using AudioBuffer in method signatures and such can offer more flexibility if your code also needs to be able to deal with AudioBuffer<double>.

For example an audio channel routing thing I did has a method like :

template<typename T, typename U>
void processAudio(const AudioBuffer<T>& inbuf, AudioBuffer<U>& outbuf)

In that the input and output buffers can be AudioBuffers of either float or double.

1 Like