summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-01-14 22:53:38 +0100
committerCarl Hetherington <cth@carlh.net>2020-01-14 21:55:06 +0000
commitdf62a2d137400c6c6286675f30597b91203e6374 (patch)
tree31c2fe97772ffb8a7a8a308b95286295af85f7ea /src
parent4a7730e78a55be61ae37e024e17dd1897f2dccad (diff)
Add some PT-style names to the guesswork on which channel a particular sound file belongs to.
Backported from 0dca360f831aa51a4c0a33caa18e78c07391f3b7 in v2.15.x.
Diffstat (limited to 'src')
-rw-r--r--src/lib/audio_mapping.cc36
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;
}
}