+ int const ch = film->audio_channels ();
+
+ AudioMapping map;
+ if (mixdown_to_stereo) {
+ _output_audio_channels = 2;
+ map = AudioMapping (ch, 2);
+ float const overall_gain = 2 / (4 + sqrt(2));
+ float const minus_3dB = 1 / sqrt(2);
+ if (ch == 2) {
+ map.set (dcp::LEFT, 0, 1);
+ map.set (dcp::RIGHT, 1, 1);
+ } else if (ch == 4) {
+ map.set (dcp::LEFT, 0, overall_gain);
+ map.set (dcp::RIGHT, 1, overall_gain);
+ map.set (dcp::CENTRE, 0, overall_gain * minus_3dB);
+ map.set (dcp::CENTRE, 1, overall_gain * minus_3dB);
+ map.set (dcp::LS, 0, overall_gain);
+ } else if (ch >= 6) {
+ map.set (dcp::LEFT, 0, overall_gain);
+ map.set (dcp::RIGHT, 1, overall_gain);
+ map.set (dcp::CENTRE, 0, overall_gain * minus_3dB);
+ map.set (dcp::CENTRE, 1, overall_gain * minus_3dB);
+ map.set (dcp::LS, 0, overall_gain);
+ map.set (dcp::RS, 1, overall_gain);
+ }
+ /* XXX: maybe we should do something better for >6 channel DCPs */
+ } else {
+ _output_audio_channels = ch;
+ map = AudioMapping (ch, ch);
+ for (int i = 0; i < ch; ++i) {
+ map.set (i, i, 1);
+ }