#pragma once #include "types.h" enum CWAV_ENCODING { CWAV_ENCODING_PCM8 = 0, CWAV_ENCODING_PCM16 = 1, CWAV_ENCODING_DSPADPCM = 2, CWAV_ENCODING_IMAADPCM = 3, }; enum CWAV_REFTYPE { CWAV_REFTYPE_DSP_ADPCM_INFO = 0x0300, CWAV_REFTYPE_IMA_ADPCM_INFO = 0x0301, CWAV_REFTYPE_SAMPLE_DATA = 0x1F00, CWAV_REFTYPE_INFO_BLOCK = 0x7000, CWAV_REFTYPE_DATA_BLOCK = 0x7001, CWAV_REFTYPE_CHANNEL_INFO = 0x7100, }; struct cwav_reference { // 0x00 tc::bn::le16 idtype; // See CWAV_REFTYPE // 0x02 tc::bn::pad<2> padding; // 0x04 tc::bn::le32 offset; // 0x08 }; struct cwav_sizedreference { // 0x00 tc::bn::le16 idtype; // See CWAV_REFTYPE // 0x02 tc::bn::pad<2> padding; // 0x04 tc::bn::le32 offset; // 0x08 tc::bn::le32 size; // 0x0C }; struct cwav_header { static const uint32_t kStructMagic = tc::bn::make_struct_magic_uint32("CWAV"); // 0x00 tc::bn::le32 magic; // 0x04 tc::bn::le16 byteordermark; // byte_t[2]{0xFF,0xFE} == little endian, byte_t[2]{0xFE,0xFF} == big endian // 0x06 tc::bn::le16 headersize; // 0x08 tc::bn::le32 version; // 0x0C tc::bn::le32 totalsize; // 0x10 tc::bn::le16 datablocks; // 0x12 tc::bn::pad<2> reserved; // 0x14 cwav_sizedreference infoblockref; // 0x20 cwav_sizedreference datablockref; // 0x2C }; struct cwav_infoheader { static const uint32_t kStructMagic = tc::bn::make_struct_magic_uint32("INFO"); // 0x00 tc::bn::le32 magic; // 0x04 tc::bn::le32 size; // 0x08 byte_t encoding; // See CWAV_ENCODING // 0x09 byte_t looped; // 0 = no loop, 1 = loop // 0x0A tc::bn::pad<2> padding; // 0x0C tc::bn::le32 samplerate; // 0x10 tc::bn::le32 loopstart; // 0x14 tc::bn::le32 loopend; // 0x18 tc::bn::pad<4> reserved; // 0x1C //tc::bn::le32 channelcount; // 0x20 }; struct cwav_referencetable { // 0x00 tc::bn::le32 ref_count; // 0x04 cwav_reference[] ref_entry; }; struct cwav_channelinfo { // 0x00 cwav_reference sampleref; // 0x08 cwav_reference codecref; // 0x10 tc::bn::pad<4> reserved; // 0x14 }; struct cwav_dspadpcminfo { // 0x00 std::array, 16> coef; // 0x20 tc::bn::le16 scale; // 0x22 tc::bn::le16 yn1; // 0x24 tc::bn::le16 yn2; // 0x26 tc::bn::le16 loopscale; // 0x28 tc::bn::le16 loopyn1; // 0x2A tc::bn::le16 loopyn2; // 0x2C }; struct cwav_imaadpcminfo { // 0x00 tc::bn::le16 data; // 0x02 byte_t tableindex; // 0x03 byte_t padding; // 0x04 tc::bn::le16 loopdata; // 0x06 byte_t looptableindex; // 0x07 byte_t looppadding; // 0x08 };