X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Faudio_mapping.cc;h=05dfb7e897de8bb1c23cdfdb01c9390519cd3d52;hp=86add09f4cb4330cdcc039fb9d8477f83e8f4465;hb=8f12e84009d7c2685bb2eeb32665876463d4e6e5;hpb=e13e5cd4cfda39b0a0b77ed8036e14e15f93ec2e diff --git a/src/lib/audio_mapping.cc b/src/lib/audio_mapping.cc index 86add09f4..05dfb7e89 100644 --- a/src/lib/audio_mapping.cc +++ b/src/lib/audio_mapping.cc @@ -81,16 +81,32 @@ AudioMapping::make_zero () } } +struct ChannelRegex +{ + ChannelRegex (string regex_, int channel_) + : regex (regex_) + , channel (channel_) + {} + + string regex; + int channel; +}; + void AudioMapping::make_default (AudioProcessor const * processor, optional filename) { - static string const regex[] = { - ".*[\\._-]L[\\._-].*", - ".*[\\._-]R[\\._-].*", - ".*[\\._-]C[\\._-].*", - ".*[\\._-]Lfe[\\._-].*", - ".*[\\._-]Ls[\\._-].*", - ".*[\\._-]Rs[\\._-].*" + static ChannelRegex const regex[] = { + ChannelRegex(".*[\\._-]L[\\._-].*", 0), + ChannelRegex(".*[\\._-]R[\\._-].*", 1), + ChannelRegex(".*[\\._-]C[\\._-].*", 2), + ChannelRegex(".*[\\._-]Lfe[\\._-].*", 3), + ChannelRegex(".*[\\._-]LFE[\\._-].*", 3), + ChannelRegex(".*[\\._-]Lss[\\._-].*", 4), + ChannelRegex(".*[\\._-]Lsr[\\._-].*", 6), + ChannelRegex(".*[\\._-]Ls[\\._-].*", 4), + ChannelRegex(".*[\\._-]Rss[\\._-].*", 5), + ChannelRegex(".*[\\._-]Rsr[\\._-].*", 7), + ChannelRegex(".*[\\._-]Rs[\\._-].*", 5), }; static int const regexes = sizeof(regex) / sizeof(*regex); @@ -105,9 +121,9 @@ AudioMapping::make_default (AudioProcessor const * processor, optionalstring(), e) && i < output_channels()) { - set (0, i, 1); + boost::regex e (regex[i].regex, boost::regex::icase); + if (boost::regex_match(filename->string(), e) && regex[i].channel < output_channels()) { + set (0, regex[i].channel, 1); guessed = true; } } @@ -163,6 +179,8 @@ AudioMapping::AudioMapping (cxml::ConstNodePtr node, int state_version) void AudioMapping::set (int input_channel, int output_channel, float g) { + DCPOMATIC_ASSERT (input_channel < int(_gain.size())); + DCPOMATIC_ASSERT (output_channel < int(_gain[0].size())); _gain[input_channel][output_channel] = g; }