1#ifndef YAZE_ZELDA3_MUSIC_MUSIC_BANK_H
2#define YAZE_ZELDA3_MUSIC_MUSIC_BANK_H
8#include "absl/status/status.h"
9#include "absl/status/statusor.h"
11#include "nlohmann/json.hpp"
30 enum class Bank : uint8_t {
213 const std::string&
name);
257 nlohmann::json
ToJson()
const;
263 std::vector<MusicSong>* custom_songs);
270 std::vector<MusicSong>* custom_songs);
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Represents the full Overworld data, light and dark world.
Manages the collection of songs, instruments, and samples from a ROM.
static uint8_t GetSpcBankId(Bank bank)
static uint32_t GetBankRomAddress(Bank bank)
Get the ROM address for a bank.
bool HasModifications() const
Check if any music data has been modified.
MusicInstrument * GetInstrument(int index)
Get an instrument by index.
int CreateNewInstrument(const std::string &name)
Create a new instrument.
static constexpr uint16_t GetSongTableAddress()
nlohmann::json ToJson() const
bool IsVanilla(int index) const
Check if a song is a vanilla (original) song.
absl::Status LoadFromJson(const nlohmann::json &j)
absl::Status LoadSamples(Rom &rom)
size_t GetSampleCount() const
Get the number of samples.
MusicSong * GetSongById(int song_id)
Get a song by vanilla ID (1-based).
MusicSong * GetSong(int index)
Get a song by index.
absl::Status DetectExpandedMusicPatch(Rom &rom)
absl::Status LoadInstruments(Rom &rom)
static int GetBankMaxSize(Bank bank)
Get the maximum size for a bank.
ExpandedBankInfo expanded_bank_info_
size_t GetInstrumentCount() const
Get the number of instruments.
size_t GetSongCount() const
Get the number of songs loaded.
std::vector< MusicSample > samples_
const ExpandedBankInfo & GetExpandedBankInfo() const
Get information about the expanded bank configuration.
absl::Status LoadSongTable(Rom &rom, Bank bank, std::vector< MusicSong > *custom_songs)
bool AllSongsFit() const
Check if all songs fit in their banks.
static BankSongRange GetBankSongRange(Bank bank)
absl::Status SaveInstruments(Rom &rom)
MusicSample * GetSample(int index)
Get a sample by index.
absl::Status DeleteSong(int index)
Delete a song by index.
MusicBank & operator=(const MusicBank &)=delete
MusicBank & operator=(MusicBank &&)=default
MusicBank(MusicBank &&)=default
std::vector< MusicSong > songs_
SpaceInfo CalculateSpaceUsage(Bank bank) const
Calculate space usage for a bank.
absl::StatusOr< int > ImportSampleFromWav(const std::string &filepath, const std::string &name)
Import a WAV file as a new sample.
absl::Status SaveSamples(Rom &rom)
absl::Status SaveToRom(Rom &rom)
Save all modified music data back to ROM.
absl::Status SaveSongTable(Rom &rom, Bank bank)
int auxiliary_song_count_
int CalculateSongSize(const MusicSong &song) const
bool IsExpandedSong(int index) const
Check if a song is from an expanded bank.
int overworld_song_count_
void ClearModifications()
Mark all data as unmodified (after save).
absl::Status LoadExpandedSongTable(Rom &rom, std::vector< MusicSong > *custom_songs)
bool instruments_modified_
std::vector< MusicInstrument > instruments_
MusicBank(const MusicBank &)=delete
int CreateNewSong(const std::string &name, Bank bank)
Create a new empty song.
bool IsLoaded() const
Check if music data has been loaded.
absl::Status LoadFromRom(Rom &rom)
Load all music data from a ROM.
std::vector< MusicSong * > GetSongsInBank(Bank bank)
Get all songs in a specific bank.
bool HasExpandedMusicPatch() const
Check if the ROM has the Oracle of Secrets expanded music patch.
int DuplicateSong(int index)
Duplicate a song.
MusicBank::Bank GetVanillaSongBank(int song_id)
Get the bank for a vanilla song ID.
constexpr uint16_t kSongTableAram
const char * GetVanillaSongName(int song_id)
Get the vanilla name for a song ID.
uint16_t aux_aram_address
std::string recommendation
An instrument definition with ADSR envelope.
A BRR-encoded audio sample.
A complete song composed of segments.