From 0dca360f831aa51a4c0a33caa18e78c07391f3b7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 14 Jan 2020 22:53:38 +0100 Subject: Add some PT-style names to the guesswork on which channel a particular sound file belongs to. --- src/lib/audio_mapping.cc | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/lib/audio_mapping.cc b/src/lib/audio_mapping.cc index f07d5dece..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; } } -- cgit v1.2.3