mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-27 06:53:01 +00:00
GUI: prepare FM preview for the other OPs
This commit is contained in:
parent
80a9677b0e
commit
d74172680f
4 changed files with 99 additions and 24 deletions
|
@ -20,8 +20,12 @@
|
|||
#define _USE_MATH_DEFINES
|
||||
#include "gui.h"
|
||||
#include "../../extern/opn/ym3438.h"
|
||||
#include "../../extern/opm/opm.h"
|
||||
#include "../../extern/opl/opl3.h"
|
||||
#include "../../extern/Nuked-OPLL/opll.h"
|
||||
#include "../engine/platform/sound/ymfm/ymfm_opz.h"
|
||||
|
||||
#define FM_WRITE(addr,val) \
|
||||
#define OPN_WRITE(addr,val) \
|
||||
OPN2_Write((ym3438_t*)fmPreviewOPN,0,(addr)); \
|
||||
do { \
|
||||
OPN2_Clock((ym3438_t*)fmPreviewOPN,out); \
|
||||
|
@ -35,7 +39,7 @@ const unsigned char dtTableFMP[8]={
|
|||
7,6,5,0,1,2,3,4
|
||||
};
|
||||
|
||||
void FurnaceGUI::renderFMPreview(const DivInstrumentFM& params, int pos) {
|
||||
void FurnaceGUI::renderFMPreviewOPN(const DivInstrumentFM& params, int pos) {
|
||||
if (fmPreviewOPN==NULL) {
|
||||
fmPreviewOPN=new ym3438_t;
|
||||
}
|
||||
|
@ -57,19 +61,19 @@ void FurnaceGUI::renderFMPreview(const DivInstrumentFM& params, int pos) {
|
|||
for (int i=0; i<4; i++) {
|
||||
const DivInstrumentFM::Operator& op=params.op[i];
|
||||
unsigned short baseAddr=i*4;
|
||||
FM_WRITE(baseAddr+0x40,op.tl);
|
||||
FM_WRITE(baseAddr+0x30,(op.mult&15)|(dtTableFMP[op.dt&7]<<4));
|
||||
FM_WRITE(baseAddr+0x50,(op.ar&31)|(op.rs<<6));
|
||||
FM_WRITE(baseAddr+0x60,(op.dr&31)|(op.am<<7));
|
||||
FM_WRITE(baseAddr+0x70,op.d2r&31);
|
||||
FM_WRITE(baseAddr+0x80,(op.rr&15)|(op.sl<<4));
|
||||
FM_WRITE(baseAddr+0x90,op.ssgEnv&15);
|
||||
OPN_WRITE(baseAddr+0x40,op.tl);
|
||||
OPN_WRITE(baseAddr+0x30,(op.mult&15)|(dtTableFMP[op.dt&7]<<4));
|
||||
OPN_WRITE(baseAddr+0x50,(op.ar&31)|(op.rs<<6));
|
||||
OPN_WRITE(baseAddr+0x60,(op.dr&31)|(op.am<<7));
|
||||
OPN_WRITE(baseAddr+0x70,op.d2r&31);
|
||||
OPN_WRITE(baseAddr+0x80,(op.rr&15)|(op.sl<<4));
|
||||
OPN_WRITE(baseAddr+0x90,op.ssgEnv&15);
|
||||
}
|
||||
FM_WRITE(0xb0,(params.alg&7)|((params.fb&7)<<3));
|
||||
FM_WRITE(0xb4,0xc0|(params.fms&7)|((params.ams&3)<<4));
|
||||
FM_WRITE(0xa4,mult0?0x1c:0x14); // frequency
|
||||
FM_WRITE(0xa0,0);
|
||||
FM_WRITE(0x28,0xf0); // key on
|
||||
OPN_WRITE(0xb0,(params.alg&7)|((params.fb&7)<<3));
|
||||
OPN_WRITE(0xb4,0xc0|(params.fms&7)|((params.ams&3)<<4));
|
||||
OPN_WRITE(0xa4,mult0?0x1c:0x14); // frequency
|
||||
OPN_WRITE(0xa0,0);
|
||||
OPN_WRITE(0x28,0xf0); // key on
|
||||
}
|
||||
|
||||
// render
|
||||
|
@ -84,3 +88,37 @@ void FurnaceGUI::renderFMPreview(const DivInstrumentFM& params, int pos) {
|
|||
fmPreview[i]=aOut;
|
||||
}
|
||||
}
|
||||
|
||||
void FurnaceGUI::renderFMPreviewOPM(const DivInstrumentFM& params, int pos) {
|
||||
}
|
||||
|
||||
void FurnaceGUI::renderFMPreviewOPLL(const DivInstrumentFM& params, int pos) {
|
||||
}
|
||||
|
||||
void FurnaceGUI::renderFMPreviewOPL(const DivInstrumentFM& params, int pos) {
|
||||
}
|
||||
|
||||
void FurnaceGUI::renderFMPreviewOPZ(const DivInstrumentFM& params, int pos) {
|
||||
}
|
||||
|
||||
void FurnaceGUI::renderFMPreview(const DivInstrument* ins, int pos) {
|
||||
switch (ins->type) {
|
||||
case DIV_INS_FM:
|
||||
renderFMPreviewOPN(ins->fm,pos);
|
||||
break;
|
||||
case DIV_INS_OPM:
|
||||
renderFMPreviewOPM(ins->fm,pos);
|
||||
break;
|
||||
case DIV_INS_OPLL:
|
||||
renderFMPreviewOPLL(ins->fm,pos);
|
||||
break;
|
||||
case DIV_INS_OPL:
|
||||
renderFMPreviewOPL(ins->fm,pos);
|
||||
break;
|
||||
case DIV_INS_OPZ:
|
||||
renderFMPreviewOPZ(ins->fm,pos);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6872,6 +6872,10 @@ FurnaceGUI::FurnaceGUI():
|
|||
fmPreviewOn(false),
|
||||
fmPreviewPaused(false),
|
||||
fmPreviewOPN(NULL),
|
||||
fmPreviewOPM(NULL),
|
||||
fmPreviewOPL(NULL),
|
||||
fmPreviewOPLL(NULL),
|
||||
fmPreviewOPZ(NULL),
|
||||
editString(NULL),
|
||||
pendingRawSampleDepth(8),
|
||||
pendingRawSampleChannels(1),
|
||||
|
|
|
@ -1349,6 +1349,10 @@ class FurnaceGUI {
|
|||
short fmPreview[FM_PREVIEW_SIZE];
|
||||
bool updateFMPreview, fmPreviewOn, fmPreviewPaused;
|
||||
void* fmPreviewOPN;
|
||||
void* fmPreviewOPM;
|
||||
void* fmPreviewOPL;
|
||||
void* fmPreviewOPLL;
|
||||
void* fmPreviewOPZ;
|
||||
String* editString;
|
||||
|
||||
String pendingRawSample;
|
||||
|
@ -2137,7 +2141,12 @@ class FurnaceGUI {
|
|||
bool drawSysConf(int chan, DivSystem type, DivConfig& flags, bool modifyOnChange, bool fromMenu=false);
|
||||
void kvsConfig(DivInstrument* ins);
|
||||
void drawFMPreview(const ImVec2& size);
|
||||
void renderFMPreview(const DivInstrumentFM& params, int pos=0);
|
||||
void renderFMPreview(const DivInstrument* ins, int pos=0);
|
||||
void renderFMPreviewOPN(const DivInstrumentFM& params, int pos=0);
|
||||
void renderFMPreviewOPM(const DivInstrumentFM& params, int pos=0);
|
||||
void renderFMPreviewOPLL(const DivInstrumentFM& params, int pos=0);
|
||||
void renderFMPreviewOPL(const DivInstrumentFM& params, int pos=0);
|
||||
void renderFMPreviewOPZ(const DivInstrumentFM& params, int pos=0);
|
||||
|
||||
// these ones offer ctrl-wheel fine value changes.
|
||||
bool CWSliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format=NULL, ImGuiSliderFlags flags=0);
|
||||
|
|
|
@ -1284,7 +1284,7 @@ inline bool enBit30(const int val) {
|
|||
|
||||
|
||||
void FurnaceGUI::kvsConfig(DivInstrument* ins) {
|
||||
if (ins->type==DIV_INS_FM && fmPreviewOn) {
|
||||
if (fmPreviewOn) {
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip("left click to restart\nmiddle click to pause\nright click to see algorithm");
|
||||
}
|
||||
|
@ -1299,10 +1299,10 @@ void FurnaceGUI::kvsConfig(DivInstrument* ins) {
|
|||
ImGui::SetTooltip("left click to configure TL scaling\nright click to see FM preview");
|
||||
}
|
||||
}
|
||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Right) && ins->type==DIV_INS_FM) {
|
||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
||||
fmPreviewOn=!fmPreviewOn;
|
||||
}
|
||||
if (!fmPreviewOn || ins->type!=DIV_INS_FM) {
|
||||
if (!fmPreviewOn) {
|
||||
int opCount=4;
|
||||
if (ins->type==DIV_INS_OPLL) opCount=2;
|
||||
if (ins->type==DIV_INS_OPL) opCount=(ins->fm.ops==4)?4:2;
|
||||
|
@ -2289,7 +2289,7 @@ void FurnaceGUI::drawInsEdit() {
|
|||
} else {
|
||||
DivInstrument* ins=e->song.ins[curIns];
|
||||
if (updateFMPreview) {
|
||||
renderFMPreview(ins->fm);
|
||||
renderFMPreview(ins);
|
||||
updateFMPreview=false;
|
||||
}
|
||||
if (settings.insEditColorize) {
|
||||
|
@ -2477,10 +2477,10 @@ void FurnaceGUI::drawInsEdit() {
|
|||
P(CWSliderScalar(FM_NAME(FM_ALG),ImGuiDataType_U8,&ins->fm.alg,&_ZERO,&_SEVEN)); rightClickable
|
||||
P(CWSliderScalar(FM_NAME(FM_AMS),ImGuiDataType_U8,&ins->fm.ams,&_ZERO,&_THREE)); rightClickable
|
||||
ImGui::TableNextColumn();
|
||||
if (ins->type==DIV_INS_FM && fmPreviewOn) {
|
||||
if (fmPreviewOn) {
|
||||
drawFMPreview(ImVec2(ImGui::GetContentRegionAvail().x,48.0*dpiScale));
|
||||
if (!fmPreviewPaused) {
|
||||
renderFMPreview(ins->fm,1);
|
||||
renderFMPreview(ins,1);
|
||||
WAKE_UP;
|
||||
}
|
||||
} else {
|
||||
|
@ -2498,7 +2498,15 @@ void FurnaceGUI::drawInsEdit() {
|
|||
P(CWSliderScalar(FM_NAME(FM_AMS),ImGuiDataType_U8,&ins->fm.ams,&_ZERO,&_THREE)); rightClickable
|
||||
P(CWSliderScalar(FM_NAME(FM_AMS2),ImGuiDataType_U8,&ins->fm.ams2,&_ZERO,&_THREE)); rightClickable
|
||||
ImGui::TableNextColumn();
|
||||
drawAlgorithm(ins->fm.alg,FM_ALGS_4OP,ImVec2(ImGui::GetContentRegionAvail().x,48.0*dpiScale));
|
||||
if (fmPreviewOn) {
|
||||
drawFMPreview(ImVec2(ImGui::GetContentRegionAvail().x,48.0*dpiScale));
|
||||
if (!fmPreviewPaused) {
|
||||
renderFMPreview(ins,1);
|
||||
WAKE_UP;
|
||||
}
|
||||
} else {
|
||||
drawAlgorithm(ins->fm.alg,FM_ALGS_4OP,ImVec2(ImGui::GetContentRegionAvail().x,48.0*dpiScale));
|
||||
}
|
||||
kvsConfig(ins);
|
||||
|
||||
if (ImGui::Button("Request from TX81Z")) {
|
||||
|
@ -2532,7 +2540,15 @@ void FurnaceGUI::drawInsEdit() {
|
|||
}
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
drawAlgorithm(ins->fm.alg&algMax,fourOp?FM_ALGS_4OP_OPL:FM_ALGS_2OP_OPL,ImVec2(ImGui::GetContentRegionAvail().x,48.0*dpiScale));
|
||||
if (fmPreviewOn) {
|
||||
drawFMPreview(ImVec2(ImGui::GetContentRegionAvail().x,48.0*dpiScale));
|
||||
if (!fmPreviewPaused) {
|
||||
renderFMPreview(ins,1);
|
||||
WAKE_UP;
|
||||
}
|
||||
} else {
|
||||
drawAlgorithm(ins->fm.alg&algMax,fourOp?FM_ALGS_4OP_OPL:FM_ALGS_2OP_OPL,ImVec2(ImGui::GetContentRegionAvail().x,48.0*dpiScale));
|
||||
}
|
||||
kvsConfig(ins);
|
||||
break;
|
||||
}
|
||||
|
@ -2557,7 +2573,15 @@ void FurnaceGUI::drawInsEdit() {
|
|||
}
|
||||
ImGui::EndDisabled();
|
||||
ImGui::TableNextColumn();
|
||||
drawAlgorithm(0,FM_ALGS_2OP_OPL,ImVec2(ImGui::GetContentRegionAvail().x,24.0*dpiScale));
|
||||
if (fmPreviewOn) {
|
||||
drawFMPreview(ImVec2(ImGui::GetContentRegionAvail().x,24.0*dpiScale));
|
||||
if (!fmPreviewPaused) {
|
||||
renderFMPreview(ins,1);
|
||||
WAKE_UP;
|
||||
}
|
||||
} else {
|
||||
drawAlgorithm(0,FM_ALGS_2OP_OPL,ImVec2(ImGui::GetContentRegionAvail().x,24.0*dpiScale));
|
||||
}
|
||||
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||
|
||||
|
|
Loading…
Reference in a new issue