Skip to main content
← PSoXide SDK guides and examples · SDK 80d1c329e977 · All Cargo features enabled; check feature gates before use.

Bank

Struct Bank 

Source
pub struct Bank<'a> { /* private fields */ }
Expand description

A parsed bank.

Implementations§

Source§

impl<'a> Bank<'a>

Source

pub fn parse(bytes: &'a [u8]) -> Result<Self, FormatError>

Parse bytes.

Source

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());
Source

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.

Source

pub fn adpcm_range(&self) -> (u32, u32)

Where the ADPCM region sits in the full container, as (offset, length) in bytes.

Source

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).

Source

pub fn sample_count(&self) -> u16

Number of samples.

Source

pub fn font_index(&self, id: u8) -> Option<u8>

Index of the font whose original id is id.

Source

pub fn instrument(&self, font: u8, inst: u8) -> Option<Instrument>

Instrument inst of font index font.

Source

pub fn drum(&self, font: u8, key: u8) -> Option<Drum>

Drum key of font index font.

Source

pub fn sample(&self, idx: u16) -> Option<SampleInfo>

Sample idx.

Source

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.

Source

pub fn envelope_point(&self, word: u32) -> Option<(i16, i16)>

Envelope point word as (delay, arg).

Trait Implementations§

Source§

impl<'a> Clone for Bank<'a>

Source§

fn clone(&self) -> Bank<'a>

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Bank<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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 T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.