Skip to main content

SamplePanel

Struct SamplePanel 

Source
pub struct SamplePanel {
    pub attack: Level,
    pub decay_release: Level,
    pub number: u8,
    pub id: SampleRef,
    pub dynamics: RangedU8<3>,
    pub filter: bool,
    /* private fields */
}
Expand description

The sample panel: which sample plays, its envelope, and its level.

Unclaimed bits, kept verbatim through a re-encode: 57..=63.

The body’s map, in offset order:

bytesbitsfieldtype
0x00 bits 7..10..=6attackLevel
0x00 bit 0; 0x01 bits 7..27..=13decay_releaseLevel
0x01 bits 1..0; 0x02 bits 7..214..=21numberu8
0x02 bits 1..0; 0x03 bits 7..0; 0x04 bits 7..0; 0x05 bits 7..0; 0x06 bits 7..222..=53idSampleRef
0x06 bits 1..054..=55dynamicsRangedU8<3>
0x07 bit 756..=56filterbool
0x07 bits 6..057..=63unclaimed

Fields§

§attack: Level

Bits 0..=6 (byte 0x00, bits 7..1).

§decay_release: Level

Bits 7..=13 (byte 0x00, bit 0; byte 0x01, bits 7..2).

§number: u8

Zero-based slot in the instrument’s Samp Lib — the panel number minus one. A position, not an identity: adding or deleting samples renumbers it. Use id to resolve the dependency.

Bits 14..=21 (byte 0x01, bits 1..0; byte 0x02, bits 7..2).

§id: SampleRef

The sample (.nsmp) this program depends on, laid out exactly as [PianoPanel::id].

Bits 22..=53 (byte 0x02, bits 1..0; byte 0x03, bits 7..0; byte 0x04, bits 7..0; byte 0x05, bits 7..0; byte 0x06, bits 7..2).

§dynamics: RangedU8<3>

Bits 54..=55 (byte 0x06, bits 1..0).

§filter: bool

Bits 56..=56 (byte 0x07, bit 7).

Implementations§

Source§

impl SamplePanel

Source

pub fn field_values(&self) -> Vec<FieldValue>

Every registered field’s current value, under its full path, in declaration order — nested bodies inline where their field sits. Describes the same fields as Self::field_specs, so callers may zip the two positionally.

Source

pub fn field_specs() -> Vec<FieldSpec>

Source

pub fn fields(&self) -> Vec<Field>

Every settable field, described under its full path.

Source

pub fn set_field(&mut self, path: &str, value: &str) -> Result<(), FieldError>

Set one field by its full path.

Trait Implementations§

Source§

impl Body for SamplePanel

Source§

const LEN: Option<u64>

Fixed body length, when the format has one; checked on read and write.
Source§

fn read<R: Read + Seek>( r: &mut BodyReader<'_, R>, _: &Header, ) -> Result<Self, Error>

Decode from r, which is scoped to the body: position 0 is the first body byte and BodyReader::len is known. header is for version gating and location/aux interpretation, not for layout — the container already consumed the header bytes.
Source§

fn write<W: Write + Seek>(&self, w: &mut BodyWriter<'_, W>) -> Result<(), Error>

Encode to w in one forward pass.
Source§

impl BodyLayout for SamplePanel

Source§

fn layout() -> &'static [LayoutField]

Every placed field, in declaration order. Bits no field claims are preserved by the codec but have no entry here — there is no name to report them under.
Source§

impl Debug for SamplePanel

The decoded values; the backing bytes are not printed.

Source§

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

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

impl Default for SamplePanel

Source§

fn default() -> SamplePanel

Returns the “default value” for a type. Read more
Source§

impl From<&SamplePanel> for [u8; 8]

Source§

fn from(p: &SamplePanel) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<[u8; 8]> for SamplePanel

Source§

type Error = ParseError

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

fn try_from(raw: [u8; 8]) -> Result<Self, Self::Error>

Performs the conversion.

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.