Rounding Errors when using AudioSampleBuffer

Hi!

When using the AudioCDBurner class, I found that there were rounding errors in the audio data on the CD compared to the original wav file, which was already in 44.1 kHz, 16bit format.
I found so far, that in readFromAudioReader() the data read from the file will be converted from 16bit int values to float, because AudioSampleBuffer can only handle float values. Before writing the data to the CD, convertSamples() is called to convert that float back to 16bit again. In this process, there is a reproducable rounding error happening for some values.
It confuses me a little, that convertiong from 16bit int to 32bit float, back to 16bit int causes a rounding problem at all.

Does anyone have an idea how to come around that problem? I thought about extending the AudioSampleBuffer class to be able to pass unchanged data in other formats than float to avoid that conversion, but that could become a lot of work.

Best Regards,
Gregor

I order of likeliness:

[list]
[] Something is wrong with your code.[/]
[] You are running your code on a fake Macbook Pro you bought in Hong Kong.[/]
[] The Juce library has its float/integer conversion wrong.[/][/list]

I’ve been looking at AudioSampleBuffer::readFromAudioReader and there’s a related float conversion ( / 0x7fffffff ) if your reader has its usesFloatingPointData set to false. So maybe you have it as true?

I’m sure Jules and other know better than me where float/int conversion happen, but it would help if spell out how exactly you read the audio into AudioSampleBuffer, and any exchange of buffers between classes…