1#ifndef YAZE_APP_EDITOR_MUSIC_MUSIC_PLAYER_H
2#define YAZE_APP_EDITOR_MUSIC_MUSIC_PLAYER_H
10#include "absl/status/status.h"
279 uint16_t tick)
const;
326 void UploadSongToAram(
const std::vector<uint8_t>& data, uint16_t aram_address);
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
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.
emu::Emulator * emulator()
ApuDebugStatus GetApuStatus() const
Get APU timing diagnostic status.
void Stop()
Stop playback completely.
void PreviewCustomSong(int song_index)
Preview a custom (modified) song from memory.
bool IsPlaying() const
Check if currently playing.
void InitializeDirectSpc()
void ReinitAudio()
Reinitialize the audio system.
float CalculateTicksPerSecond(uint8_t tempo) const
void SetPlaybackSpeed(float speed)
Set the playback speed (0.25x to 2.0x).
bool IsPaused() const
Check if currently paused.
uint32_t playback_start_tick_
std::function< void(bool)> audio_exclusivity_callback_
void ForceNewFrame()
Force a DSP NewFrame() call.
ChannelState GetChannelState(int channel_index) const
int GetSongIndexInBank(int song_id, uint8_t bank) const
uint8_t current_spc_bank_
void SetInterpolationType(int type)
Set the DSP interpolation type for audio quality.
void SetVolume(float volume)
Set the master volume (0.0 to 1.0).
uint8_t GetSongTempo(const zelda3::music::MusicSong &song) const
std::chrono::steady_clock::time_point playback_start_time_
bool preview_initialized_
void Update()
Call once per frame to update playback state.
int GetPlayingSongIndex() const
Get the index of the currently playing song, or -1 if none.
void UploadSoundBankFromRom(uint32_t rom_offset)
void PrepareAudioPlayback()
Prepare audio pipeline for playback.
bool EnsurePreviewReady()
void Pause()
Pause the current playback.
uint32_t GetCurrentPlaybackTick() const
AudioQueueStatus GetAudioQueueStatus() const
Get audio queue diagnostic status.
PlaybackMode GetMode() const
void InitializePreviewMode()
std::array< ChannelState, 8 > GetChannelStates() const
void TransitionTo(PlaybackMode new_mode)
void PlaySong(int song_index)
Start playing a song by index.
void UploadSongToAram(const std::vector< uint8_t > &data, uint16_t aram_address)
DspDebugStatus GetDspStatus() const
Get DSP buffer diagnostic status.
void SetDirectSpcMode(bool enabled)
Enable/disable direct SPC mode (bypasses game CPU).
void Resume()
Resume paused playback.
void SetAudioExclusivityCallback(std::function< void(bool)> callback)
Set a callback to be called when audio playback starts/stops.
bool IsAudioReady() const
Check if the audio system is ready for playback.
uint32_t GetBankRomOffset(uint8_t bank) const
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.
std::chrono::steady_clock::time_point last_frame_time_
void TogglePlayPause()
Toggle between play/pause states.
const zelda3::music::MusicInstrument * ResolveInstrumentForEvent(const zelda3::music::MusicSegment &segment, int channel_index, uint16_t tick) const
Resolve the instrument used at a specific tick in a track.
void SetEmulator(emu::Emulator *emulator)
Set the main emulator instance to use for playback.
PlaybackState GetState() const
zelda3::music::MusicBank * music_bank_
void ResetDspBuffer()
Reset the DSP sample buffer.
void PreviewSample(int sample_index)
Preview a raw BRR sample.
void PreviewInstrument(int instrument_index)
Preview an instrument at middle C.
emu::Emulator * emulator_
void SeekToSegment(int segment_index)
Seek to a specific segment in the current song.
void ClearAudioQueue()
Clear the audio queue (stops sound immediately).
int playback_segment_index_
void PlaySongDirect(int song_id)
MusicPlayer(zelda3::music::MusicBank *music_bank)
A class for emulating and debugging SNES games.
Manages the collection of songs, instruments, and samples from a ROM.
PlaybackMode
Playback mode for the music player.
APU timing diagnostic status for debug UI.
Audio queue diagnostic status for debug UI.
Represents the state of a single DSP channel for visualization.
DSP buffer diagnostic status for debug UI.
Represents the current playback state of the music player.
int current_segment_index
An instrument definition with ADSR envelope.
A segment containing 8 parallel tracks.
A complete song composed of segments.
A single event in a music track (note, command, or control).