Please implement CoreAudioFormat::createWriterFor() :-)

I’ve been trying to put together a multichannel audio file recorder, primarily for recording 3rd and 5th order ambisonics in 16 and 36 channel formats. The WAV writer doesn’t support those channel counts and CAF is not implemented. Google are supporting ambix/caf for their spatial audio platforms - would be great to be able to work with these files in JUCE!

1 Like

Looks like the WAV-writer used to work for up to 32 channels before the recent changes. (Higher channel counts like 36 still produce the output file but the highest channels seem to be silent. That could however be due to my test code.)

@Xenakios What exactly doesn’t work anymore with the wav-writer? I’ve just tried the following code which opens a 7.1 surround file and exports it again. Seems to work fine for me:

int main (int argc, char* argv[])
    AudioFormatManager fm;

    File surround71 ("Surround7.1.wav");
    ScopedPointer<AudioFormatReader> reader (fm.createReaderFor (surround71.createInputStream()));

    if (reader != nullptr)
        File testWav ("test.wav");
        if (testWav.existsAsFile())

        jassert (! testWav.existsAsFile());

        ScopedPointer<AudioFormatWriter> writer (fm.findFormatForFileExtension ("wav")->createWriterFor (testWav.createOutputStream(),
                                                                                                         {}, 0));
        if (writer != nullptr)
            writer->writeFromAudioReader (*reader, 0, reader->lengthInSamples);

    return 0;

@fabian as far as I know it should be possible to record 16 or 32, 36 channels etc. to wav. i.e. not one of the “wave format extensible” surroundsound formats. reaper certainly can

Agreed, you should be able to create a file of any arbitrary number of channels.


It (createWriterFor) doesn’t seem to work with any number of channels given via AudioChannelSet::discreteChannels(int). If I use the old signature which takes the number of channels as an integer, it works only up to 8 channels now. (Used to work for at least 32 channels with older Juce.) My use case doesn’t care about specific surround layouts, I just want to write a file with an arbitrary channel count. (Although a bit of a fringe use case, I may have to deal with files up to thousands of channels… :wink: )

This is fixed now on develop with commits 0cf21a4 and fb310f7.