aboutsummaryrefslogtreecommitdiffstats
path: root/src/formats.rs
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2018-10-11 17:57:31 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2018-10-11 17:57:31 +0200
commit62b334873ca1ccad05c389a0cb3dedb21b05652c (patch)
tree35fa8863487c6cf847fa10e9d0bf250d967aeb89 /src/formats.rs
parent205d69bc3baa0953f2d6bf60e92ff73f6c2715da (diff)
downloadnihav-62b334873ca1ccad05c389a0cb3dedb21b05652c.tar.gz
format: add channel map conversion from M$ WAVE bitmask
Diffstat (limited to 'src/formats.rs')
-rw-r--r--src/formats.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/formats.rs b/src/formats.rs
index 5481c76..b72cd1a 100644
--- a/src/formats.rs
+++ b/src/formats.rs
@@ -175,6 +175,20 @@ pub struct NAChannelMap {
ids: Vec<NAChannelType>,
}
+const MS_CHANNEL_MAP: [NAChannelType; 11] = [
+ NAChannelType::L,
+ NAChannelType::R,
+ NAChannelType::C,
+ NAChannelType::LFE,
+ NAChannelType::Ls,
+ NAChannelType::Rs,
+ NAChannelType::Lss,
+ NAChannelType::Rss,
+ NAChannelType::Cs,
+ NAChannelType::Lc,
+ NAChannelType::Rc,
+];
+
impl NAChannelMap {
pub fn new() -> Self { NAChannelMap { ids: Vec::new() } }
pub fn add_channel(&mut self, ch: NAChannelType) {
@@ -197,6 +211,15 @@ impl NAChannelMap {
}
None
}
+ pub fn from_ms_mapping(chmap: u32) -> Self {
+ let mut cm = NAChannelMap::new();
+ for i in 0..MS_CHANNEL_MAP.len() {
+ if ((chmap >> i) & 1) != 0 {
+ cm.add_channel(MS_CHANNEL_MAP[i]);
+ }
+ }
+ cm
+ }
}
impl fmt::Display for NAChannelMap {