Multichannel WAV files

Hi everybody,

I want to read a multichannel wav file with discrete channels. I created a 58 channel file using ffmpeg.

TL;DR:
Please remove the wrong assert in modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp line 1028.

After adding a workaround to set the channelset, I realised, that it is only used here:

Which means, the assert is superficial, and when it is removed, discrete multichannel WAV files will work again.

Cheers,
Daniel

Hi Daniel,

Thank you for spotting this mistake. How about something like this instead, though:

// AudioChannelSet and wav's dwChannelMask are compatible
BigInteger channelBits (channelMask);

for (auto bit = channelBits.findNextSetBit (0); bit >= 0; bit = channelBits.findNextSetBit (bit + 1))
	channelLayout.addChannel (static_cast<AudioChannelSet::ChannelType> (bit + 1));

// channel layout and number of channels do not match
if (channelLayout.size() != static_cast<int> (numChannels))
{
	// for backward compatibility with old wav files, assume 1 or 2
	// channel wav files are mono/stereo respectively
	if (numChannels <= 2 && channelMask == 0)
		channelLayout = AudioChannelSet::canonicalChannelSet (static_cast<int> (numChannels));
	else
	{
		auto discreteSpeaker = static_cast<int> (AudioChannelSet::discreteChannel0);

		while (channelLayout.size() < static_cast<int> (numChannels))
			channelLayout.addChannel (static_cast<AudioChannelSet::ChannelType> (discreteSpeaker++));
	}
}

This would use all the channel layout information provided by wav header’s dwChannelMask and then fill-up the rest with discrete channels.

Thanks, that sounds good to me.
Good idea to set a proper channel set once, instead of falling back each time it is requested.

Cheers!

OK it’s on develop with commit 8e7a207. Thank you for reporting!