GUI: better DPCM mapping, part 1
UI needs to be better it does not work yet
This commit is contained in:
parent
1dd46274d5
commit
e51ca07acb
|
@ -1400,10 +1400,25 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sampleMapWaitingInput) {
|
if (sampleMapWaitingInput) {
|
||||||
if (sampleMapColumn==1) {
|
switch (sampleMapColumn) {
|
||||||
// TODO: map?
|
case 0: {
|
||||||
if (ev.key.keysym.scancode==SDL_SCANCODE_DELETE) {
|
if (ev.key.keysym.scancode==SDL_SCANCODE_DELETE) {
|
||||||
alterSampleMap(true,-1);
|
alterSampleMap(0,-1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto it=valueKeys.find(ev.key.keysym.sym);
|
||||||
|
if (it!=valueKeys.cend()) {
|
||||||
|
int num=it->second;
|
||||||
|
if (num<10) {
|
||||||
|
alterSampleMap(0,num);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
if (ev.key.keysym.scancode==SDL_SCANCODE_DELETE) {
|
||||||
|
alterSampleMap(1,-1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto it=noteKeys.find(ev.key.keysym.scancode);
|
auto it=noteKeys.find(ev.key.keysym.scancode);
|
||||||
|
@ -1414,23 +1429,41 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
|
||||||
if (num<-60) num=-60; // C-(-5)
|
if (num<-60) num=-60; // C-(-5)
|
||||||
if (num>119) num=119; // B-9
|
if (num>119) num=119; // B-9
|
||||||
|
|
||||||
alterSampleMap(true,num);
|
alterSampleMap(1,num);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
// TODO: map?
|
}
|
||||||
|
case 2: {
|
||||||
if (ev.key.keysym.scancode==SDL_SCANCODE_DELETE) {
|
if (ev.key.keysym.scancode==SDL_SCANCODE_DELETE) {
|
||||||
alterSampleMap(false,-1);
|
alterSampleMap(2,-1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto it=valueKeys.find(ev.key.keysym.sym);
|
auto it=valueKeys.find(ev.key.keysym.sym);
|
||||||
if (it!=valueKeys.cend()) {
|
if (it!=valueKeys.cend()) {
|
||||||
int num=it->second;
|
int num=it->second;
|
||||||
if (num<10) {
|
if (num<10) {
|
||||||
alterSampleMap(false,num);
|
alterSampleMap(2,num);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: {
|
||||||
|
if (ev.key.keysym.scancode==SDL_SCANCODE_DELETE) {
|
||||||
|
alterSampleMap(3,-1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto it=valueKeys.find(ev.key.keysym.sym);
|
||||||
|
if (it!=valueKeys.cend()) {
|
||||||
|
int num=it->second;
|
||||||
|
if (num<16) {
|
||||||
|
alterSampleMap(3,num);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2258,7 +2258,7 @@ class FurnaceGUI {
|
||||||
|
|
||||||
void drawMacroEdit(FurnaceGUIMacroDesc& i, int totalFit, float availableWidth, int index);
|
void drawMacroEdit(FurnaceGUIMacroDesc& i, int totalFit, float availableWidth, int index);
|
||||||
void drawMacros(std::vector<FurnaceGUIMacroDesc>& macros, FurnaceGUIMacroEditState& state);
|
void drawMacros(std::vector<FurnaceGUIMacroDesc>& macros, FurnaceGUIMacroEditState& state);
|
||||||
void alterSampleMap(bool isNote, int val);
|
void alterSampleMap(int column, int val);
|
||||||
|
|
||||||
void insTabSample(DivInstrument* ins);
|
void insTabSample(DivInstrument* ins);
|
||||||
|
|
||||||
|
|
|
@ -2128,7 +2128,7 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros, FurnaceGUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FurnaceGUI::alterSampleMap(bool isNote, int val) {
|
void FurnaceGUI::alterSampleMap(int column, int val) {
|
||||||
if (curIns<0 || curIns>=(int)e->song.ins.size()) return;
|
if (curIns<0 || curIns>=(int)e->song.ins.size()) return;
|
||||||
DivInstrument* ins=e->song.ins[curIns];
|
DivInstrument* ins=e->song.ins[curIns];
|
||||||
int sampleMapMin=sampleMapSelStart;
|
int sampleMapMin=sampleMapSelStart;
|
||||||
|
@ -2142,9 +2142,9 @@ void FurnaceGUI::alterSampleMap(bool isNote, int val) {
|
||||||
for (int i=sampleMapMin; i<=sampleMapMax; i++) {
|
for (int i=sampleMapMin; i<=sampleMapMax; i++) {
|
||||||
if (i<0 || i>=120) continue;
|
if (i<0 || i>=120) continue;
|
||||||
|
|
||||||
if (sampleMapColumn==1 && isNote) {
|
if (sampleMapColumn==1 && column==1) {
|
||||||
ins->amiga.noteMap[i].freq=val;
|
ins->amiga.noteMap[i].freq=val;
|
||||||
} else if (sampleMapColumn==0 && !isNote) {
|
} else if (sampleMapColumn==0 && column==0) {
|
||||||
if (val<0) {
|
if (val<0) {
|
||||||
ins->amiga.noteMap[i].map=-1;
|
ins->amiga.noteMap[i].map=-1;
|
||||||
} else if (sampleMapDigit>0) {
|
} else if (sampleMapDigit>0) {
|
||||||
|
@ -2156,13 +2156,39 @@ void FurnaceGUI::alterSampleMap(bool isNote, int val) {
|
||||||
if (ins->amiga.noteMap[i].map>=(int)e->song.sample.size()) {
|
if (ins->amiga.noteMap[i].map>=(int)e->song.sample.size()) {
|
||||||
ins->amiga.noteMap[i].map=((int)e->song.sample.size())-1;
|
ins->amiga.noteMap[i].map=((int)e->song.sample.size())-1;
|
||||||
}
|
}
|
||||||
|
} else if (sampleMapColumn==2 && column==2) {
|
||||||
|
if (val<0) {
|
||||||
|
ins->amiga.noteMap[i].dpcmFreq=-1;
|
||||||
|
} else if (sampleMapDigit>0) {
|
||||||
|
ins->amiga.noteMap[i].dpcmFreq*=10;
|
||||||
|
ins->amiga.noteMap[i].dpcmFreq+=val;
|
||||||
|
} else {
|
||||||
|
ins->amiga.noteMap[i].dpcmFreq=val;
|
||||||
|
}
|
||||||
|
if (ins->amiga.noteMap[i].dpcmFreq>15) {
|
||||||
|
ins->amiga.noteMap[i].dpcmFreq%=10;
|
||||||
|
}
|
||||||
|
} else if (sampleMapColumn==3 && column==3) {
|
||||||
|
if (val<0) {
|
||||||
|
ins->amiga.noteMap[i].dpcmDelta=-1;
|
||||||
|
} else if (sampleMapDigit>0) {
|
||||||
|
if (ins->amiga.noteMap[i].dpcmDelta>7) {
|
||||||
|
|
||||||
|
ins->amiga.noteMap[i].dpcmDelta=val;
|
||||||
|
} else {
|
||||||
|
ins->amiga.noteMap[i].dpcmDelta<<=4;
|
||||||
|
ins->amiga.noteMap[i].dpcmDelta+=val;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ins->amiga.noteMap[i].dpcmDelta=val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool advance=false;
|
bool advance=false;
|
||||||
if (sampleMapColumn==1 && isNote) {
|
if (sampleMapColumn==1 && column==1) {
|
||||||
advance=true;
|
advance=true;
|
||||||
} else if (sampleMapColumn==0 && !isNote) {
|
} else if (sampleMapColumn==0 && column==0) {
|
||||||
int digits=1;
|
int digits=1;
|
||||||
if (e->song.sample.size()>=10) digits=2;
|
if (e->song.sample.size()>=10) digits=2;
|
||||||
if (e->song.sample.size()>=100) digits=3;
|
if (e->song.sample.size()>=100) digits=3;
|
||||||
|
@ -2170,6 +2196,16 @@ void FurnaceGUI::alterSampleMap(bool isNote, int val) {
|
||||||
sampleMapDigit=0;
|
sampleMapDigit=0;
|
||||||
advance=true;
|
advance=true;
|
||||||
}
|
}
|
||||||
|
} else if (sampleMapColumn==2 && column==2) {
|
||||||
|
if (++sampleMapDigit>=2) {
|
||||||
|
sampleMapDigit=0;
|
||||||
|
advance=true;
|
||||||
|
}
|
||||||
|
} else if (sampleMapColumn==3 && column==3) {
|
||||||
|
if (++sampleMapDigit>=2) {
|
||||||
|
sampleMapDigit=0;
|
||||||
|
advance=true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (advance && sampleMapMin==sampleMapMax) {
|
if (advance && sampleMapMin==sampleMapMax) {
|
||||||
|
@ -2449,11 +2485,16 @@ void FurnaceGUI::insTabSample(DivInstrument* ins) {
|
||||||
ImGui::PushFont(patFont);
|
ImGui::PushFont(patFont);
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
ImGui::SetNextItemWidth(ImGui::CalcTextSize("0000").x);
|
ImGui::SetNextItemWidth(ImGui::CalcTextSize("0000").x);
|
||||||
ImGui::Selectable(" TO ",(sampleMapWaitingInput && sampleMapColumn==1 && i>=sampleMapMin && i<=sampleMapMax));
|
if (sampleMap.dpcmFreq<0) {
|
||||||
|
sName=fmt::sprintf("--##SD1%d",i);
|
||||||
|
} else {
|
||||||
|
sName=fmt::sprintf("%2d##SD1%d",sampleMap.dpcmFreq,i);
|
||||||
|
}
|
||||||
|
ImGui::Selectable(sName.c_str(),(sampleMapWaitingInput && sampleMapColumn==2 && i>=sampleMapMin && i<=sampleMapMax));
|
||||||
|
|
||||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) {
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) {
|
||||||
sampleMapFocused=true;
|
sampleMapFocused=true;
|
||||||
sampleMapColumn=1;
|
sampleMapColumn=2;
|
||||||
sampleMapDigit=0;
|
sampleMapDigit=0;
|
||||||
sampleMapSelStart=i;
|
sampleMapSelStart=i;
|
||||||
sampleMapSelEnd=i;
|
sampleMapSelEnd=i;
|
||||||
|
@ -2473,7 +2514,7 @@ void FurnaceGUI::insTabSample(DivInstrument* ins) {
|
||||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
||||||
if (sampleMapSelStart==sampleMapSelEnd) {
|
if (sampleMapSelStart==sampleMapSelEnd) {
|
||||||
sampleMapFocused=true;
|
sampleMapFocused=true;
|
||||||
sampleMapColumn=1;
|
sampleMapColumn=2;
|
||||||
sampleMapDigit=0;
|
sampleMapDigit=0;
|
||||||
sampleMapSelStart=i;
|
sampleMapSelStart=i;
|
||||||
sampleMapSelEnd=i;
|
sampleMapSelEnd=i;
|
||||||
|
@ -2498,11 +2539,16 @@ void FurnaceGUI::insTabSample(DivInstrument* ins) {
|
||||||
ImGui::PushFont(patFont);
|
ImGui::PushFont(patFont);
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
ImGui::SetNextItemWidth(ImGui::CalcTextSize("0000").x);
|
ImGui::SetNextItemWidth(ImGui::CalcTextSize("0000").x);
|
||||||
ImGui::Selectable(" DO ",(sampleMapWaitingInput && sampleMapColumn==2 && i>=sampleMapMin && i<=sampleMapMax));
|
if (sampleMap.dpcmDelta<0) {
|
||||||
|
sName=fmt::sprintf("--##SD2%d",i);
|
||||||
|
} else {
|
||||||
|
sName=fmt::sprintf("%2X##SD2%d",sampleMap.dpcmDelta,i);
|
||||||
|
}
|
||||||
|
ImGui::Selectable(sName.c_str(),(sampleMapWaitingInput && sampleMapColumn==3 && i>=sampleMapMin && i<=sampleMapMax));
|
||||||
|
|
||||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) {
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) {
|
||||||
sampleMapFocused=true;
|
sampleMapFocused=true;
|
||||||
sampleMapColumn=2;
|
sampleMapColumn=3;
|
||||||
sampleMapDigit=0;
|
sampleMapDigit=0;
|
||||||
sampleMapSelStart=i;
|
sampleMapSelStart=i;
|
||||||
sampleMapSelEnd=i;
|
sampleMapSelEnd=i;
|
||||||
|
@ -2522,7 +2568,7 @@ void FurnaceGUI::insTabSample(DivInstrument* ins) {
|
||||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
||||||
if (sampleMapSelStart==sampleMapSelEnd) {
|
if (sampleMapSelStart==sampleMapSelEnd) {
|
||||||
sampleMapFocused=true;
|
sampleMapFocused=true;
|
||||||
sampleMapColumn=2;
|
sampleMapColumn=3;
|
||||||
sampleMapDigit=0;
|
sampleMapDigit=0;
|
||||||
sampleMapSelStart=i;
|
sampleMapSelStart=i;
|
||||||
sampleMapSelEnd=i;
|
sampleMapSelEnd=i;
|
||||||
|
|
|
@ -420,7 +420,7 @@ void FurnaceGUI::drawPiano() {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (sampleMapWaitingInput) {
|
if (sampleMapWaitingInput) {
|
||||||
alterSampleMap(true,note);
|
alterSampleMap(1,note);
|
||||||
} else {
|
} else {
|
||||||
e->synchronized([this,note]() {
|
e->synchronized([this,note]() {
|
||||||
e->autoNoteOn(-1,curIns,note);
|
e->autoNoteOn(-1,curIns,note);
|
||||||
|
|
Loading…
Reference in a new issue