/* SPDX-License-Identifier: MIT. RPMC-26 complete memory song contract. */
#ifndef RPMC_H
#define RPMC_H
#include <stddef.h>
#include <stdint.h>
typedef struct {uint8_t *bytes;size_t size;} rpmc_bytes;
typedef struct {uint16_t index;uint8_t meta[1399];rpmc_bytes name;uint8_t keymap[240];} rpmc_meta;
typedef struct {uint16_t index;rpmc_bytes name;uint8_t keymap[96];} rpmc_xm_instrument;
typedef struct {uint32_t pan,volume,muted,surround;} rpmc_channel;
typedef struct {
    uint32_t format,length,channels,patterns,speed,bpm,global_volume,mix_volume,pan_separation,flags,restart;
    rpmc_bytes title,message,events,sample_data,source_data;
    uint8_t macros[1152];uint32_t *order,*order_rows,*pattern_rows;rpmc_channel *channel_state;
    rpmc_meta *samples,*instruments;rpmc_xm_instrument *xm_instruments;
    size_t sample_count,instrument_count,xm_instrument_count;
} rpmc_song;
/* meta is the complete LE numeric SampleMeta contract; cells are 44-byte events.
 * All successful decode allocations belong to song; release with rpmc_free.
 * Encode returns one allocation owned by caller; release with free().
 */
int rpmc_decode(const uint8_t *,size_t,rpmc_song *);
int rpmc_encode(const rpmc_song *,uint8_t **,size_t *);
void rpmc_free(rpmc_song *);
#endif
