use crate::testing_prelude::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Depth {
_16,
_24,
}
impl Depth {
pub const fn as_u16(self) -> u16 {
match self {
Self::_16 => 16,
Self::_24 => 24,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Rate {
_44100,
_48000,
_96000,
_192000,
}
impl Rate {
pub const fn as_u32(self) -> u32 {
match self {
Self::_44100 => 44100,
Self::_48000 => 48000,
Self::_96000 => 96000,
Self::_192000 => 192_000,
}
}
pub(super) fn dir_suffix(self) -> &'static str {
match self {
Self::_44100 => "44.1",
Self::_48000 => "48",
Self::_96000 => "96",
Self::_192000 => "192",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct SampleFormat {
pub depth: Depth,
pub rate: Rate,
}
impl Default for SampleFormat {
fn default() -> Self {
Self::FLAC16_441
}
}
impl SampleFormat {
pub const FLAC16_441: Self = Self {
depth: Depth::_16,
rate: Rate::_44100,
};
pub const FLAC16_48: Self = Self {
depth: Depth::_16,
rate: Rate::_48000,
};
pub const FLAC24_441: Self = Self {
depth: Depth::_24,
rate: Rate::_44100,
};
pub const FLAC24_48: Self = Self {
depth: Depth::_24,
rate: Rate::_48000,
};
pub const FLAC24_96: Self = Self {
depth: Depth::_24,
rate: Rate::_96000,
};
pub fn encoding(self) -> Quality {
match self.depth {
Depth::_24 => Quality::Lossless24,
Depth::_16 => Quality::Lossless,
}
}
pub(super) fn dir_suffix(self) -> String {
format!("{{{}-{}}}", self.depth.as_u16(), self.rate.dir_suffix())
}
}