reference player prototype
poor performance no playback sync yet
This commit is contained in:
parent
9bbfdc6f43
commit
f77aafb44d
13 changed files with 336 additions and 15 deletions
|
|
@ -357,6 +357,9 @@ void FurnaceGUI::doAction(int what) {
|
|||
case GUI_ACTION_WINDOW_USER_PRESETS:
|
||||
nextWindow=GUI_WINDOW_USER_PRESETS;
|
||||
break;
|
||||
case GUI_ACTION_WINDOW_REF_PLAYER:
|
||||
nextWindow=GUI_WINDOW_REF_PLAYER;
|
||||
break;
|
||||
|
||||
case GUI_ACTION_COLLAPSE_WINDOW:
|
||||
collapseWindow=true;
|
||||
|
|
@ -464,6 +467,10 @@ void FurnaceGUI::doAction(int what) {
|
|||
break;
|
||||
case GUI_WINDOW_USER_PRESETS:
|
||||
userPresetsOpen=false;
|
||||
break;
|
||||
case GUI_WINDOW_REF_PLAYER:
|
||||
refPlayerOpen=false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2311,6 +2311,17 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
|
|||
dpiScale
|
||||
);
|
||||
break;
|
||||
case GUI_FILE_MUSIC_OPEN:
|
||||
if (!dirExists(workingDirMusic)) workingDirMusic=getHomeDir();
|
||||
hasOpened=fileDialog->openLoad(
|
||||
_("Open Audio File"),
|
||||
audioLoadFormats,
|
||||
workingDirMusic,
|
||||
dpiScale,
|
||||
NULL,
|
||||
false
|
||||
);
|
||||
break;
|
||||
case GUI_FILE_TEST_OPEN:
|
||||
if (!dirExists(workingDirTest)) workingDirTest=getHomeDir();
|
||||
hasOpened=fileDialog->openLoad(
|
||||
|
|
@ -3841,6 +3852,7 @@ bool FurnaceGUI::loop() {
|
|||
DECLARE_METRIC(log)
|
||||
DECLARE_METRIC(effectList)
|
||||
DECLARE_METRIC(userPresets)
|
||||
DECLARE_METRIC(refPlayer)
|
||||
DECLARE_METRIC(popup)
|
||||
|
||||
#ifdef IS_MOBILE
|
||||
|
|
@ -4453,6 +4465,7 @@ bool FurnaceGUI::loop() {
|
|||
IMPORT_CLOSE(memoryOpen);
|
||||
IMPORT_CLOSE(csPlayerOpen);
|
||||
IMPORT_CLOSE(userPresetsOpen);
|
||||
IMPORT_CLOSE(refPlayerOpen);
|
||||
} else if (pendingLayoutImportStep==1) {
|
||||
// let the UI settle
|
||||
} else if (pendingLayoutImportStep==2) {
|
||||
|
|
@ -4821,6 +4834,7 @@ bool FurnaceGUI::loop() {
|
|||
if (ImGui::MenuItem(_("effect list"),BIND_FOR(GUI_ACTION_WINDOW_EFFECT_LIST),effectListOpen)) effectListOpen=!effectListOpen;
|
||||
if (ImGui::MenuItem(_("play/edit controls"),BIND_FOR(GUI_ACTION_WINDOW_EDIT_CONTROLS),editControlsOpen)) editControlsOpen=!editControlsOpen;
|
||||
if (ImGui::MenuItem(_("piano/input pad"),BIND_FOR(GUI_ACTION_WINDOW_PIANO),pianoOpen)) pianoOpen=!pianoOpen;
|
||||
if (ImGui::MenuItem(_("reference music player"),BIND_FOR(GUI_ACTION_WINDOW_REF_PLAYER),refPlayerOpen)) refPlayerOpen=!refPlayerOpen;
|
||||
if (spoilerOpen) if (ImGui::MenuItem(_("spoiler"),NULL,spoilerOpen)) spoilerOpen=!spoilerOpen;
|
||||
|
||||
ImGui::EndMenu();
|
||||
|
|
@ -5043,6 +5057,7 @@ bool FurnaceGUI::loop() {
|
|||
MEASURE(memory,drawMemory());
|
||||
MEASURE(effectList,drawEffectList());
|
||||
MEASURE(userPresets,drawUserPresets());
|
||||
MEASURE(refPlayer,drawRefPlayer());
|
||||
MEASURE(patManager,drawPatManager());
|
||||
|
||||
} else {
|
||||
|
|
@ -5088,6 +5103,7 @@ bool FurnaceGUI::loop() {
|
|||
MEASURE(log,drawLog());
|
||||
MEASURE(effectList,drawEffectList());
|
||||
MEASURE(userPresets,drawUserPresets());
|
||||
MEASURE(refPlayer,drawRefPlayer());
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -5239,6 +5255,9 @@ bool FurnaceGUI::loop() {
|
|||
case GUI_FILE_CMDSTREAM_OPEN:
|
||||
workingDirROM=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
||||
break;
|
||||
case GUI_FILE_MUSIC_OPEN:
|
||||
workingDirMusic=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
||||
break;
|
||||
case GUI_FILE_TEST_OPEN:
|
||||
case GUI_FILE_TEST_OPEN_MULTI:
|
||||
case GUI_FILE_TEST_SAVE:
|
||||
|
|
@ -5877,6 +5896,11 @@ bool FurnaceGUI::loop() {
|
|||
showError(fmt::sprintf(_("Error while loading file! (%s)"),lastError));
|
||||
}
|
||||
break;
|
||||
case GUI_FILE_MUSIC_OPEN:
|
||||
if (!e->getFilePlayer()->loadFile(copyOfName.c_str())) {
|
||||
showError(fmt::sprintf(_("Error while loading file!")));
|
||||
}
|
||||
break;
|
||||
case GUI_FILE_TEST_OPEN:
|
||||
showWarning(fmt::sprintf(_("You opened: %s"),copyOfName),GUI_WARN_GENERIC);
|
||||
break;
|
||||
|
|
@ -8170,11 +8194,13 @@ void FurnaceGUI::syncState() {
|
|||
workingDirAudioExport=e->getConfString("lastDirAudioExport",workingDir);
|
||||
workingDirVGMExport=e->getConfString("lastDirVGMExport",workingDir);
|
||||
workingDirROMExport=e->getConfString("lastDirROMExport",workingDir);
|
||||
workingDirROM=e->getConfString("lastDirROM",workingDir);
|
||||
workingDirFont=e->getConfString("lastDirFont",workingDir);
|
||||
workingDirColors=e->getConfString("lastDirColors",workingDir);
|
||||
workingDirKeybinds=e->getConfString("lastDirKeybinds",workingDir);
|
||||
workingDirLayout=e->getConfString("lastDirLayout",workingDir);
|
||||
workingDirConfig=e->getConfString("lastDirConfig",workingDir);
|
||||
workingDirMusic=e->getConfString("lastDirMusic",workingDir);
|
||||
workingDirTest=e->getConfString("lastDirTest",workingDir);
|
||||
|
||||
editControlsOpen=e->getConfBool("editControlsOpen",true);
|
||||
|
|
@ -8216,6 +8242,7 @@ void FurnaceGUI::syncState() {
|
|||
findOpen=e->getConfBool("findOpen",false);
|
||||
spoilerOpen=e->getConfBool("spoilerOpen",false);
|
||||
userPresetsOpen=e->getConfBool("userPresetsOpen",false);
|
||||
refPlayerOpen=e->getConfBool("refPlayerOpen",false);
|
||||
|
||||
insListDir=e->getConfBool("insListDir",false);
|
||||
waveListDir=e->getConfBool("waveListDir",false);
|
||||
|
|
@ -8333,11 +8360,13 @@ void FurnaceGUI::commitState(DivConfig& conf) {
|
|||
conf.set("lastDirAudioExport",workingDirAudioExport);
|
||||
conf.set("lastDirVGMExport",workingDirVGMExport);
|
||||
conf.set("lastDirROMExport",workingDirROMExport);
|
||||
conf.set("lastDirROM",workingDirROM);
|
||||
conf.set("lastDirFont",workingDirFont);
|
||||
conf.set("lastDirColors",workingDirColors);
|
||||
conf.set("lastDirKeybinds",workingDirKeybinds);
|
||||
conf.set("lastDirLayout",workingDirLayout);
|
||||
conf.set("lastDirConfig",workingDirConfig);
|
||||
conf.set("lastDirMusic",workingDirMusic);
|
||||
conf.set("lastDirTest",workingDirTest);
|
||||
|
||||
// commit last open windows
|
||||
|
|
@ -8376,6 +8405,7 @@ void FurnaceGUI::commitState(DivConfig& conf) {
|
|||
conf.set("findOpen",findOpen);
|
||||
conf.set("spoilerOpen",spoilerOpen);
|
||||
conf.set("userPresetsOpen",userPresetsOpen);
|
||||
conf.set("refPlayerOpen",refPlayerOpen);
|
||||
|
||||
// commit dir state
|
||||
conf.set("insListDir",insListDir);
|
||||
|
|
@ -8779,6 +8809,7 @@ FurnaceGUI::FurnaceGUI():
|
|||
csPlayerOpen(false),
|
||||
cvOpen(false),
|
||||
userPresetsOpen(false),
|
||||
refPlayerOpen(false),
|
||||
cvNotSerious(false),
|
||||
shortIntro(false),
|
||||
insListDir(false),
|
||||
|
|
|
|||
|
|
@ -567,6 +567,7 @@ enum FurnaceGUIWindows {
|
|||
GUI_WINDOW_MEMORY,
|
||||
GUI_WINDOW_CS_PLAYER,
|
||||
GUI_WINDOW_USER_PRESETS,
|
||||
GUI_WINDOW_REF_PLAYER,
|
||||
GUI_WINDOW_SPOILER
|
||||
};
|
||||
|
||||
|
|
@ -647,6 +648,7 @@ enum FurnaceGUIFileDialogs {
|
|||
GUI_FILE_TG100_ROM_OPEN,
|
||||
GUI_FILE_MU5_ROM_OPEN,
|
||||
GUI_FILE_CMDSTREAM_OPEN,
|
||||
GUI_FILE_MUSIC_OPEN,
|
||||
|
||||
GUI_FILE_TEST_OPEN,
|
||||
GUI_FILE_TEST_OPEN_MULTI,
|
||||
|
|
@ -771,6 +773,7 @@ enum FurnaceGUIActions {
|
|||
GUI_ACTION_WINDOW_MEMORY,
|
||||
GUI_ACTION_WINDOW_CS_PLAYER,
|
||||
GUI_ACTION_WINDOW_USER_PRESETS,
|
||||
GUI_ACTION_WINDOW_REF_PLAYER,
|
||||
|
||||
GUI_ACTION_COLLAPSE_WINDOW,
|
||||
GUI_ACTION_CLOSE_WINDOW,
|
||||
|
|
@ -1688,7 +1691,7 @@ class FurnaceGUI {
|
|||
String workingDirSong, workingDirIns, workingDirWave, workingDirSample, workingDirAudioExport;
|
||||
String workingDirVGMExport, workingDirROMExport;
|
||||
String workingDirFont, workingDirColors, workingDirKeybinds;
|
||||
String workingDirLayout, workingDirROM, workingDirTest;
|
||||
String workingDirLayout, workingDirROM, workingDirMusic, workingDirTest;
|
||||
String workingDirConfig;
|
||||
String mmlString[32];
|
||||
String mmlStringW, grooveString, grooveListString, mmlStringModTable;
|
||||
|
|
@ -2392,7 +2395,7 @@ class FurnaceGUI {
|
|||
bool mixerOpen, debugOpen, inspectorOpen, oscOpen, volMeterOpen, statsOpen, compatFlagsOpen;
|
||||
bool pianoOpen, notesOpen, channelsOpen, regViewOpen, logOpen, effectListOpen, chanOscOpen;
|
||||
bool subSongsOpen, findOpen, spoilerOpen, patManagerOpen, sysManagerOpen, clockOpen, speedOpen;
|
||||
bool groovesOpen, xyOscOpen, memoryOpen, csPlayerOpen, cvOpen, userPresetsOpen;
|
||||
bool groovesOpen, xyOscOpen, memoryOpen, csPlayerOpen, cvOpen, userPresetsOpen, refPlayerOpen;
|
||||
|
||||
bool cvNotSerious;
|
||||
|
||||
|
|
@ -2992,6 +2995,7 @@ class FurnaceGUI {
|
|||
void drawTutorial();
|
||||
void drawXYOsc();
|
||||
void drawUserPresets();
|
||||
void drawRefPlayer();
|
||||
|
||||
float drawSystemChannelInfo(const DivSysDef* whichDef, int keyHitOffset=-1, float width=-1.0f);
|
||||
void drawSystemChannelInfoText(const DivSysDef* whichDef);
|
||||
|
|
|
|||
|
|
@ -656,6 +656,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={
|
|||
D("WINDOW_MEMORY", _N("Memory Composition"), 0),
|
||||
D("WINDOW_CS_PLAYER", _N("Command Stream Player"), 0),
|
||||
D("WINDOW_USER_PRESETS", _N("User Presets"), 0),
|
||||
D("WINDOW_REF_PLAYER", _N("Reference Music Player"), 0),
|
||||
|
||||
D("COLLAPSE_WINDOW", _N("Collapse/expand current window"), 0),
|
||||
D("CLOSE_WINDOW", _N("Close current window"), FURKMOD_SHIFT|SDLK_ESCAPE),
|
||||
|
|
|
|||
|
|
@ -333,8 +333,21 @@ void FurnaceGUI::drawMixer() {
|
|||
}
|
||||
}
|
||||
|
||||
// metronome/sample preview
|
||||
// file player/metronome/sample preview
|
||||
if (displayInternalPorts) {
|
||||
if (portSet(_("Music Player"),0xffc,0,16,0,16,selectedSubPort,portPos)) {
|
||||
selectedPortSet=0xffc;
|
||||
if (selectedSubPort>=0) {
|
||||
portDragActive=true;
|
||||
ImGui::InhibitInertialScroll();
|
||||
auto subPortI=portPos.find((selectedPortSet<<4)|selectedSubPort);
|
||||
if (subPortI!=portPos.cend()) {
|
||||
subPortPos=subPortI->second;
|
||||
} else {
|
||||
portDragActive=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (portSet(_("Sample Preview"),0xffd,0,1,0,1,selectedSubPort,portPos)) {
|
||||
selectedPortSet=0xffd;
|
||||
if (selectedSubPort>=0) {
|
||||
|
|
|
|||
82
src/gui/refPlayer.cpp
Normal file
82
src/gui/refPlayer.cpp
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2025 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "gui.h"
|
||||
#include <fmt/printf.h>
|
||||
#include "imgui.h"
|
||||
#include "IconsFontAwesome4.h"
|
||||
|
||||
void FurnaceGUI::drawRefPlayer() {
|
||||
if (nextWindow==GUI_WINDOW_REF_PLAYER) {
|
||||
refPlayerOpen=true;
|
||||
ImGui::SetNextWindowFocus();
|
||||
nextWindow=GUI_WINDOW_NOTHING;
|
||||
}
|
||||
if (!refPlayerOpen) return;
|
||||
if (ImGui::Begin("Music Player",&refPlayerOpen,globalWinFlags,_("Music Player"))) {
|
||||
DivFilePlayer* fp=e->getFilePlayer();
|
||||
|
||||
size_t playPos=fp->getPos();
|
||||
size_t minPos=0;
|
||||
size_t maxPos=fp->getFileInfo().frames;
|
||||
int fileRate=fp->getFileInfo().samplerate;
|
||||
if (fileRate<1) fileRate=1;
|
||||
int posHours=(playPos/fileRate)/3600;
|
||||
int posMinutes=((playPos/fileRate)/60)%60;
|
||||
int posSeconds=(playPos/fileRate)%60;
|
||||
int posMillis=(1000*(playPos%fileRate))/fileRate;
|
||||
ImGui::Text("%d:%02d:%02d.%03d",posHours,posMinutes,posSeconds,posMillis);
|
||||
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||
if (ImGui::SliderScalar("##Position",ImGuiDataType_U64,&playPos,&minPos,&maxPos,"")) {
|
||||
fp->setPos(playPos);
|
||||
}
|
||||
|
||||
if (ImGui::Button("Open")) {
|
||||
openFileDialog(GUI_FILE_MUSIC_OPEN);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(ICON_FA_FAST_BACKWARD)) {
|
||||
fp->stop();
|
||||
fp->setPos(0);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (fp->isPlaying()) {
|
||||
pushToggleColors(true);
|
||||
if (ImGui::Button(ICON_FA_PAUSE "##Pause")) {
|
||||
fp->stop();
|
||||
}
|
||||
popToggleColors();
|
||||
} else {
|
||||
if (ImGui::Button(ICON_FA_PLAY "##Play")) {
|
||||
fp->play();
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
float vol=fp->getVolume();
|
||||
if (ImGui::SliderFloat("Volume",&vol,0.0f,1.0f)) {
|
||||
if (vol<0.0f) vol=0.0f;
|
||||
if (vol>1.0f) vol=1.0f;
|
||||
fp->setVolume(vol);
|
||||
}
|
||||
}
|
||||
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_REF_PLAYER;
|
||||
ImGui::End();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue