mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-13 22:22:31 +00:00
bit_depth prototype
This commit is contained in:
parent
d034782a27
commit
29378f53a5
10 changed files with 20 additions and 0 deletions
|
@ -25,6 +25,7 @@ impl From<ApeProperties> for FileProperties {
|
||||||
overall_bitrate: Some(input.overall_bitrate),
|
overall_bitrate: Some(input.overall_bitrate),
|
||||||
audio_bitrate: Some(input.audio_bitrate),
|
audio_bitrate: Some(input.audio_bitrate),
|
||||||
sample_rate: Some(input.sample_rate),
|
sample_rate: Some(input.sample_rate),
|
||||||
|
bit_depth: None,
|
||||||
channels: Some(input.channels),
|
channels: Some(input.channels),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ pub(super) fn read_properties(
|
||||||
overall_bitrate,
|
overall_bitrate,
|
||||||
audio_bitrate,
|
audio_bitrate,
|
||||||
sample_rate: Some(sample_rate),
|
sample_rate: Some(sample_rate),
|
||||||
|
bit_depth: None,
|
||||||
channels: Some(channels),
|
channels: Some(channels),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ impl From<WavProperties> for FileProperties {
|
||||||
overall_bitrate: Some(input.overall_bitrate),
|
overall_bitrate: Some(input.overall_bitrate),
|
||||||
audio_bitrate: Some(input.audio_bitrate),
|
audio_bitrate: Some(input.audio_bitrate),
|
||||||
sample_rate: Some(input.sample_rate),
|
sample_rate: Some(input.sample_rate),
|
||||||
|
bit_depth: None,
|
||||||
channels: Some(input.channels),
|
channels: Some(input.channels),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ impl From<Mp3Properties> for FileProperties {
|
||||||
overall_bitrate: Some(input.overall_bitrate),
|
overall_bitrate: Some(input.overall_bitrate),
|
||||||
audio_bitrate: Some(input.audio_bitrate),
|
audio_bitrate: Some(input.audio_bitrate),
|
||||||
sample_rate: Some(input.sample_rate),
|
sample_rate: Some(input.sample_rate),
|
||||||
|
bit_depth: None,
|
||||||
channels: Some(input.channels),
|
channels: Some(input.channels),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ impl From<Mp4Properties> for FileProperties {
|
||||||
overall_bitrate: Some(input.overall_bitrate),
|
overall_bitrate: Some(input.overall_bitrate),
|
||||||
audio_bitrate: Some(input.audio_bitrate),
|
audio_bitrate: Some(input.audio_bitrate),
|
||||||
sample_rate: Some(input.sample_rate),
|
sample_rate: Some(input.sample_rate),
|
||||||
|
bit_depth: None,
|
||||||
channels: Some(input.channels),
|
channels: Some(input.channels),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ where
|
||||||
let info = stream_info.read_u32::<BigEndian>()?;
|
let info = stream_info.read_u32::<BigEndian>()?;
|
||||||
|
|
||||||
let sample_rate = info >> 12;
|
let sample_rate = info >> 12;
|
||||||
|
let bits_per_sample = ((info >> 4) & 0b1111) + 1;
|
||||||
let channels = ((info >> 9) & 7) + 1;
|
let channels = ((info >> 9) & 7) + 1;
|
||||||
|
|
||||||
// Read the remaining 32 bits of the total samples
|
// Read the remaining 32 bits of the total samples
|
||||||
|
@ -54,6 +55,7 @@ where
|
||||||
overall_bitrate,
|
overall_bitrate,
|
||||||
audio_bitrate,
|
audio_bitrate,
|
||||||
sample_rate: Some(sample_rate as u32),
|
sample_rate: Some(sample_rate as u32),
|
||||||
|
bit_depth: Some(bits_per_sample as u8),
|
||||||
channels: Some(channels as u8),
|
channels: Some(channels as u8),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ impl From<OpusProperties> for FileProperties {
|
||||||
overall_bitrate: Some(input.overall_bitrate),
|
overall_bitrate: Some(input.overall_bitrate),
|
||||||
audio_bitrate: Some(input.audio_bitrate),
|
audio_bitrate: Some(input.audio_bitrate),
|
||||||
sample_rate: Some(input.input_sample_rate),
|
sample_rate: Some(input.input_sample_rate),
|
||||||
|
bit_depth: None,
|
||||||
channels: Some(input.channels),
|
channels: Some(input.channels),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ impl From<VorbisProperties> for FileProperties {
|
||||||
overall_bitrate: Some(input.overall_bitrate),
|
overall_bitrate: Some(input.overall_bitrate),
|
||||||
audio_bitrate: Some(input.audio_bitrate),
|
audio_bitrate: Some(input.audio_bitrate),
|
||||||
sample_rate: Some(input.sample_rate),
|
sample_rate: Some(input.sample_rate),
|
||||||
|
bit_depth: None,
|
||||||
channels: Some(input.channels),
|
channels: Some(input.channels),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ pub struct FileProperties {
|
||||||
pub(crate) overall_bitrate: Option<u32>,
|
pub(crate) overall_bitrate: Option<u32>,
|
||||||
pub(crate) audio_bitrate: Option<u32>,
|
pub(crate) audio_bitrate: Option<u32>,
|
||||||
pub(crate) sample_rate: Option<u32>,
|
pub(crate) sample_rate: Option<u32>,
|
||||||
|
pub(crate) bit_depth: Option<u8>,
|
||||||
pub(crate) channels: Option<u8>,
|
pub(crate) channels: Option<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +18,7 @@ impl Default for FileProperties {
|
||||||
overall_bitrate: None,
|
overall_bitrate: None,
|
||||||
audio_bitrate: None,
|
audio_bitrate: None,
|
||||||
sample_rate: None,
|
sample_rate: None,
|
||||||
|
bit_depth: None,
|
||||||
channels: None,
|
channels: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +31,7 @@ impl FileProperties {
|
||||||
overall_bitrate: Option<u32>,
|
overall_bitrate: Option<u32>,
|
||||||
audio_bitrate: Option<u32>,
|
audio_bitrate: Option<u32>,
|
||||||
sample_rate: Option<u32>,
|
sample_rate: Option<u32>,
|
||||||
|
bit_depth: Option<u8>,
|
||||||
channels: Option<u8>,
|
channels: Option<u8>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -36,6 +39,7 @@ impl FileProperties {
|
||||||
overall_bitrate,
|
overall_bitrate,
|
||||||
audio_bitrate,
|
audio_bitrate,
|
||||||
sample_rate,
|
sample_rate,
|
||||||
|
bit_depth,
|
||||||
channels,
|
channels,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,6 +64,11 @@ impl FileProperties {
|
||||||
self.sample_rate
|
self.sample_rate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Bits per sample (usually 16 or 24 bit)
|
||||||
|
pub fn bit_depth(&self) -> Option<u8> {
|
||||||
|
self.bit_depth
|
||||||
|
}
|
||||||
|
|
||||||
/// Channel count
|
/// Channel count
|
||||||
pub fn channels(&self) -> Option<u8> {
|
pub fn channels(&self) -> Option<u8> {
|
||||||
self.channels
|
self.channels
|
||||||
|
|
|
@ -13,6 +13,7 @@ const AIFF_PROPERTIES: FileProperties = FileProperties::new(
|
||||||
Some(1542),
|
Some(1542),
|
||||||
Some(1536),
|
Some(1536),
|
||||||
Some(48000),
|
Some(48000),
|
||||||
|
None,
|
||||||
Some(2),
|
Some(2),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ const FLAC_PROPERTIES: FileProperties = FileProperties::new(
|
||||||
Some(321),
|
Some(321),
|
||||||
Some(275),
|
Some(275),
|
||||||
Some(48000),
|
Some(48000),
|
||||||
|
None,
|
||||||
Some(2),
|
Some(2),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue