Skip to main content

Sample

Enum Sample 

Source
pub enum Sample {
    V2(Cbin<Sample>),
    V3(Cbin<SampleV3>),
}
Expand description

A sample instrument, decoded by generation: all three share the nsmp tag, and the header version says which schema the body holds.

Variants§

§

V2(Cbin<Sample>)

§

V3(Cbin<SampleV3>)

The nsmp3/nsmp4 generations: section chain decoded, strokes stored verbatim and decodable through nsmp::codec.

Implementations§

Source§

impl Sample

Source

pub fn name(&self) -> Result<String, Error>

Source

pub fn max_name_len(&self) -> usize

Longest name this generation’s field takes.

Source

pub fn set_name(&mut self, name: &str) -> Result<(), Error>

Source

pub fn set_root_key(&mut self, index: usize, note: u8) -> Result<(), Error>

Move the note a zone’s sample plays untransposed at.

Source

pub fn set_zone_top_note(&mut self, index: usize, note: u8) -> Result<(), Error>

Source

pub fn has_low_note(&self) -> bool

Whether this generation stores a zone’s lowest note.

False where zones tile — a zone reaches down to one above the next-lower zone’s top, so only the top note is stored — which is what makes Self::set_zone_low_note refuse there.

Source

pub fn set_zone_low_note(&mut self, index: usize, note: u8) -> Result<(), Error>

Move a zone’s lowest note, on the generations that store one — see Self::has_low_note.

Source

pub fn zones_are_editable(&self) -> bool

Whether this instrument’s zones can be retuned and remapped. Its name always can.

False where the zone table does not read, or where a map that also describes the keyboard note by note cannot be recomputed from the layout. The setters say which at length.

Source

pub fn chain(&self) -> Result<Chain, Error>

Which section chain this body’s sections form. A narrow body whose map version names no chain we have a specimen of reports the error.

Source

pub fn layout(&self) -> Result<Layout, Error>

Which generation’s units this body’s stroke streams are in. A content version past the generations the codec describes is refused rather than guessed at.

Source

pub fn generation(&self) -> &'static str

The generation to name in a report, taken from the content version rather than the file name.

Source

pub fn zones(&self) -> Result<Vec<ZoneAudio<'_>>, Error>

Every zone in stored order, paired with the stream that plays it.

One codec reads all three generations, so the only thing that branches here is which accessors reach the zones and their streams.

Source

pub fn stroke_streams(&self) -> Vec<(usize, &[u8])>

Every stroke’s stream in file order, whether or not a zone names it.

Source

pub fn to_bytes(&self) -> Result<Vec<u8>, Error>

Serializes, recomputing the checksum over the body it just produced.

Trait Implementations§

Source§

impl Debug for Sample

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.