yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::MusicEditor Class Reference

A class for editing music data in a Rom. More...

#include <music_editor.h>

Inheritance diagram for yaze::editor::MusicEditor:

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)
 
Romrom () const
 
void set_emulator (emu::Emulator *emulator)
 
emu::Emulatoremulator () 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
 
Romrom () const
 
zelda3::GameDatagame_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)
 

Private Attributes

AssemblyEditor assembly_editor_
 
zelda3::music::MusicBank music_bank_
 
editor::music::TrackerView tracker_view_
 
editor::music::PianoRollView piano_roll_view_
 
editor::music::InstrumentEditorView instrument_editor_view_
 
editor::music::SampleEditorView sample_editor_view_
 
editor::music::SongBrowserView song_browser_view_
 
std::vector< UndoStateundo_stack_
 
std::vector< UndoStateredo_stack_
 
int current_song_index_ = 0
 
int current_pattern_index_ = 0
 
int current_channel_index_ = 0
 
int current_segment_index_ = 0
 
std::vector< bool > channel_muted_ = std::vector<bool>(8, false)
 
std::vector< bool > channel_soloed_ = std::vector<bool>(8, false)
 
std::vector< std::string > song_names_
 
ImGuiTableFlags music_editor_flags_
 
ImGuiTableFlags toolset_table_flags_
 
Romrom_
 
emu::Emulatoremulator_ = nullptr
 
project::YazeProjectproject_ = nullptr
 
std::unique_ptr< emu::audio::IAudioBackendaudio_backend_
 
bool song_browser_auto_shown_ = false
 
bool tracker_auto_shown_ = false
 
bool music_dirty_ = false
 
bool persist_custom_music_ = true
 
std::string music_storage_key_
 
std::chrono::steady_clock::time_point last_music_persist_
 
ImVector< int > active_songs_
 
std::unordered_map< int, std::shared_ptr< gui::PanelWindow > > song_cards_
 
std::unordered_map< int, std::unique_ptr< editor::music::TrackerView > > song_trackers_
 
std::unordered_map< int, SongPianoRollWindowsong_piano_rolls_
 
ImGuiWindowClass song_window_class_
 
std::string asm_buffer_
 
bool show_asm_export_popup_ = false
 
bool show_asm_import_popup_ = false
 
int asm_import_target_index_ = -1
 
std::string asm_import_error_
 
std::unique_ptr< editor::music::MusicPlayermusic_player_
 

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_
 

Detailed Description

A class for editing music data in a Rom.

Definition at line 89 of file music_editor.h.

Constructor & Destructor Documentation

◆ MusicEditor()

yaze::editor::MusicEditor::MusicEditor ( Rom * rom = nullptr)
inlineexplicit

Definition at line 91 of file music_editor.h.

References yaze::editor::kMusic, and yaze::editor::Editor::type_.

Member Function Documentation

◆ Initialize()

◆ Load()

◆ Save()

absl::Status yaze::editor::MusicEditor::Save ( )
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().

Here is the call graph for this function:

◆ Update()

◆ Cut()

absl::Status yaze::editor::MusicEditor::Cut ( )
overridevirtual

Implements yaze::editor::Editor.

Definition at line 617 of file music_editor.cc.

References Copy(), and PushUndoState().

Here is the call graph for this function:

◆ Copy()

absl::Status yaze::editor::MusicEditor::Copy ( )
overridevirtual
Todo
Serialize selected events to clipboard

Implements yaze::editor::Editor.

Definition at line 625 of file music_editor.cc.

Referenced by Cut().

◆ Paste()

absl::Status yaze::editor::MusicEditor::Paste ( )
overridevirtual
Todo
Paste from clipboard

Implements yaze::editor::Editor.

Definition at line 631 of file music_editor.cc.

◆ Undo()

absl::Status yaze::editor::MusicEditor::Undo ( )
overridevirtual

◆ Redo()

absl::Status yaze::editor::MusicEditor::Redo ( )
overridevirtual

◆ Find()

absl::Status yaze::editor::MusicEditor::Find ( )
inlineoverridevirtual

Implements yaze::editor::Editor.

Definition at line 104 of file music_editor.h.

◆ set_rom()

void yaze::editor::MusicEditor::set_rom ( Rom * rom)
inline

Definition at line 107 of file music_editor.h.

References rom(), and rom_.

Here is the call graph for this function:

◆ rom()

Rom * yaze::editor::MusicEditor::rom ( ) const
inline

Definition at line 110 of file music_editor.h.

References rom_.

Referenced by set_rom().

◆ set_emulator()

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().

Here is the call graph for this function:

◆ emulator()

emu::Emulator * yaze::editor::MusicEditor::emulator ( ) const
inline

Definition at line 114 of file music_editor.h.

References emulator_.

Referenced by set_emulator().

◆ SetProject()

◆ TogglePlayPause()

void yaze::editor::MusicEditor::TogglePlayPause ( )

Definition at line 276 of file music_editor.cc.

References music_player_.

Referenced by DrawSongTrackerWindow().

◆ StopPlayback()

void yaze::editor::MusicEditor::StopPlayback ( )

Definition at line 288 of file music_editor.cc.

References music_player_.

Referenced by DrawSongTrackerWindow().

◆ SpeedUp()

void yaze::editor::MusicEditor::SpeedUp ( float delta = 0.1f)

Definition at line 294 of file music_editor.cc.

References music_player_.

Referenced by DrawSongTrackerWindow().

◆ SlowDown()

void yaze::editor::MusicEditor::SlowDown ( float delta = 0.1f)

Definition at line 301 of file music_editor.cc.

References music_player_.

Referenced by DrawSongTrackerWindow().

◆ OpenSong()

◆ FocusSong()

void yaze::editor::MusicEditor::FocusSong ( int song_index)

Definition at line 750 of file music_editor.cc.

References song_cards_.

Referenced by OpenSong().

◆ DrawSongTrackerWindow()

◆ DrawPlaybackControl()

◆ DrawTrackerView()

void yaze::editor::MusicEditor::DrawTrackerView ( )
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_.

Here is the call graph for this function:

◆ DrawPianoRollView()

◆ DrawInstrumentEditor()

void yaze::editor::MusicEditor::DrawInstrumentEditor ( )
private

Definition at line 1093 of file music_editor.cc.

References yaze::editor::music::InstrumentEditorView::Draw(), instrument_editor_view_, and music_bank_.

Here is the call graph for this function:

◆ DrawSampleEditor()

void yaze::editor::MusicEditor::DrawSampleEditor ( )
private

Definition at line 1097 of file music_editor.cc.

References yaze::editor::music::SampleEditorView::Draw(), music_bank_, and sample_editor_view_.

Here is the call graph for this function:

◆ DrawSongBrowser()

void yaze::editor::MusicEditor::DrawSongBrowser ( )
private

◆ DrawToolset()

◆ DrawChannelOverview()

void yaze::editor::MusicEditor::DrawChannelOverview ( )
private

Definition at line 1350 of file music_editor.cc.

References music_player_.

Referenced by DrawPlaybackControl(), and DrawSongTrackerWindow().

◆ RestoreMusicState()

absl::StatusOr< bool > yaze::editor::MusicEditor::RestoreMusicState ( )
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().

Here is the call graph for this function:

◆ PersistMusicState()

absl::Status yaze::editor::MusicEditor::PersistMusicState ( const char * reason = nullptr)
private

◆ MarkMusicDirty()

void yaze::editor::MusicEditor::MarkMusicDirty ( )
private

Definition at line 615 of file music_editor.cc.

References music_dirty_.

Referenced by PushUndoState(), and RestoreState().

◆ PushUndoState()

void yaze::editor::MusicEditor::PushUndoState ( )
private

◆ RestoreState()

void yaze::editor::MusicEditor::RestoreState ( const UndoState & state)
private

◆ current_channel()

int yaze::editor::MusicEditor::current_channel ( ) const
inlineprivate

Definition at line 182 of file music_editor.h.

References current_channel_index_.

◆ set_current_channel()

void yaze::editor::MusicEditor::set_current_channel ( int channel)
inlineprivate

Definition at line 183 of file music_editor.h.

References current_channel_index_.

◆ OpenSongPianoRoll()

◆ ExportSongToAsm()

◆ ImportSongFromAsm()

void yaze::editor::MusicEditor::ImportSongFromAsm ( int song_index)
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_.

Here is the call graph for this function:

◆ ImportAsmBufferToSong()

◆ DrawAsmPopups()

void yaze::editor::MusicEditor::DrawAsmPopups ( )
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().

Here is the call graph for this function:

◆ SeekToSegment()

void yaze::editor::MusicEditor::SeekToSegment ( int segment_index)
private

Definition at line 1425 of file music_editor.cc.

References music_player_.

Member Data Documentation

◆ assembly_editor_

AssemblyEditor yaze::editor::MusicEditor::assembly_editor_
private

Definition at line 149 of file music_editor.h.

Referenced by Initialize().

◆ music_bank_

◆ tracker_view_

editor::music::TrackerView yaze::editor::MusicEditor::tracker_view_
private

Definition at line 153 of file music_editor.h.

Referenced by DrawSongTrackerWindow(), and DrawTrackerView().

◆ piano_roll_view_

editor::music::PianoRollView yaze::editor::MusicEditor::piano_roll_view_
private

Definition at line 154 of file music_editor.h.

Referenced by DrawPianoRollView(), and Initialize().

◆ instrument_editor_view_

editor::music::InstrumentEditorView yaze::editor::MusicEditor::instrument_editor_view_
private

Definition at line 155 of file music_editor.h.

Referenced by DrawInstrumentEditor(), and Initialize().

◆ sample_editor_view_

editor::music::SampleEditorView yaze::editor::MusicEditor::sample_editor_view_
private

Definition at line 156 of file music_editor.h.

Referenced by DrawSampleEditor(), and Initialize().

◆ song_browser_view_

editor::music::SongBrowserView yaze::editor::MusicEditor::song_browser_view_
private

Definition at line 157 of file music_editor.h.

Referenced by DrawSongBrowser(), and Initialize().

◆ undo_stack_

std::vector<UndoState> yaze::editor::MusicEditor::undo_stack_
private

Definition at line 164 of file music_editor.h.

Referenced by PushUndoState(), Redo(), and Undo().

◆ redo_stack_

std::vector<UndoState> yaze::editor::MusicEditor::redo_stack_
private

Definition at line 165 of file music_editor.h.

Referenced by PushUndoState(), Redo(), and Undo().

◆ current_song_index_

int yaze::editor::MusicEditor::current_song_index_ = 0
private

◆ current_pattern_index_

int yaze::editor::MusicEditor::current_pattern_index_ = 0
private

Definition at line 174 of file music_editor.h.

◆ current_channel_index_

int yaze::editor::MusicEditor::current_channel_index_ = 0
private

◆ current_segment_index_

int yaze::editor::MusicEditor::current_segment_index_ = 0
private

Definition at line 176 of file music_editor.h.

Referenced by DrawPianoRollView(), Initialize(), and OpenSong().

◆ channel_muted_

std::vector<bool> yaze::editor::MusicEditor::channel_muted_ = std::vector<bool>(8, false)
private

Definition at line 177 of file music_editor.h.

◆ channel_soloed_

std::vector<bool> yaze::editor::MusicEditor::channel_soloed_ = std::vector<bool>(8, false)
private

Definition at line 178 of file music_editor.h.

Referenced by DrawToolset().

◆ song_names_

std::vector<std::string> yaze::editor::MusicEditor::song_names_
private

Definition at line 179 of file music_editor.h.

Referenced by DrawToolset().

◆ music_editor_flags_

ImGuiTableFlags yaze::editor::MusicEditor::music_editor_flags_
private
Initial value:
=
ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter |
ImGuiTableFlags_BordersV | ImGuiTableFlags_SizingFixedFit

Definition at line 187 of file music_editor.h.

◆ toolset_table_flags_

ImGuiTableFlags yaze::editor::MusicEditor::toolset_table_flags_
private
Initial value:
=
ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_BordersOuter |
ImGuiTableFlags_BordersV | ImGuiTableFlags_PadOuterX

Definition at line 191 of file music_editor.h.

◆ rom_

Rom* yaze::editor::MusicEditor::rom_
private

Definition at line 195 of file music_editor.h.

Referenced by DrawToolset(), Initialize(), Load(), rom(), Save(), and set_rom().

◆ emulator_

emu::Emulator* yaze::editor::MusicEditor::emulator_ = nullptr
private

Definition at line 196 of file music_editor.h.

Referenced by emulator(), Initialize(), and set_emulator().

◆ project_

project::YazeProject* yaze::editor::MusicEditor::project_ = nullptr
private

Definition at line 197 of file music_editor.h.

Referenced by Load(), PersistMusicState(), and SetProject().

◆ audio_backend_

std::unique_ptr<emu::audio::IAudioBackend> yaze::editor::MusicEditor::audio_backend_
private

Definition at line 201 of file music_editor.h.

Referenced by Initialize(), and set_emulator().

◆ song_browser_auto_shown_

bool yaze::editor::MusicEditor::song_browser_auto_shown_ = false
private

Definition at line 202 of file music_editor.h.

Referenced by Update().

◆ tracker_auto_shown_

bool yaze::editor::MusicEditor::tracker_auto_shown_ = false
private

Definition at line 203 of file music_editor.h.

Referenced by Update().

◆ music_dirty_

bool yaze::editor::MusicEditor::music_dirty_ = false
private

Definition at line 204 of file music_editor.h.

Referenced by MarkMusicDirty(), PersistMusicState(), RestoreMusicState(), and Update().

◆ persist_custom_music_

bool yaze::editor::MusicEditor::persist_custom_music_ = true
private

Definition at line 205 of file music_editor.h.

Referenced by Load(), PersistMusicState(), SetProject(), and Update().

◆ music_storage_key_

std::string yaze::editor::MusicEditor::music_storage_key_
private

Definition at line 206 of file music_editor.h.

Referenced by Load(), PersistMusicState(), RestoreMusicState(), SetProject(), and Update().

◆ last_music_persist_

std::chrono::steady_clock::time_point yaze::editor::MusicEditor::last_music_persist_
private

Definition at line 207 of file music_editor.h.

Referenced by PersistMusicState(), RestoreMusicState(), and Update().

◆ active_songs_

ImVector<int> yaze::editor::MusicEditor::active_songs_
private

Definition at line 210 of file music_editor.h.

Referenced by OpenSong(), and Update().

◆ song_cards_

std::unordered_map<int, std::shared_ptr<gui::PanelWindow> > yaze::editor::MusicEditor::song_cards_
private

Definition at line 211 of file music_editor.h.

Referenced by FocusSong(), and Update().

◆ song_trackers_

std::unordered_map<int, std::unique_ptr<editor::music::TrackerView> > yaze::editor::MusicEditor::song_trackers_
private

Definition at line 213 of file music_editor.h.

Referenced by DrawSongTrackerWindow(), and Update().

◆ song_piano_rolls_

std::unordered_map<int, SongPianoRollWindow> yaze::editor::MusicEditor::song_piano_rolls_
private

Definition at line 219 of file music_editor.h.

Referenced by OpenSongPianoRoll(), and Update().

◆ song_window_class_

ImGuiWindowClass yaze::editor::MusicEditor::song_window_class_
private

Definition at line 222 of file music_editor.h.

Referenced by Initialize(), and Update().

◆ asm_buffer_

std::string yaze::editor::MusicEditor::asm_buffer_
private

◆ show_asm_export_popup_

bool yaze::editor::MusicEditor::show_asm_export_popup_ = false
private

Definition at line 233 of file music_editor.h.

Referenced by DrawAsmPopups(), and ExportSongToAsm().

◆ show_asm_import_popup_

bool yaze::editor::MusicEditor::show_asm_import_popup_ = false
private

Definition at line 234 of file music_editor.h.

Referenced by DrawAsmPopups(), and ImportSongFromAsm().

◆ asm_import_target_index_

int yaze::editor::MusicEditor::asm_import_target_index_ = -1
private

Definition at line 235 of file music_editor.h.

Referenced by DrawAsmPopups(), and ImportSongFromAsm().

◆ asm_import_error_

std::string yaze::editor::MusicEditor::asm_import_error_
private

Definition at line 236 of file music_editor.h.

Referenced by DrawAsmPopups(), ImportAsmBufferToSong(), and ImportSongFromAsm().

◆ music_player_


The documentation for this class was generated from the following files: