I’m trying to use a copy of the demo convolution reverb plugin code to upload several head-related transfer functions (HRTFs, i.e. very short .wav files) to create a better sense of audio spatialization. I’m using the built-in (in the Native Audio SDK demo) ConvolutionReverb_UploadSample function (see below) to load audio buffers as impulse responses, but the audio content/waveform changes every time I upload the same audio buffer.
For example, when I try to upload an impulse response recorded at a certain location (5 degrees azimuth in this case), sometimes I get this:

…other times I get this:

…and other times I get this:

It’s the exact same audio file, and this same thing happens even if I try loading sample buffers that I hardcode rather than uploading, so I’m fairly confident that my file upload process is not the culprit.
This is the function I’m using to upload files. It’s already included in the original file in the SDK - I did not modify anything within it. It looks fine, and I even tried manually setting some of the necessary data rather than using this function, but to no avail.
extern "C" UNITY_AUDIODSP_EXPORT_API bool ConvolutionReverbCopy_UploadSample(int index, float* data, int numsamples, int numchannels, int samplerate, const char* name)
{
if (index < 0 || index >= ConvolutionReverbCopy::MAXSAMPLE)
return false;
MutexScopeLock mutexScope(ConvolutionReverbCopy::sampleMutex);
ConvolutionReverbCopy::IRSample& s = ConvolutionReverbCopy::GetIRSample(index);
if (s.allocated)
delete[] s.data;
int num = numsamples * numchannels;
if (num > 0)
{
s.data = new float[num];
s.allocated = 1;
strcpy_s(s.name, name);
memcpy(s.data, data, numsamples * numchannels * sizeof(float));
}
else
{
s.data = NULL;
s.allocated = 1;
}
s.numsamples = numsamples;
s.numchannels = numchannels;
s.samplerate = samplerate;
s.updatecount = ++ConvolutionReverbCopy::globalupdatecount;
return true;
}
Summary: Can anyone help me identify why the audio content is manipulated differently every time I upload the same file?