pub struct Bank<'a> { /* private fields */ }Expand description
A parsed bank.
Implementations§
Source§impl<'a> Bank<'a>
impl<'a> Bank<'a>
Sourcepub fn parse(bytes: &'a [u8]) -> Result<Self, FormatError>
pub fn parse(bytes: &'a [u8]) -> Result<Self, FormatError>
Parse bytes.
Sourcepub fn parse_tables(bytes: &'a [u8]) -> Result<Self, FormatError>
pub fn parse_tables(bytes: &'a [u8]) -> Result<Self, FormatError>
Parse only the tables of a bank. bytes is the container up to the end of
the tables (Bank::tables_used bytes at least), without the ADPCM
region: a game that streams the samples from disc straight into SPU RAM
never holds them in main RAM. Everything works except Bank::adpcm,
which returns an empty slice; Bank::adpcm_range says where the
region is in the full container.
§Errors
As Bank::parse, except that the ADPCM region need not be present.
use psx_seq::format::Bank;
let mut f = vec![0u8; 64];
f[..4].copy_from_slice(b"PSQB");
f[4] = 1;
f[28..32].copy_from_slice(&64u32.to_le_bytes()); // off_env
f[32..36].copy_from_slice(&64u32.to_le_bytes()); // off_adpcm
f[36..40].copy_from_slice(&4096u32.to_le_bytes()); // adpcm_bytes
assert!(Bank::parse(&f).is_err());
let b = Bank::parse_tables(&f).unwrap();
assert_eq!(b.adpcm_range(), (64, 4096));
assert!(b.adpcm().is_empty());Sourcepub fn tables_used(&self) -> usize
pub fn tables_used(&self) -> usize
Bytes from the start of the container to the end of the last table
(envelopes included): what Bank::parse_tables needs resident. The
ADPCM region starts at or after this, at Bank::adpcm_range.
Sourcepub fn adpcm_range(&self) -> (u32, u32)
pub fn adpcm_range(&self) -> (u32, u32)
Where the ADPCM region sits in the full container, as
(offset, length) in bytes.
Sourcepub fn adpcm(&self) -> &'a [u8]
pub fn adpcm(&self) -> &'a [u8]
The ADPCM region, to upload to SPU RAM (empty for a bank parsed with
Bank::parse_tables over the tables alone).
Sourcepub fn sample_count(&self) -> u16
pub fn sample_count(&self) -> u16
Number of samples.
Sourcepub fn font_index(&self, id: u8) -> Option<u8>
pub fn font_index(&self, id: u8) -> Option<u8>
Index of the font whose original id is id.
Sourcepub fn instrument(&self, font: u8, inst: u8) -> Option<Instrument>
pub fn instrument(&self, font: u8, inst: u8) -> Option<Instrument>
Instrument inst of font index font.
Sourcepub fn sample(&self, idx: u16) -> Option<SampleInfo>
pub fn sample(&self, idx: u16) -> Option<SampleInfo>
Sample idx.
Sourcepub fn resident(&self, idx: u16, base: u32) -> Option<Sample>
pub fn resident(&self, idx: u16, base: u32) -> Option<Sample>
The resident Sample for idx when the ADPCM region sits at
base in SPU RAM.
Sourcepub fn envelope_point(&self, word: u32) -> Option<(i16, i16)>
pub fn envelope_point(&self, word: u32) -> Option<(i16, i16)>
Envelope point word as (delay, arg).
Trait Implementations§
impl<'a> Copy for Bank<'a>
Auto Trait Implementations§
impl<'a> Freeze for Bank<'a>
impl<'a> RefUnwindSafe for Bank<'a>
impl<'a> Send for Bank<'a>
impl<'a> Sync for Bank<'a>
impl<'a> Unpin for Bank<'a>
impl<'a> UnsafeUnpin for Bank<'a>
impl<'a> UnwindSafe for Bank<'a>
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)