A class for editing music data in a Rom. More...
#include <music_editor.h>

Classes | |
| struct | SongPianoRollWindow |
| struct | UndoState |
Public Member Functions | |
| MusicEditor (Rom *rom=nullptr) | |
| void | Initialize () override |
| absl::Status | Load () override |
| absl::Status | Save () override |
| absl::Status | Update () override |
| absl::Status | Cut () override |
| absl::Status | Copy () override |
| absl::Status | Paste () override |
| absl::Status | Undo () override |
| absl::Status | Redo () override |
| absl::Status | Find () override |
| void | set_rom (Rom *rom) |
| Rom * | rom () const |
| void | set_emulator (emu::Emulator *emulator) |
| emu::Emulator * | emulator () const |
| void | SetProject (project::YazeProject *project) |
| void | TogglePlayPause () |
| void | StopPlayback () |
| void | SpeedUp (float delta=0.1f) |
| void | SlowDown (float delta=0.1f) |
| void | OpenSong (int song_index) |
| void | FocusSong (int song_index) |
Public Member Functions inherited from yaze::editor::Editor | |
| Editor ()=default | |
| virtual | ~Editor ()=default |
| void | SetDependencies (const EditorDependencies &deps) |
| virtual void | SetGameData (zelda3::GameData *game_data) |
| virtual absl::Status | Clear () |
| EditorType | type () const |
| bool * | active () |
| void | set_active (bool active) |
| void | toggle_active () |
| virtual bool | IsRomLoaded () const |
| virtual std::string | GetRomStatus () const |
| Rom * | rom () const |
| zelda3::GameData * | game_data () const |
| EditorContext | context () const |
| bool | HasContext () const |
Private Member Functions | |
| void | DrawSongTrackerWindow (int song_index) |
| void | DrawPlaybackControl () |
| void | DrawTrackerView () |
| void | DrawPianoRollView () |
| void | DrawInstrumentEditor () |
| void | DrawSampleEditor () |
| void | DrawSongBrowser () |
| void | DrawToolset () |
| void | DrawChannelOverview () |
| absl::StatusOr< bool > | RestoreMusicState () |
| absl::Status | PersistMusicState (const char *reason=nullptr) |
| void | MarkMusicDirty () |
| void | PushUndoState () |
| void | RestoreState (const UndoState &state) |
| int | current_channel () const |
| void | set_current_channel (int channel) |
| void | OpenSongPianoRoll (int song_index) |
| void | ExportSongToAsm (int song_index) |
| void | ImportSongFromAsm (int song_index) |
| bool | ImportAsmBufferToSong (int song_index) |
| void | DrawAsmPopups () |
| void | SeekToSegment (int segment_index) |
Additional Inherited Members | |
Protected Member Functions inherited from yaze::editor::Editor | |
| std::string | MakePanelTitle (const std::string &base_title) const |
| std::string | MakePanelId (const std::string &base_id) const |
| template<typename T > | |
| absl::StatusOr< T > | SafeRomAccess (std::function< T()> accessor, const std::string &operation="") const |
Protected Attributes inherited from yaze::editor::Editor | |
| bool | active_ = false |
| EditorType | type_ |
| EditorDependencies | dependencies_ |
A class for editing music data in a Rom.
Definition at line 89 of file music_editor.h.
|
inlineexplicit |
Definition at line 91 of file music_editor.h.
References yaze::editor::kMusic, and yaze::editor::Editor::type_.
|
overridevirtual |
Implements yaze::editor::Editor.
Definition at line 41 of file music_editor.cc.
References assembly_editor_, audio_backend_, yaze::emu::audio::AudioConfig::buffer_frames, yaze::emu::audio::AudioConfig::channels, yaze::emu::audio::AudioBackendFactory::Create(), current_channel_index_, current_segment_index_, current_song_index_, yaze::editor::Editor::dependencies_, emulator_, yaze::emu::audio::AudioConfig::format, ICON_MD_BUG_REPORT, ICON_MD_CODE, ICON_MD_HELP, ICON_MD_LIBRARY_MUSIC, ICON_MD_PIANO, ICON_MD_PLAY_CIRCLE, ICON_MD_SPEAKER, ICON_MD_WAVES, instrument_editor_view_, yaze::emu::audio::INT16, LOG_ERROR, LOG_INFO, LOG_WARN, music_bank_, music_player_, OpenSong(), OpenSongPianoRoll(), yaze::editor::EditorDependencies::panel_manager, piano_roll_view_, yaze::editor::PanelManager::RegisterPanel(), rom_, sample_editor_view_, yaze::emu::audio::AudioConfig::sample_rate, yaze::emu::audio::AudioBackendFactory::SDL2, yaze::emu::Emulator::SetExternalAudioBackend(), song_browser_view_, song_window_class_, and yaze::emu::audio::AudioBackendFactory::WASM.
|
overridevirtual |
Implements yaze::editor::Editor.
Definition at line 240 of file music_editor.cc.
References yaze::zelda3::music::MusicBank::LoadFromRom(), LOG_INFO, LOG_WARN, yaze::project::YazeProject::MakeStorageKey(), music_bank_, yaze::project::YazeProject::music_persistence, music_player_, music_storage_key_, yaze::project::YazeProject::MusicPersistence::persist_custom_music, persist_custom_music_, project_, RestoreMusicState(), rom_, and yaze::project::YazeProject::MusicPersistence::storage_key.

|
overridevirtual |
Implements yaze::editor::Editor.
Definition at line 543 of file music_editor.cc.
References music_bank_, PersistMusicState(), RETURN_IF_ERROR, rom_, and yaze::zelda3::music::MusicBank::SaveToRom().

|
overridevirtual |
Implements yaze::editor::Editor.
Definition at line 308 of file music_editor.cc.
References active_songs_, yaze::editor::Editor::dependencies_, DrawAsmPopups(), DrawSongTrackerWindow(), yaze::editor::PanelManager::GetActiveCategory(), yaze::zelda3::music::MusicBank::GetSong(), yaze::editor::PanelManager::GetVisibilityFlag(), yaze::zelda3::music::MusicBank::HasModifications(), ICON_MD_MUSIC_NOTE, yaze::editor::PanelManager::IsPanelPinned(), yaze::editor::PanelManager::IsPanelVisible(), last_music_persist_, LOG_WARN, music_bank_, music_dirty_, music_player_, music_storage_key_, yaze::zelda3::music::MusicSong::name, yaze::editor::EditorDependencies::panel_manager, persist_custom_music_, PersistMusicState(), PushUndoState(), song_browser_auto_shown_, song_cards_, song_piano_rolls_, song_trackers_, song_window_class_, tracker_auto_shown_, and yaze::editor::PanelManager::UnregisterPanel().
|
overridevirtual |
Implements yaze::editor::Editor.
Definition at line 617 of file music_editor.cc.
References Copy(), and PushUndoState().

|
overridevirtual |
Implements yaze::editor::Editor.
Definition at line 625 of file music_editor.cc.
Referenced by Cut().
|
overridevirtual |
Implements yaze::editor::Editor.
Definition at line 631 of file music_editor.cc.
|
overridevirtual |
Implements yaze::editor::Editor.
Definition at line 637 of file music_editor.cc.
References current_song_index_, yaze::zelda3::music::MusicBank::GetSong(), music_bank_, redo_stack_, RestoreState(), yaze::editor::MusicEditor::UndoState::song_index, yaze::editor::MusicEditor::UndoState::song_snapshot, and undo_stack_.

|
overridevirtual |
Implements yaze::editor::Editor.
Definition at line 653 of file music_editor.cc.
References current_song_index_, yaze::zelda3::music::MusicBank::GetSong(), music_bank_, redo_stack_, RestoreState(), yaze::editor::MusicEditor::UndoState::song_index, yaze::editor::MusicEditor::UndoState::song_snapshot, and undo_stack_.

|
inlineoverridevirtual |
Implements yaze::editor::Editor.
Definition at line 104 of file music_editor.h.
|
inline |
|
inline |
| void yaze::editor::MusicEditor::set_emulator | ( | emu::Emulator * | emulator | ) |
Definition at line 213 of file music_editor.cc.
References audio_backend_, emulator(), emulator_, LOG_INFO, music_player_, and yaze::emu::Emulator::SetExternalAudioBackend().

|
inline |
| void yaze::editor::MusicEditor::SetProject | ( | project::YazeProject * | project | ) |
Definition at line 229 of file music_editor.cc.
References yaze::project::YazeProject::MakeStorageKey(), yaze::project::YazeProject::music_persistence, music_storage_key_, yaze::project::YazeProject::MusicPersistence::persist_custom_music, persist_custom_music_, project_, and yaze::project::YazeProject::MusicPersistence::storage_key.

| void yaze::editor::MusicEditor::TogglePlayPause | ( | ) |
Definition at line 276 of file music_editor.cc.
References music_player_.
Referenced by DrawSongTrackerWindow().
| void yaze::editor::MusicEditor::StopPlayback | ( | ) |
Definition at line 288 of file music_editor.cc.
References music_player_.
Referenced by DrawSongTrackerWindow().
| void yaze::editor::MusicEditor::SpeedUp | ( | float | delta = 0.1f | ) |
Definition at line 294 of file music_editor.cc.
References music_player_.
Referenced by DrawSongTrackerWindow().
| void yaze::editor::MusicEditor::SlowDown | ( | float | delta = 0.1f | ) |
Definition at line 301 of file music_editor.cc.
References music_player_.
Referenced by DrawSongTrackerWindow().
| void yaze::editor::MusicEditor::OpenSong | ( | int | song_index | ) |
Definition at line 708 of file music_editor.cc.
References active_songs_, current_segment_index_, current_song_index_, yaze::editor::Editor::dependencies_, FocusSong(), yaze::zelda3::music::MusicBank::GetSong(), ICON_MD_MUSIC_NOTE, LOG_INFO, music_bank_, yaze::zelda3::music::MusicSong::name, yaze::editor::EditorDependencies::panel_manager, yaze::editor::PanelManager::RegisterPanel(), and yaze::editor::PanelManager::ShowPanel().
Referenced by DrawPlaybackControl(), and Initialize().

| void yaze::editor::MusicEditor::FocusSong | ( | int | song_index | ) |
|
private |
Definition at line 810 of file music_editor.cc.
References yaze::editor::music::TrackerView::Draw(), DrawChannelOverview(), yaze::zelda3::music::MusicBank::GetSong(), ICON_MD_EDIT, ICON_MD_GRAPHIC_EQ, ICON_MD_PAUSE, ICON_MD_PAUSE_CIRCLE, ICON_MD_PIANO, ICON_MD_PLAY_ARROW, ICON_MD_SPEED, ICON_MD_STOP, yaze::editor::music::PlaybackState::is_playing, music_bank_, music_player_, OpenSongPianoRoll(), yaze::gui::SliderFloatWheel(), SlowDown(), song_trackers_, SpeedUp(), StopPlayback(), TogglePlayPause(), and tracker_view_.
Referenced by Update().
|
private |
Definition at line 953 of file music_editor.cc.
References current_song_index_, DrawChannelOverview(), DrawToolset(), yaze::zelda3::music::MusicBank::GetSong(), ICON_MD_EDIT, ICON_MD_KEYBOARD, ICON_MD_OPEN_IN_NEW, ICON_MD_PIANO, music_bank_, music_player_, OpenSong(), and OpenSongPianoRoll().
|
private |
Definition at line 1053 of file music_editor.cc.
References current_song_index_, yaze::editor::music::TrackerView::Draw(), yaze::zelda3::music::MusicBank::GetSong(), music_bank_, and tracker_view_.

|
private |
Definition at line 1058 of file music_editor.cc.
References current_channel_index_, current_segment_index_, current_song_index_, yaze::editor::music::PianoRollView::Draw(), yaze::editor::music::PianoRollView::GetActiveChannel(), yaze::editor::music::PianoRollView::GetActiveSegment(), yaze::zelda3::music::MusicBank::GetSong(), music_bank_, music_player_, piano_roll_view_, PushUndoState(), yaze::editor::music::PianoRollView::SetActiveChannel(), yaze::editor::music::PianoRollView::SetActiveSegment(), yaze::editor::music::PianoRollView::SetOnEditCallback(), yaze::editor::music::PianoRollView::SetOnNotePreview(), yaze::editor::music::PianoRollView::SetOnSegmentPreview(), and yaze::editor::music::PianoRollView::SetPlaybackState().
|
private |
Definition at line 1093 of file music_editor.cc.
References yaze::editor::music::InstrumentEditorView::Draw(), instrument_editor_view_, and music_bank_.

|
private |
Definition at line 1097 of file music_editor.cc.
References yaze::editor::music::SampleEditorView::Draw(), music_bank_, and sample_editor_view_.

|
private |
Definition at line 699 of file music_editor.cc.
References current_song_index_, yaze::editor::music::SongBrowserView::Draw(), yaze::editor::music::SongBrowserView::GetSelectedSongIndex(), music_bank_, yaze::editor::music::SongBrowserView::SetSelectedSongIndex(), and song_browser_view_.

|
private |
Definition at line 1101 of file music_editor.cc.
References yaze::emu::Emulator::audio_backend(), channel_soloed_, yaze::gui::ConvertColorToImVec4(), current_song_index_, yaze::gui::ThemeManager::Get(), yaze::gui::ThemeManager::GetCurrentTheme(), yaze::zelda3::music::MusicBank::GetSong(), yaze::emu::audio::IAudioBackend::GetStatus(), ICON_MD_BUG_REPORT, ICON_MD_EDIT, ICON_MD_GRAPHIC_EQ, ICON_MD_PAUSE, ICON_MD_PAUSE_CIRCLE, ICON_MD_PLAY_ARROW, ICON_MD_REFRESH, ICON_MD_SPEED, ICON_MD_STOP, ICON_MD_VOLUME_UP, ICON_MD_WARNING, yaze::emu::Emulator::is_snes_initialized(), yaze::zelda3::music::MusicBank::LoadFromRom(), music_bank_, music_player_, rom_, yaze::gui::SliderFloatWheel(), yaze::gui::SliderIntWheel(), yaze::emu::Emulator::snes(), and song_names_.
Referenced by DrawPlaybackControl().
|
private |
Definition at line 1350 of file music_editor.cc.
References music_player_.
Referenced by DrawPlaybackControl(), and DrawSongTrackerWindow().
|
private |
Definition at line 557 of file music_editor.cc.
References last_music_persist_, yaze::zelda3::music::MusicBank::LoadFromJson(), music_bank_, music_dirty_, music_storage_key_, and RETURN_IF_ERROR.
Referenced by Load().

|
private |
Definition at line 584 of file music_editor.cc.
References last_music_persist_, yaze::project::YazeProject::MusicPersistence::last_saved_at, LOG_DEBUG, music_bank_, music_dirty_, yaze::project::YazeProject::music_persistence, music_storage_key_, persist_custom_music_, project_, RETURN_IF_ERROR, yaze::project::YazeProject::MusicPersistence::storage_key, and yaze::zelda3::music::MusicBank::ToJson().
Referenced by Save(), and Update().

|
private |
Definition at line 615 of file music_editor.cc.
References music_dirty_.
Referenced by PushUndoState(), and RestoreState().
|
private |
Definition at line 669 of file music_editor.cc.
References current_song_index_, yaze::zelda3::music::MusicBank::GetSong(), MarkMusicDirty(), music_bank_, redo_stack_, yaze::editor::MusicEditor::UndoState::song_index, yaze::editor::MusicEditor::UndoState::song_snapshot, and undo_stack_.
Referenced by Cut(), DrawPianoRollView(), ImportAsmBufferToSong(), and Update().

|
private |
Definition at line 689 of file music_editor.cc.
References current_song_index_, yaze::zelda3::music::MusicBank::GetSong(), yaze::zelda3::music::MusicBank::GetSongCount(), MarkMusicDirty(), music_bank_, yaze::editor::MusicEditor::UndoState::song_index, and yaze::editor::MusicEditor::UndoState::song_snapshot.
Referenced by Redo(), and Undo().

|
inlineprivate |
Definition at line 182 of file music_editor.h.
References current_channel_index_.
|
inlineprivate |
Definition at line 183 of file music_editor.h.
References current_channel_index_.
|
private |
Definition at line 757 of file music_editor.cc.
References yaze::editor::MusicEditor::SongPianoRollWindow::card, yaze::editor::Editor::dependencies_, yaze::zelda3::music::MusicBank::GetSong(), yaze::zelda3::music::MusicBank::GetSongCount(), ICON_MD_PIANO, music_bank_, yaze::zelda3::music::MusicSong::name, yaze::editor::EditorDependencies::panel_manager, yaze::editor::PanelManager::RegisterPanel(), yaze::editor::PanelManager::ShowPanel(), song_piano_rolls_, yaze::editor::MusicEditor::SongPianoRollWindow::view, and yaze::editor::MusicEditor::SongPianoRollWindow::visible_flag.
Referenced by DrawPlaybackControl(), DrawSongTrackerWindow(), and Initialize().

|
private |
Definition at line 1433 of file music_editor.cc.
References asm_buffer_, yaze::zelda3::music::AsmExportOptions::base_aram_address, yaze::zelda3::music::AsmExporter::ExportSong(), yaze::zelda3::music::MusicBank::GetSong(), yaze::zelda3::music::AsmExportOptions::include_comments, yaze::zelda3::music::MusicBank::IsExpandedSong(), yaze::zelda3::music::kAuxSongTableAram, yaze::zelda3::music::kSongTableAram, yaze::zelda3::music::AsmExportOptions::label_prefix, LOG_ERROR, LOG_INFO, LOG_WARN, music_bank_, show_asm_export_popup_, and yaze::zelda3::music::AsmExportOptions::use_instrument_macros.

|
private |
Definition at line 1473 of file music_editor.cc.
References asm_buffer_, asm_import_error_, asm_import_target_index_, ImportAsmBufferToSong(), LOG_INFO, and show_asm_import_popup_.

|
private |
Definition at line 1494 of file music_editor.cc.
References asm_buffer_, asm_import_error_, yaze::zelda3::music::MusicBank::GetSong(), yaze::zelda3::music::AsmImporter::ImportSong(), LOG_ERROR, LOG_INFO, LOG_WARN, music_bank_, PushUndoState(), yaze::zelda3::music::AsmImportOptions::strict_mode, and yaze::zelda3::music::AsmImportOptions::verbose_errors.
Referenced by DrawAsmPopups(), and ImportSongFromAsm().

|
private |
Definition at line 1544 of file music_editor.cc.
References asm_buffer_, asm_import_error_, asm_import_target_index_, ImportAsmBufferToSong(), show_asm_export_popup_, and show_asm_import_popup_.
Referenced by Update().

|
private |
Definition at line 1425 of file music_editor.cc.
References music_player_.
|
private |
Definition at line 149 of file music_editor.h.
Referenced by Initialize().
|
private |
Definition at line 152 of file music_editor.h.
Referenced by DrawInstrumentEditor(), DrawPianoRollView(), DrawPlaybackControl(), DrawSampleEditor(), DrawSongBrowser(), DrawSongTrackerWindow(), DrawToolset(), DrawTrackerView(), ExportSongToAsm(), ImportAsmBufferToSong(), Initialize(), Load(), OpenSong(), OpenSongPianoRoll(), PersistMusicState(), PushUndoState(), Redo(), RestoreMusicState(), RestoreState(), Save(), Undo(), and Update().
|
private |
Definition at line 153 of file music_editor.h.
Referenced by DrawSongTrackerWindow(), and DrawTrackerView().
|
private |
Definition at line 154 of file music_editor.h.
Referenced by DrawPianoRollView(), and Initialize().
|
private |
Definition at line 155 of file music_editor.h.
Referenced by DrawInstrumentEditor(), and Initialize().
|
private |
Definition at line 156 of file music_editor.h.
Referenced by DrawSampleEditor(), and Initialize().
|
private |
Definition at line 157 of file music_editor.h.
Referenced by DrawSongBrowser(), and Initialize().
|
private |
Definition at line 164 of file music_editor.h.
Referenced by PushUndoState(), Redo(), and Undo().
|
private |
Definition at line 165 of file music_editor.h.
Referenced by PushUndoState(), Redo(), and Undo().
|
private |
Definition at line 173 of file music_editor.h.
Referenced by DrawPianoRollView(), DrawPlaybackControl(), DrawSongBrowser(), DrawToolset(), DrawTrackerView(), Initialize(), OpenSong(), PushUndoState(), Redo(), RestoreState(), and Undo().
|
private |
Definition at line 174 of file music_editor.h.
|
private |
Definition at line 175 of file music_editor.h.
Referenced by current_channel(), DrawPianoRollView(), Initialize(), and set_current_channel().
|
private |
Definition at line 176 of file music_editor.h.
Referenced by DrawPianoRollView(), Initialize(), and OpenSong().
|
private |
Definition at line 177 of file music_editor.h.
|
private |
Definition at line 178 of file music_editor.h.
Referenced by DrawToolset().
|
private |
Definition at line 179 of file music_editor.h.
Referenced by DrawToolset().
|
private |
Definition at line 187 of file music_editor.h.
|
private |
Definition at line 191 of file music_editor.h.
|
private |
Definition at line 195 of file music_editor.h.
Referenced by DrawToolset(), Initialize(), Load(), rom(), Save(), and set_rom().
|
private |
Definition at line 196 of file music_editor.h.
Referenced by emulator(), Initialize(), and set_emulator().
|
private |
Definition at line 197 of file music_editor.h.
Referenced by Load(), PersistMusicState(), and SetProject().
|
private |
Definition at line 201 of file music_editor.h.
Referenced by Initialize(), and set_emulator().
|
private |
Definition at line 202 of file music_editor.h.
Referenced by Update().
|
private |
Definition at line 203 of file music_editor.h.
Referenced by Update().
|
private |
Definition at line 204 of file music_editor.h.
Referenced by MarkMusicDirty(), PersistMusicState(), RestoreMusicState(), and Update().
|
private |
Definition at line 205 of file music_editor.h.
Referenced by Load(), PersistMusicState(), SetProject(), and Update().
|
private |
Definition at line 206 of file music_editor.h.
Referenced by Load(), PersistMusicState(), RestoreMusicState(), SetProject(), and Update().
|
private |
Definition at line 207 of file music_editor.h.
Referenced by PersistMusicState(), RestoreMusicState(), and Update().
|
private |
Definition at line 210 of file music_editor.h.
Referenced by OpenSong(), and Update().
|
private |
Definition at line 211 of file music_editor.h.
Referenced by FocusSong(), and Update().
|
private |
Definition at line 213 of file music_editor.h.
Referenced by DrawSongTrackerWindow(), and Update().
|
private |
Definition at line 219 of file music_editor.h.
Referenced by OpenSongPianoRoll(), and Update().
|
private |
Definition at line 222 of file music_editor.h.
Referenced by Initialize(), and Update().
|
private |
Definition at line 232 of file music_editor.h.
Referenced by DrawAsmPopups(), ExportSongToAsm(), ImportAsmBufferToSong(), and ImportSongFromAsm().
|
private |
Definition at line 233 of file music_editor.h.
Referenced by DrawAsmPopups(), and ExportSongToAsm().
|
private |
Definition at line 234 of file music_editor.h.
Referenced by DrawAsmPopups(), and ImportSongFromAsm().
|
private |
Definition at line 235 of file music_editor.h.
Referenced by DrawAsmPopups(), and ImportSongFromAsm().
|
private |
Definition at line 236 of file music_editor.h.
Referenced by DrawAsmPopups(), ImportAsmBufferToSong(), and ImportSongFromAsm().
|
private |
Definition at line 240 of file music_editor.h.
Referenced by DrawChannelOverview(), DrawPianoRollView(), DrawPlaybackControl(), DrawSongTrackerWindow(), DrawToolset(), Initialize(), Load(), SeekToSegment(), set_emulator(), SlowDown(), SpeedUp(), StopPlayback(), TogglePlayPause(), and Update().