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

SongHeader

Struct SongHeader 

Source
pub struct SongHeader {
    pub flags: u16,
    pub n_fonts: u8,
    pub peak_voices: u8,
    pub code_len: u16,
    pub font_ids: [u8; 8],
    pub code_off: u16,
}
Expand description

The parsed header of a song.

Fields§

§flags: u16

Flag bits.

§n_fonts: u8

Number of soundfont ids.

§peak_voices: u8

Voices the song needs at most (measured by the cook).

§code_len: u16

Bytes of bytecode.

§font_ids: [u8; 8]

Soundfont ids, in the original table order (slot s is n - 1 - s).

§code_off: u16

Offset of the bytecode in the file.

Implementations§

Source§

impl SongHeader

Source

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

Parse the header of bytes.

use psx_seq::format::*;
let mut f = vec![];
f.extend_from_slice(b"PSQ1");
f.extend_from_slice(&[1, 0, 0, 0, 1, 6, 2, 0, 1, 0, 0, 0]);
f.extend_from_slice(&[7, 0, 0, 0]);
f.extend_from_slice(&[0xFF, 0xFF]);
let h = SongHeader::parse(&f).unwrap();
assert_eq!((h.n_fonts, h.peak_voices, h.code_len, h.font_ids[0]), (1, 6, 2, 7));
assert_eq!(h.code_off, 20);
Source

pub fn code<'a>(&self, bytes: &'a [u8]) -> &'a [u8]

The bytecode inside bytes.

Source

pub fn code_mut<'a>(&self, bytes: &'a mut [u8]) -> &'a mut [u8]

The bytecode inside bytes, writable (songs that patch themselves need RAM; the file is normally loaded into RAM anyway).

Trait Implementations§

Source§

impl Clone for SongHeader

Source§

fn clone(&self) -> SongHeader

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 Debug for SongHeader

Source§

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

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

impl PartialEq for SongHeader

Source§

fn eq(&self, other: &SongHeader) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for SongHeader

Source§

impl Eq for SongHeader

Source§

impl StructuralPartialEq for SongHeader

Auto Trait Implementations§

§

impl Freeze for SongHeader

§

impl RefUnwindSafe for SongHeader

§

impl Send for SongHeader

§

impl Sync for SongHeader

§

impl Unpin for SongHeader

§

impl UnsafeUnpin for SongHeader

§

impl UnwindSafe for SongHeader

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.