yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
music_piano_roll_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_MUSIC_PANELS_MUSIC_PIANO_ROLL_PANEL_H_
2#define YAZE_APP_EDITOR_MUSIC_PANELS_MUSIC_PIANO_ROLL_PANEL_H_
3
4#include <functional>
5#include <string>
6
10#include "app/gui/core/icons.h"
12
13namespace yaze {
14namespace editor {
15
23 public:
25 int* current_song_index, int* current_segment_index,
26 int* current_channel_index,
27 music::PianoRollView* piano_roll_view,
28 music::MusicPlayer* music_player)
29 : music_bank_(music_bank),
30 current_song_index_(current_song_index),
31 current_segment_index_(current_segment_index),
32 current_channel_index_(current_channel_index),
33 piano_roll_view_(piano_roll_view),
34 music_player_(music_player) {}
35
36 // ==========================================================================
37 // WindowContent Identity
38 // ==========================================================================
39
40 std::string GetId() const override { return "music.piano_roll"; }
41 std::string GetDisplayName() const override { return "Piano Roll"; }
42 std::string GetIcon() const override { return ICON_MD_PIANO; }
43 std::string GetEditorCategory() const override { return "Music"; }
44 int GetPriority() const override { return 15; }
45
46 // ==========================================================================
47 // Callback Setters
48 // ==========================================================================
49
50 void SetOnEditCallback(std::function<void()> callback) {
51 on_edit_ = callback;
54 }
55
56 // ==========================================================================
57 // WindowContent Drawing
58 // ==========================================================================
59
60 void Draw(bool* p_open) override {
62 ImGui::TextDisabled("Music bank not loaded");
63 return;
64 }
65
67 if (song &&
68 *current_segment_index_ >= static_cast<int>(song->segments.size())) {
70 }
71
74
75 // Set up note preview callback
77 [this, song_index = *current_song_index_](
78 const zelda3::music::TrackEvent& evt, int segment_idx,
79 int channel_idx) {
80 auto* target = music_bank_->GetSong(song_index);
81 if (!target || !music_player_)
82 return;
83 music_player_->PreviewNote(*target, evt, segment_idx, channel_idx);
84 });
85
87 [this, song_index = *current_song_index_](
88 const zelda3::music::MusicSong& /*unused*/, int segment_idx) {
89 auto* target = music_bank_->GetSong(song_index);
90 if (!target || !music_player_)
91 return;
92 music_player_->PreviewSegment(*target, segment_idx);
93 });
94
95 // Update playback state for cursor visualization
96 auto state =
98 piano_roll_view_->SetPlaybackState(state.is_playing, state.is_paused,
99 state.current_tick);
100
102
103 // Update indices from view state
106 }
107
108 private:
110 int* current_song_index_ = nullptr;
115 std::function<void()> on_edit_;
116};
117
118} // namespace editor
119} // namespace yaze
120
121#endif // YAZE_APP_EDITOR_MUSIC_PANELS_MUSIC_PIANO_ROLL_PANEL_H_
WindowContent wrapper for the piano roll view.
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
std::string GetEditorCategory() const override
Editor category this panel belongs to.
int GetPriority() const override
Get display priority for menu ordering.
MusicPianoRollPanel(zelda3::music::MusicBank *music_bank, int *current_song_index, int *current_segment_index, int *current_channel_index, music::PianoRollView *piano_roll_view, music::MusicPlayer *music_player)
std::string GetIcon() const override
Material Design icon for this panel.
void SetOnEditCallback(std::function< void()> callback)
void Draw(bool *p_open) override
Draw the panel content.
std::string GetId() const override
Unique identifier for this panel.
Base interface for all logical window content components.
Handles audio playback for the music editor using the SNES APU emulator.
void PreviewSegment(const zelda3::music::MusicSong &song, int segment_index)
Preview a specific segment of a song.
void PreviewNote(const zelda3::music::MusicSong &song, const zelda3::music::TrackEvent &event, int segment_index, int channel_index)
Preview a single note with the current instrument.
PlaybackState GetState() const
UI component for displaying and editing music tracks as a piano roll.
void SetPlaybackState(bool is_playing, bool is_paused, uint32_t current_tick)
void Draw(zelda3::music::MusicSong *song, const zelda3::music::MusicBank *bank=nullptr)
Draw the piano roll view for the given song.
void SetOnNotePreview(std::function< void(const zelda3::music::TrackEvent &, int, int)> callback)
Set callback for note preview.
void SetOnEditCallback(std::function< void()> callback)
Set callback for when edits occur.
void SetOnSegmentPreview(std::function< void(const zelda3::music::MusicSong &, int)> callback)
Set callback for segment preview.
Manages the collection of songs, instruments, and samples from a ROM.
Definition music_bank.h:27
MusicSong * GetSong(int index)
Get a song by index.
#define ICON_MD_PIANO
Definition icons.h:1462
Represents the current playback state of the music player.
A complete song composed of segments.
Definition song_data.h:334
A single event in a music track (note, command, or control).
Definition song_data.h:247