Store Sequence of Audio Samples/Buffers/Streams


I am trying to decide what the best option would be to achieve the following idea:

Two audio parameters are linked to a series of audio samples. These samples are currently stored in a ValueTree. When the parameters change, a specific audio sample is selected based on a parameter to property match in the ValuTree. The only downside with this is that the base64 audio needs to be converted to an output stream and then converted to a buffer on the fly - I would imagine that there may be better ways to do this?

I was thinking maybe a HashMap that has preloaded AudioBuffers in it - then it could operate like a ValueTree but with ready-made AudioBuffers? However I did read somewhere that HashMaps are pass-by-value, so I suspect this wouldn’t work.

Thanks all.

The value you pass in could be a std::unique_ptr<AudioBuffer<float>>… Usually I recommend to have AudioBuffer as member or on the stack only, but in this case, I think that is a legit use case.

1 Like

Thanks @daniel,

That worked a treat!

I ended up using an unordered_map instead of a HashMap - seemed to make more sense.