I've been attempting to playback an audio file from a buffer (short int) using the Superpowered Audio SDK. Currently, on each call of the process function, I have the output buffer passed in and written like so:
getBufferData(short int *output, unsigned int samples) {
memcpy(output, buffer + bufferPtr, samples * sizeOf(short int));
bufferPtr += samples;
}
The resulting audio is recognizable as the song I'm attempting to play, but heavily distorted.
I Have checked that the data in the buffer is what I'm expecting by writing it to a wav file and testing playback that way.
A hunch of mine is that the memcpy routine may be too intensive to call so frequently, but I haven't been able to find an alternative.
I also understand that this method of playback is not the appropriate way to play back an audio file using superpowered, but for my use case is required.
Any guidance would be greatly appreciated!