Skip to main content

parse_patterns

Function parse_patterns 

Source
pub fn parse_patterns(
    header: &XmHeader,
    bytes: &[u8],
) -> Result<(Vec<XmPattern>, usize)>
Expand description

Parse all patterns starting from the end of the file header.

For each pattern:

  • Reads the 9-byte pattern header.
  • If packed_size == 0, the pattern is “all empty” — emits num_rows rows of num_channels default cells without advancing into packed data.
  • Otherwise, decodes num_rows * num_channels cells from the packed block, tolerating truncation by emitting default cells for any leftover slots.

Returns the decoded patterns and the absolute byte offset after the last pattern (where the instrument table begins).