Fix up the dataSize calculation, it was using sampleRate instead of numSamples, resulting in a file that was always 1s per the header.