pub mod speaker;
mod class_codes;
mod terminal_type;
const MAX_AUDIO_CHANNEL_INDEX: usize = 12;
const MAX_AUDIO_CHANNEL_COUNT: usize = MAX_AUDIO_CHANNEL_INDEX + 1;
#[derive(Debug, Clone, Copy, PartialEq)]
#[allow(missing_docs)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Channel {
LeftFront,
RightFront,
CenterFront,
Lfe,
LeftSurround,
RightSurround,
LeftOfCenter,
RightOfCenter,
Surround,
SideLeft,
SideRight,
Top,
}
impl Channel {
fn get_channel_config(&self) -> ChannelConfig {
match self {
Channel::LeftFront => ChannelConfig::LeftFront,
Channel::RightFront => ChannelConfig::RightFront,
Channel::CenterFront => ChannelConfig::CenterFront,
Channel::Lfe => ChannelConfig::Lfe,
Channel::LeftSurround => ChannelConfig::LeftSurround,
Channel::RightSurround => ChannelConfig::RightSurround,
Channel::LeftOfCenter => ChannelConfig::LeftOfCenter,
Channel::RightOfCenter => ChannelConfig::RightOfCenter,
Channel::Surround => ChannelConfig::Surround,
Channel::SideLeft => ChannelConfig::SideLeft,
Channel::SideRight => ChannelConfig::SideRight,
Channel::Top => ChannelConfig::Top,
}
}
}
#[repr(u16)]
#[non_exhaustive]
enum ChannelConfig {
None = 0x0000,
LeftFront = 0x0001,
RightFront = 0x0002,
CenterFront = 0x0004,
Lfe = 0x0008,
LeftSurround = 0x0010,
RightSurround = 0x0020,
LeftOfCenter = 0x0040,
RightOfCenter = 0x0080,
Surround = 0x0100,
SideLeft = 0x0200,
SideRight = 0x0400,
Top = 0x0800,
}
impl From<ChannelConfig> for u16 {
fn from(t: ChannelConfig) -> u16 {
t as u16
}
}
#[repr(u8)]
#[allow(missing_docs)]
#[derive(Clone, Copy)]
pub enum FeedbackRefresh {
Period2Frames = 1,
Period4Frames = 2,
Period8Frames = 3,
Period16Frames = 4,
Period32Frames = 5,
Period64Frames = 6,
Period128Frames = 7,
Period256Frames = 8,
Period512Frames = 9,
}
impl FeedbackRefresh {
pub const fn frame_count(&self) -> usize {
1 << (*self as usize)
}
}
#[repr(u8)]
#[derive(Clone, Copy)]
pub enum SampleWidth {
Width2Byte = 2,
Width3Byte = 3,
Width4Byte = 4,
}
impl SampleWidth {
pub const fn in_bit(self) -> usize {
8 * self as usize
}
}