pub struct Track { /* private fields */ }
Expand description
Audio Track.
This struct holds the details for an audio track, allowing you to fetch things like duration, sector positioning, etc.
It is the return value of Toc::audio_track
.
Implementations§
source§impl Track
impl Track
sourcepub const fn bytes(self) -> u64
pub const fn bytes(self) -> u64
Byte Size.
Return the equivalent RAW PCM byte size for this track.
Examples
use cdtoc::Toc;
let toc = Toc::from_cdtoc("9+96+5766+A284+E600+11FE5+15913+19A98+1E905+240CB+26280").unwrap();
let track = toc.audio_track(9).unwrap();
assert_eq!(
track.bytes(),
20_295_408,
);
sourcepub const fn position(&self) -> TrackPosition
pub const fn position(&self) -> TrackPosition
Disc Position.
Return whether or not this track appears first, last, or somewhere in between on the disc.
Examples
use cdtoc::{Toc, TrackPosition};
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
assert_eq!(toc.audio_track(1).unwrap().position(), TrackPosition::First);
assert_eq!(toc.audio_track(2).unwrap().position(), TrackPosition::Middle);
assert_eq!(toc.audio_track(3).unwrap().position(), TrackPosition::Middle);
assert_eq!(toc.audio_track(4).unwrap().position(), TrackPosition::Last);
sourcepub const fn samples(self) -> u64
pub const fn samples(self) -> u64
Total Samples.
Return the total number of samples.
Examples
use cdtoc::Toc;
let toc = Toc::from_cdtoc("9+96+5766+A284+E600+11FE5+15913+19A98+1E905+240CB+26280").unwrap();
let track = toc.audio_track(9).unwrap();
assert_eq!(
track.samples(),
5_073_852,
);
sourcepub const fn sectors(&self) -> u32
pub const fn sectors(&self) -> u32
Sector Size.
Return the number of sectors occupied by this track.
Examples
use cdtoc::Toc;
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
let track = toc.audio_track(1).unwrap();
assert_eq!(track.sectors(), 11_413_u32);
sourcepub const fn sector_range(&self) -> Range<u32>
pub const fn sector_range(&self) -> Range<u32>
Sector Range.
Return the range of sectors — start..end
— occupied by this track.
Examples
use cdtoc::Toc;
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
let track = toc.audio_track(1).unwrap();
assert_eq!(track.sector_range(), 150..11_563);
// If you just want the length, sectors() can get that more
// directly, but it works out the same either way:
assert_eq!(track.sector_range().len(), track.sectors() as usize);