1#ifndef YAZE_ZELDA3_MUSIC_SPC_PARSER_H
2#define YAZE_ZELDA3_MUSIC_SPC_PARSER_H
7#include "absl/status/statusor.h"
71 static absl::StatusOr<MusicSong>
ParseSong(
Rom& rom, uint16_t address,
83 Rom& rom, uint16_t table_address, uint8_t bank,
int max_entries = 40);
93 static absl::StatusOr<MusicTrack>
ParseTrack(
Rom& rom, uint16_t address,
95 int max_ticks = 50000);
119 static const uint8_t*
GetSpcData(
Rom& rom, uint16_t spc_address, uint8_t bank,
120 int* out_length =
nullptr);
152 static bool IsCommand(uint8_t
byte) {
return byte >= 0xE0; }
162 uint16_t address,
int repeat_count,
163 int remaining_ticks);
179 static std::vector<int16_t>
Decode(
const std::vector<uint8_t>& brr_data,
180 int* loop_start =
nullptr);
188 static std::vector<uint8_t>
Encode(
const std::vector<int16_t>& pcm_data,
189 int loop_start = -1);
193 static constexpr int kFilter1[4] = {0, 15, 61, 115};
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
BRR sample encoder/decoder.
static constexpr int kFilter2[4]
static std::vector< int16_t > Decode(const std::vector< uint8_t > &brr_data, int *loop_start=nullptr)
Decode BRR data to PCM samples.
static std::vector< uint8_t > Encode(const std::vector< int16_t > &pcm_data, int loop_start=-1)
Encode PCM samples to BRR format.
static constexpr int kFilter3[4]
static constexpr int kFilter1[4]
Parser for N-SPC music data from ROM.
static bool IsDuration(uint8_t byte)
Check if a byte is a duration value (< 128).
static bool IsCommand(uint8_t byte)
Check if a byte is a command opcode.
static absl::StatusOr< MusicSong > ParseSong(Rom &rom, uint16_t address, uint8_t bank)
Parse a complete song from ROM.
static bool IsNotePitch(uint8_t byte)
Check if a byte is a note pitch.
static absl::StatusOr< std::vector< uint16_t > > ReadSongPointerTable(Rom &rom, uint16_t table_address, uint8_t bank, int max_entries=40)
Read the song pointer table for a given SPC bank.
static const uint8_t * GetSpcData(Rom &rom, uint16_t spc_address, uint8_t bank, int *out_length=nullptr)
Get a pointer to ROM data at an SPC address.
static absl::StatusOr< MusicTrack > ParseTrackInternal(ParseContext &ctx, uint16_t address, int max_ticks)
static absl::StatusOr< int > ParseSubroutine(ParseContext &ctx, uint16_t address, int repeat_count, int remaining_ticks)
static absl::StatusOr< MusicTrack > ParseTrack(Rom &rom, uint16_t address, uint8_t bank, int max_ticks=50000)
Parse a single track from ROM.
static int GetCommandParamCount(uint8_t opcode)
Get the parameter count for an N-SPC command.
static uint32_t SpcAddressToRomOffset(Rom &rom, uint16_t spc_address, uint8_t bank)
Convert an SPC address to a ROM offset.
constexpr uint8_t kNoteRest
constexpr uint8_t kNoteMinPitch
constexpr int kCommandParamCount[32]
constexpr uint32_t kSoundBankOffsets[]
Context for parsing operations.
std::vector< uint16_t > visited_addresses