This example should load wave in to memory only when Wav0Load will be called. But i am not sure if it will be working. And free memory when Wav0Unload is called. For more control over memory use float * wav0 instead std::vector;
// wav0.h
static std::vector<float> wav0;
void Wav0Load()
{
if (wav0.size() == 0)
{
wav0.resize(numSamples);
// fill the wav0 with data
}
}
void Wav0Unload()
{
if (wav0.size() > 0)
{
wav0.clear();
wav0.shrink_to_fit();
}
}