From b78a7062cb2b696e976f64091dbdf58133661067 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Wed, 28 Jan 2026 18:56:03 +0100 Subject: [PATCH] nihav_core/formats: add another helper function for NAChannelType --- nihav-core/src/formats.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nihav-core/src/formats.rs b/nihav-core/src/formats.rs index 722bd18..967ac73 100644 --- a/nihav-core/src/formats.rs +++ b/nihav-core/src/formats.rs @@ -172,6 +172,17 @@ impl NAChannelType { NAChannelType::Rhs | NAChannelType::Rl | NAChannelType::Rt | NAChannelType::Ro) } + /// Returns binaural channel pair corresponding to the provided centre channel (or `None` otherwise). + pub fn get_pair(self) -> Option<(Self, Self)> { + match self { + NAChannelType::C => Some((NAChannelType::L, NAChannelType::R)), + NAChannelType::Ch => Some((NAChannelType::Lh, NAChannelType::Rh)), + NAChannelType::Cl => Some((NAChannelType::Ll, NAChannelType::Rl)), + NAChannelType::Cs => Some((NAChannelType::Ls, NAChannelType::Rs)), + NAChannelType::Chs => Some((NAChannelType::Lhs, NAChannelType::Rhs)), + _ => None + } + } } impl FromStr for NAChannelType { -- 2.39.5