yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::zelda3::music Namespace Reference

Contains classes and functions for handling music data in Zelda 3. More...

Namespaces

namespace  anonymous_namespace{music_bank.cc}
 

Classes

class  AsmExporter
 Exports MusicSong to Oracle of Secrets music_macros.asm format. More...
 
struct  AsmExportOptions
 Options for ASM export in music_macros.asm format. More...
 
class  AsmImporter
 Imports music_macros.asm format files into MusicSong. More...
 
struct  AsmImportOptions
 Options for ASM import from music_macros.asm format. More...
 
struct  AsmParseResult
 Parse result with diagnostics. More...
 
class  BrrCodec
 BRR sample encoder/decoder. More...
 
struct  CommandMacroMapping
 
struct  DurationConstant
 
struct  InstrumentMacro
 
struct  InstrumentMacroMapping
 
class  MusicBank
 Manages the collection of songs, instruments, and samples from a ROM. More...
 
struct  MusicCommand
 Represents an N-SPC command (opcodes 0xE0-0xFF). More...
 
struct  MusicInstrument
 An instrument definition with ADSR envelope. More...
 
struct  MusicSample
 A BRR-encoded audio sample. More...
 
struct  MusicSegment
 A segment containing 8 parallel tracks. More...
 
struct  MusicSong
 A complete song composed of segments. More...
 
struct  MusicTrack
 One of 8 channels in a music segment. More...
 
struct  Note
 Represents a single musical note. More...
 
struct  NoteNameMapping
 
struct  SampleEdit
 A state structure for a GUI sample editor. More...
 
struct  Song
 Represents a complete song, which is a collection of SongParts. More...
 
struct  SongPart
 Represents one of the 8 channels (tracks) in a song. More...
 
struct  SongRange
 A metadata structure to keep track of parsed sections of the song data. Used to avoid re-parsing the same data from the ROM multiple times. More...
 
struct  SongSpcBlock
 Represents a block of binary data destined for the APU (SPC700) RAM. This is the intermediate format used before writing data back to the ROM. More...
 
struct  SpcCommand
 The core data structure representing a single command in a music track. A song track is a doubly-linked list of these commands. More...
 
class  SpcParser
 Parser for N-SPC music data from ROM. More...
 
class  SpcSerializer
 Serializer for N-SPC music data to ROM format. More...
 
class  Tracker
 
struct  TrackEvent
 A single event in a music track (note, command, or control). More...
 
struct  ZeldaInstrument
 Defines an instrument for a song, mapping to a sample and ADSR settings. More...
 
struct  ZeldaSfxInstrument
 Defines an instrument for a sound effect. More...
 
struct  ZeldaWave
 Represents a decoded instrument sample (a waveform). More...
 

Typedefs

using text_buf_ty = char[512]
 

Enumerations

enum class  CommandType : uint8_t {
  SetInstrument = 0xE0 , SetPan = 0xE1 , PanFade = 0xE2 , VibratoOn = 0xE3 ,
  VibratoOff = 0xE4 , SetMasterVolume = 0xE5 , MasterVolumeFade = 0xE6 , SetTempo = 0xE7 ,
  TempoFade = 0xE8 , GlobalTranspose = 0xE9 , ChannelTranspose = 0xEA , TremoloOn = 0xEB ,
  TremoloOff = 0xEC , SetChannelVolume = 0xED , ChannelVolumeFade = 0xEE , CallSubroutine = 0xEF ,
  VibratoFade = 0xF0 , PitchEnvelopeTo = 0xF1 , PitchEnvelopeFrom = 0xF2 , PitchEnvelopeOff = 0xF3 ,
  Tuning = 0xF4 , EchoVBits = 0xF5 , EchoOff = 0xF6 , EchoParams = 0xF7 ,
  EchoVolumeFade = 0xF8 , PitchSlide = 0xF9 , PercussionPatch = 0xFA
}
 

Functions

const char * GetVanillaSongName (int song_id)
 Get the vanilla name for a song ID.
 
MusicBank::Bank GetVanillaSongBank (int song_id)
 Get the bank for a vanilla song ID.
 
uint16_t LookupNSpcPitch (uint8_t note_byte)
 Look up the DSP pitch value for an N-SPC note byte.
 

Variables

constexpr DurationConstant kDurationConstants []
 
constexpr InstrumentMacro kInstrumentMacros []
 
constexpr NoteNameMapping kAsmNoteNames []
 
constexpr CommandMacroMapping kCommandMacros []
 
constexpr InstrumentMacroMapping kInstrumentMacroImport []
 
constexpr int kCommandParamCount [32]
 
constexpr uint8_t kNoteMinPitch = 0x80
 
constexpr uint8_t kNoteMaxPitch = 0xC7
 
constexpr uint8_t kNoteTie = 0xC8
 
constexpr uint8_t kNoteRest = 0xC9
 
constexpr uint8_t kTrackEnd = 0x00
 
constexpr uint8_t kDurationQuarter = 0x48
 
constexpr uint8_t kDurationQuarterDot = 0x6C
 
constexpr uint8_t kDurationQuarterTrip = 0x30
 
constexpr uint8_t kDurationEighth = 0x24
 
constexpr uint8_t kDurationEighthDot = 0x36
 
constexpr uint8_t kDurationEighthTrip = 0x18
 
constexpr uint8_t kDurationSixteenth = 0x12
 
constexpr uint8_t kDurationSixteenthDot = 0x1B
 
constexpr uint8_t kDurationThirtySecond = 0x09
 
constexpr uint32_t kOverworldBankRom = 0xD1EF5
 
constexpr uint32_t kDungeonBankRom = 0xD8000
 
constexpr uint32_t kCreditsBankRom = 0xD5380
 
constexpr uint16_t kSongTableAram = 0xD000
 
constexpr uint16_t kInstrumentTableAram = 0x3D00
 
constexpr uint16_t kSampleTableAram = 0x3C00
 
constexpr uint16_t kSampleDataAram = 0x4000
 
constexpr int kOverworldBankMaxSize = 12032
 
constexpr int kDungeonBankMaxSize = 11200
 
constexpr int kCreditsBankMaxSize = 4200
 
constexpr uint16_t kNSpcPitchTable [72]
 
constexpr uint32_t kExpandedOverworldBankRom = 0x1A9EF5
 
constexpr uint32_t kExpandedAuxBankRom = 0x1ACCA7
 
constexpr uint16_t kAuxSongTableAram = 0x2B00
 
constexpr int kExpandedOverworldBankMaxSize = 0x2DAE
 
constexpr int kAuxBankMaxSize = 0x0688
 
constexpr uint32_t kExpandedMusicHookAddress = 0x008919
 
constexpr uint8_t kJslOpcode = 0x22
 
constexpr const char * kDefaultInstrumentNames []
 
constexpr const char * kNoteNames []
 
constexpr uint32_t kSoundBankOffsets []
 
constexpr char op_len [32]
 
constexpr char fil1 [4] = {0, 15, 61, 115}
 
constexpr char fil2 [4] = {0, 4, 5, 6}
 
constexpr char fil3 [4] = {0, 0, 15, 13}
 
constexpr int kOverworldMusicBank = 0x0D0000
 
constexpr int kDungeonMusicBank = 0x0D8000
 

Detailed Description

Contains classes and functions for handling music data in Zelda 3.

Based off of the Hyrule Magic tracker code, this system is designed to parse the game's complex, pointer-based music format into an editable in-memory representation and then serialize it back into a binary format that the SNES Audio Processing Unit (APU) can understand.

Typedef Documentation

◆ text_buf_ty

Definition at line 38 of file tracker.h.

Enumeration Type Documentation

◆ CommandType

enum class yaze::zelda3::music::CommandType : uint8_t
strong
Enumerator
SetInstrument 
SetPan 
PanFade 
VibratoOn 
VibratoOff 
SetMasterVolume 
MasterVolumeFade 
SetTempo 
TempoFade 
GlobalTranspose 
ChannelTranspose 
TremoloOn 
TremoloOff 
SetChannelVolume 
ChannelVolumeFade 
CallSubroutine 
VibratoFade 
PitchEnvelopeTo 
PitchEnvelopeFrom 
PitchEnvelopeOff 
Tuning 
EchoVBits 
EchoOff 
EchoParams 
EchoVolumeFade 
PitchSlide 
PercussionPatch 

Definition at line 152 of file song_data.h.

Function Documentation

◆ GetVanillaSongName()

const char * yaze::zelda3::music::GetVanillaSongName ( int song_id)

Get the vanilla name for a song ID.

Parameters
song_idThe song ID (1-34).
Returns
The song name, or "Unknown" if invalid.

Definition at line 1202 of file music_bank.cc.

References yaze::zelda3::music::anonymous_namespace{music_bank.cc}::VanillaSongInfo::name.

Referenced by yaze::zelda3::music::MusicBank::LoadSongTable().

◆ GetVanillaSongBank()

MusicBank::Bank yaze::zelda3::music::GetVanillaSongBank ( int song_id)

Get the bank for a vanilla song ID.

Parameters
song_idThe song ID (1-34).
Returns
The bank the song belongs to.

Definition at line 1209 of file music_bank.cc.

References yaze::zelda3::music::anonymous_namespace{music_bank.cc}::VanillaSongInfo::bank, and yaze::zelda3::music::MusicBank::Overworld.

◆ LookupNSpcPitch()

uint16_t yaze::zelda3::music::LookupNSpcPitch ( uint8_t note_byte)
inline

Look up the DSP pitch value for an N-SPC note byte.

Parameters
note_byteThe note value (0x80-0xC7 for C1-B6).
Returns
The DSP pitch register value, or 0x1000 (base) for invalid notes.

Definition at line 126 of file song_data.h.

References kNoteMaxPitch, kNoteMinPitch, and kNSpcPitchTable.

Referenced by yaze::editor::music::MusicPlayer::PreviewInstrument(), and yaze::editor::music::MusicPlayer::PreviewNote().

Variable Documentation

◆ kDurationConstants

constexpr DurationConstant yaze::zelda3::music::kDurationConstants[]
constexpr
Initial value:
= {
{0x48, "!4th"},
{0x6C, "!4thD"},
{0x30, "!4thT"},
{0x24, "!8th"},
{0x36, "!8thD"},
{0x18, "!8thT"},
{0x12, "!16th"},
{0x1B, "!16thD"},
{0x09, "!32nd"},
}

Definition at line 116 of file asm_exporter.h.

Referenced by yaze::zelda3::music::AsmExporter::GetDurationConstant(), and yaze::zelda3::music::AsmImporter::ParseDurationConstant().

◆ kInstrumentMacros

constexpr InstrumentMacro yaze::zelda3::music::kInstrumentMacros[]
constexpr
Initial value:
= {
{0x02, "%Tympani()"}, {0x04, "%Sawtooth()"}, {0x05, "%Sine()"},
{0x09, "%Strings()"}, {0x0B, "%Trombone()"}, {0x0C, "%Cymbal()"},
{0x0D, "%Ocarina()"}, {0x0F, "%Harp()"}, {0x10, "%Splash()"},
{0x11, "%Trumpet()"}, {0x12, "%Horn()"}, {0x13, "%Snare()"},
{0x15, "%Choir()"}, {0x16, "%Flute()"}, {0x18, "%Piano()"},
}

Definition at line 137 of file asm_exporter.h.

Referenced by yaze::zelda3::music::AsmExporter::GetInstrumentMacro().

◆ kAsmNoteNames

constexpr NoteNameMapping yaze::zelda3::music::kAsmNoteNames[]
constexpr

Definition at line 141 of file asm_importer.h.

Referenced by yaze::zelda3::music::AsmImporter::ParseNoteName().

◆ kCommandMacros

constexpr CommandMacroMapping yaze::zelda3::music::kCommandMacros[]
constexpr
Initial value:
= {
{"SetInstrument", 0xE0, 1},
{"SetPan", 0xE1, 1},
{"PanFade", 0xE2, 2},
{"VibratoOn", 0xE3, 3},
{"VibratoOff", 0xE4, 0},
{"SetMasterVolume", 0xE5, 1},
{"MasterVolumeFade", 0xE6, 2},
{"SetTempo", 0xE7, 1},
{"TempoFade", 0xE8, 2},
{"GlobalTranspose", 0xE9, 1},
{"ChannelTranspose", 0xEA, 1},
{"TremoloOn", 0xEB, 3},
{"TremoloOff", 0xEC, 0},
{"SetChannelVolume", 0xED, 1},
{"ChannelVolumeFade", 0xEE, 2},
{"CallSubroutine", 0xEF, 3},
{"VibratoFade", 0xF0, 1},
{"PitchEnvelopeTo", 0xF1, 3},
{"PitchEnvelopeFrom", 0xF2, 3},
{"PitchEnvelopeOff", 0xF3, 0},
{"Tuning", 0xF4, 1},
{"EchoVBits", 0xF5, 1},
{"EchoOff", 0xF6, 0},
{"EchoParams", 0xF7, 3},
{"EchoVolumeFade", 0xF8, 3},
{"PitchSlide", 0xF9, 3},
{"PercussionPatch", 0xFA, 1},
}

Definition at line 233 of file asm_importer.h.

Referenced by yaze::zelda3::music::AsmImporter::ResolveCommandMacro().

◆ kInstrumentMacroImport

constexpr InstrumentMacroMapping yaze::zelda3::music::kInstrumentMacroImport[]
constexpr
Initial value:
= {
{"Tympani", 0x02}, {"Sawtooth", 0x04}, {"Sine", 0x05},
{"Strings", 0x09}, {"Trombone", 0x0B}, {"Cymbal", 0x0C},
{"Ocarina", 0x0D}, {"Harp", 0x0F}, {"Splash", 0x10},
{"Trumpet", 0x11}, {"Horn", 0x12}, {"Snare", 0x13},
{"Choir", 0x15}, {"Flute", 0x16}, {"Piano", 0x18},
}

Definition at line 269 of file asm_importer.h.

Referenced by yaze::zelda3::music::AsmImporter::ResolveInstrumentMacro().

◆ kCommandParamCount

constexpr int yaze::zelda3::music::kCommandParamCount[32]
constexpr

◆ kNoteMinPitch

◆ kNoteMaxPitch

◆ kNoteTie

◆ kNoteRest

◆ kTrackEnd

◆ kDurationQuarter

constexpr uint8_t yaze::zelda3::music::kDurationQuarter = 0x48
constexpr

◆ kDurationQuarterDot

constexpr uint8_t yaze::zelda3::music::kDurationQuarterDot = 0x6C
constexpr

Definition at line 63 of file song_data.h.

◆ kDurationQuarterTrip

constexpr uint8_t yaze::zelda3::music::kDurationQuarterTrip = 0x30
constexpr

Definition at line 64 of file song_data.h.

◆ kDurationEighth

constexpr uint8_t yaze::zelda3::music::kDurationEighth = 0x24
constexpr

◆ kDurationEighthDot

constexpr uint8_t yaze::zelda3::music::kDurationEighthDot = 0x36
constexpr

Definition at line 66 of file song_data.h.

◆ kDurationEighthTrip

constexpr uint8_t yaze::zelda3::music::kDurationEighthTrip = 0x18
constexpr

Definition at line 67 of file song_data.h.

◆ kDurationSixteenth

◆ kDurationSixteenthDot

constexpr uint8_t yaze::zelda3::music::kDurationSixteenthDot = 0x1B
constexpr

Definition at line 69 of file song_data.h.

◆ kDurationThirtySecond

constexpr uint8_t yaze::zelda3::music::kDurationThirtySecond = 0x09
constexpr

Definition at line 70 of file song_data.h.

Referenced by yaze::editor::music::PianoRollView::Draw().

◆ kOverworldBankRom

constexpr uint32_t yaze::zelda3::music::kOverworldBankRom = 0xD1EF5
constexpr

Definition at line 77 of file song_data.h.

Referenced by yaze::zelda3::music::MusicBank::GetBankRomAddress().

◆ kDungeonBankRom

constexpr uint32_t yaze::zelda3::music::kDungeonBankRom = 0xD8000
constexpr

Definition at line 78 of file song_data.h.

Referenced by yaze::zelda3::music::MusicBank::GetBankRomAddress().

◆ kCreditsBankRom

constexpr uint32_t yaze::zelda3::music::kCreditsBankRom = 0xD5380
constexpr

Definition at line 79 of file song_data.h.

Referenced by yaze::zelda3::music::MusicBank::GetBankRomAddress().

◆ kSongTableAram

◆ kInstrumentTableAram

constexpr uint16_t yaze::zelda3::music::kInstrumentTableAram = 0x3D00
constexpr

Definition at line 83 of file song_data.h.

Referenced by yaze::zelda3::music::MusicBank::LoadInstruments().

◆ kSampleTableAram

constexpr uint16_t yaze::zelda3::music::kSampleTableAram = 0x3C00
constexpr

Definition at line 84 of file song_data.h.

Referenced by yaze::zelda3::music::MusicBank::LoadSamples().

◆ kSampleDataAram

constexpr uint16_t yaze::zelda3::music::kSampleDataAram = 0x4000
constexpr

Definition at line 85 of file song_data.h.

◆ kOverworldBankMaxSize

constexpr int yaze::zelda3::music::kOverworldBankMaxSize = 12032
constexpr

Definition at line 88 of file song_data.h.

Referenced by yaze::zelda3::music::MusicBank::GetBankMaxSize().

◆ kDungeonBankMaxSize

constexpr int yaze::zelda3::music::kDungeonBankMaxSize = 11200
constexpr

Definition at line 89 of file song_data.h.

Referenced by yaze::zelda3::music::MusicBank::GetBankMaxSize().

◆ kCreditsBankMaxSize

constexpr int yaze::zelda3::music::kCreditsBankMaxSize = 4200
constexpr

Definition at line 90 of file song_data.h.

Referenced by yaze::zelda3::music::MusicBank::GetBankMaxSize().

◆ kNSpcPitchTable

constexpr uint16_t yaze::zelda3::music::kNSpcPitchTable[72]
constexpr
Initial value:
= {
0x0086, 0x008E, 0x0096, 0x009F, 0x00A9, 0x00B3,
0x00BE, 0x00C9, 0x00D6, 0x00E3, 0x00F1, 0x00FF,
0x010C, 0x011C, 0x012C, 0x013E, 0x0152, 0x0166,
0x017C, 0x0192, 0x01AC, 0x01C6, 0x01E2, 0x01FE,
0x0218, 0x0238, 0x0258, 0x027C, 0x02A4, 0x02CC,
0x02F8, 0x0324, 0x0358, 0x038C, 0x03C4, 0x03FC,
0x0430, 0x0470, 0x04B0, 0x04F8, 0x0548, 0x0598,
0x05F0, 0x0648, 0x06B0, 0x0718, 0x0788, 0x07F8,
0x0860, 0x08E0, 0x0960, 0x09F0, 0x0A90, 0x0B30,
0x0BE0, 0x0C90, 0x0D60, 0x0E30, 0x0F10, 0x0FF0,
0x10C0, 0x11C0, 0x12C0, 0x13E0, 0x1520, 0x1660,
0x17C0, 0x1920, 0x1AC0, 0x1C60, 0x1E20, 0x1FE0,
}

Definition at line 100 of file song_data.h.

Referenced by LookupNSpcPitch().

◆ kExpandedOverworldBankRom

constexpr uint32_t yaze::zelda3::music::kExpandedOverworldBankRom = 0x1A9EF5
constexpr

◆ kExpandedAuxBankRom

constexpr uint32_t yaze::zelda3::music::kExpandedAuxBankRom = 0x1ACCA7
constexpr

◆ kAuxSongTableAram

constexpr uint16_t yaze::zelda3::music::kAuxSongTableAram = 0x2B00
constexpr

◆ kExpandedOverworldBankMaxSize

constexpr int yaze::zelda3::music::kExpandedOverworldBankMaxSize = 0x2DAE
constexpr

◆ kAuxBankMaxSize

constexpr int yaze::zelda3::music::kAuxBankMaxSize = 0x0688
constexpr

Definition at line 142 of file song_data.h.

Referenced by yaze::zelda3::music::MusicBank::GetBankMaxSize().

◆ kExpandedMusicHookAddress

constexpr uint32_t yaze::zelda3::music::kExpandedMusicHookAddress = 0x008919
constexpr

◆ kJslOpcode

constexpr uint8_t yaze::zelda3::music::kJslOpcode = 0x22
constexpr

◆ kDefaultInstrumentNames

constexpr const char* yaze::zelda3::music::kDefaultInstrumentNames[]
constexpr
Initial value:
= {
"Noise",
"Tympani",
"Trombone",
"Ocarina",
"Harp",
"Splash",
"Trumpet",
"Horn",
"Snare",
"Choir",
"Flute",
"Piano",
"Cymbal",
"Strings",
"Sawtooth",
"Sine"
}

Definition at line 406 of file song_data.h.

◆ kNoteNames

constexpr const char* yaze::zelda3::music::kNoteNames[]
constexpr
Initial value:
= {
"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"
}

Definition at line 425 of file song_data.h.

Referenced by yaze::zelda3::music::Note::GetNoteName().

◆ kSoundBankOffsets

constexpr uint32_t yaze::zelda3::music::kSoundBankOffsets[]
constexpr
Initial value:
= {
0xC8000,
0xD1EF5,
0xD8000,
0xD5380
}

Definition at line 25 of file spc_parser.h.

Referenced by yaze::zelda3::music::SpcParser::ParseTrack().

◆ op_len

constexpr char yaze::zelda3::music::op_len[32]
constexpr
Initial value:
= {1, 1, 2, 3, 0, 1, 2, 1, 2, 1, 1, 3, 0, 1, 2, 3,
1, 3, 3, 0, 1, 3, 0, 3, 3, 3, 1, 2, 0, 0, 0, 0}

Definition at line 24 of file tracker.h.

◆ fil1

constexpr char yaze::zelda3::music::fil1[4] = {0, 15, 61, 115}
constexpr

Definition at line 31 of file tracker.h.

◆ fil2

constexpr char yaze::zelda3::music::fil2[4] = {0, 4, 5, 6}
constexpr

Definition at line 32 of file tracker.h.

◆ fil3

constexpr char yaze::zelda3::music::fil3[4] = {0, 0, 15, 13}
constexpr

Definition at line 33 of file tracker.h.

◆ kOverworldMusicBank

constexpr int yaze::zelda3::music::kOverworldMusicBank = 0x0D0000
constexpr

Definition at line 35 of file tracker.h.

◆ kDungeonMusicBank

constexpr int yaze::zelda3::music::kDungeonMusicBank = 0x0D8000
constexpr

Definition at line 36 of file tracker.h.