diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-01-14 22:53:38 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-01-14 22:53:38 +0100 |
| commit | 0dca360f831aa51a4c0a33caa18e78c07391f3b7 (patch) | |
| tree | 155c52083c800cc0960ac07f4407e47c3227a048 /src/lib/audio_mapping.cc | |
| parent | 7f05d8fd54632f72a09b6be1b8b4cf692f290b55 (diff) | |
Add some PT-style names to the guesswork on which channel a particular sound file belongs to.
Diffstat (limited to 'src/lib/audio_mapping.cc')
| -rw-r--r-- | src/lib/audio_mapping.cc | 36 |
1 files changed, 26 insertions, 10 deletions
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<boost::filesystem::path> 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, optional<boost::fi /* See if we can guess where this stream should go */ if (filename) { for (int i = 0; i < regexes; ++i) { - boost::regex e (regex[i], boost::regex::icase); - if (boost::regex_match(filename->string(), 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; } } |
