Reading an audio file into an interleaved destination

Hi,

I need to process audio as an interleaved buffer. From what I see, AudioFormatReader only reads into a non-interleaved buffer, splitting the sample data into channels, which is not what I need.
How can I set the reader destination to be non-interleaved?

Of course, the required buffer can be obtained by “re-interleaving” the data, however this would require inefficient copying.

Thank you.

Please, can anyone answer this? Thank you.

It’s not possible to read directly in interleaved format. If you need interleaved data, it’s probably best to use AudioData::ConverterInstance to convert from non-interleaved to interleaved after reading.

I’m already doing that (actually using AudioDataConverters::interleaveSamples).
However this means data is read from the file, changed into non-interleaved, then changed back into interleaved…
Seems very inefficient, especially when dealing with large audio files…
Is it a valid request to add an option for keeping data interleaved?

Sure, it might be useful. However, this is not a commonly-requested feature, and we’re working on some higher-priority features at the moment.

I’d recommend profiling your code to check whether the additional conversion is really a problem (that is, try measuring how long it takes to load a file with and without the additional conversion). If the conversion can be shown to take a significant amount of time, the case for adding this feature will be much stronger.

Additionally, you could consider creating a “feature request” post. If multiple users were all to request this feature, that would also strengthen the case for implementing it.

1 Like