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 // EditorPanel 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;
53 }
54
55 // ==========================================================================
56 // EditorPanel Drawing
57 // ==========================================================================
58
59 void Draw(bool* p_open) override {
61 ImGui::TextDisabled("Music bank not loaded");
62 return;
63 }
64
66 if (song && *current_segment_index_ >=
67 static_cast<int>(song->segments.size())) {
69 }
70
73
74 // Set up note preview callback
76 [this, song_index = *current_song_index_](
77 const zelda3::music::TrackEvent& evt, int segment_idx,
78 int channel_idx) {
79 auto* target = music_bank_->GetSong(song_index);
80 if (!target || !music_player_) return;
81 music_player_->PreviewNote(*target, evt, segment_idx, channel_idx);
82 });
83
85 [this, song_index = *current_song_index_](
86 const zelda3::music::MusicSong& /*unused*/, int segment_idx) {
87 auto* target = music_bank_->GetSong(song_index);
88 if (!target || !music_player_) return;
89 music_player_->PreviewSegment(*target, segment_idx);
90 });
91
92 // Update playback state for cursor visualization
93 auto state =
95 piano_roll_view_->SetPlaybackState(state.is_playing, state.is_paused,
96 state.current_tick);
97
99
100 // Update indices from view state
103 }
104
105 private:
107 int* current_song_index_ = nullptr;
112 std::function<void()> on_edit_;
113};
114
115} // namespace editor
116} // namespace yaze
117
118#endif // YAZE_APP_EDITOR_MUSIC_PANELS_MUSIC_PIANO_ROLL_PANEL_H_
Base interface for all logical panel components.
EditorPanel 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.
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