Some questions about AudioFormatReader


I’m trying to create a new AudioFormatReader and have a few questions about implementing it’s correct behaviour. Looking at your code in WavAudioFormatReader you do an average of both channels if numChannels > 1 and only the left channel is requested, but in other readers, like OggReader for example, this is different. Also in OggReader one can never read the right channel only because it breaks if the left channel pointer = 0, whereas in WavAudioFormatReader you can. So what would be the correct behaviour?

Hmm, sounds like you’ve found a couple of bugettes in the ogg code. The intended behaviour is to do what the wav reader does. I’ll go through that and tidy it up…

…actually, mulling it over, I’ve changed my mind about this.

Trying to make all the readers deal with mono/stereo channel splitting and merging involves far too much duplicated logic. I think what I’ll do is make the readers simpler - so that each non-zero channel you give it should be filled with data from the corresponding channel in the file.

The logic of duplicating mono files to stereo and vice-versa could be moved in a base class method that wraps the read() method and keeps all that logic in one place. I’ll do some refactoring shortly…