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
impl Sample
pub fn name(&self) -> Result<String, Error>
Sourcepub fn max_name_len(&self) -> usize
pub fn max_name_len(&self) -> usize
Longest name this generation’s field takes.
pub fn set_name(&mut self, name: &str) -> Result<(), Error>
Sourcepub fn set_root_key(&mut self, index: usize, note: u8) -> Result<(), Error>
pub fn set_root_key(&mut self, index: usize, note: u8) -> Result<(), Error>
Move the note a zone’s sample plays untransposed at.
pub fn set_zone_top_note(&mut self, index: usize, note: u8) -> Result<(), Error>
Sourcepub fn has_low_note(&self) -> bool
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.
Sourcepub fn set_zone_low_note(&mut self, index: usize, note: u8) -> Result<(), Error>
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.
Sourcepub fn zones_are_editable(&self) -> bool
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.
Sourcepub fn chain(&self) -> Result<Chain, Error>
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.
Sourcepub fn layout(&self) -> Result<Layout, Error>
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.
Sourcepub fn generation(&self) -> &'static str
pub fn generation(&self) -> &'static str
The generation to name in a report, taken from the content version rather than the file name.
Sourcepub fn zones(&self) -> Result<Vec<ZoneAudio<'_>>, Error>
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.
Sourcepub fn stroke_streams(&self) -> Vec<(usize, &[u8])>
pub fn stroke_streams(&self) -> Vec<(usize, &[u8])>
Every stroke’s stream in file order, whether or not a zone names it.