mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 13:05:11 +00:00
finish work on ADSR/LFO macro type
This commit is contained in:
parent
3ffe257158
commit
66234df636
3 changed files with 44 additions and 3 deletions
|
@ -182,6 +182,8 @@ struct DivInstrumentMacro {
|
||||||
|
|
||||||
// the following variables are used by the GUI and not saved in the file
|
// the following variables are used by the GUI and not saved in the file
|
||||||
int vScroll, vZoom;
|
int vScroll, vZoom;
|
||||||
|
int typeMemory[16];
|
||||||
|
unsigned char lenMemory;
|
||||||
|
|
||||||
explicit DivInstrumentMacro(const String& n, bool initOpen=false):
|
explicit DivInstrumentMacro(const String& n, bool initOpen=false):
|
||||||
name(n),
|
name(n),
|
||||||
|
@ -193,8 +195,10 @@ struct DivInstrumentMacro {
|
||||||
loop(255),
|
loop(255),
|
||||||
rel(255),
|
rel(255),
|
||||||
vScroll(0),
|
vScroll(0),
|
||||||
vZoom(-1) {
|
vZoom(-1),
|
||||||
|
lenMemory(0) {
|
||||||
memset(val,0,256*sizeof(int));
|
memset(val,0,256*sizeof(int));
|
||||||
|
memset(typeMemory,0,16*sizeof(int));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -332,7 +332,14 @@ void DivMacroInt::init(DivInstrument* which) {
|
||||||
for (size_t i=0; i<macroListLen; i++) {
|
for (size_t i=0; i<macroListLen; i++) {
|
||||||
if (macroSource[i]!=NULL) {
|
if (macroSource[i]!=NULL) {
|
||||||
macroList[i]->prepare(*macroSource[i],e);
|
macroList[i]->prepare(*macroSource[i],e);
|
||||||
hasRelease=(macroSource[i]->rel<macroSource[i]->len);
|
// check ADSR mode
|
||||||
|
if ((macroSource[i]->open&6)==4) {
|
||||||
|
hasRelease=false;
|
||||||
|
} else if ((macroSource[i]->open&6)==2) {
|
||||||
|
hasRelease=true;
|
||||||
|
} else {
|
||||||
|
hasRelease=(macroSource[i]->rel<macroSource[i]->len);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
hasRelease=false;
|
hasRelease=false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,6 +210,10 @@ const char* macroTypeLabels[4]={
|
||||||
ICON_FA_SIGN_OUT "##IMacroType"
|
ICON_FA_SIGN_OUT "##IMacroType"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char* macroLFOShapes[4]={
|
||||||
|
"Triangle", "Saw", "Square", "How did you even"
|
||||||
|
};
|
||||||
|
|
||||||
const char* fmOperatorBits[5]={
|
const char* fmOperatorBits[5]={
|
||||||
"op1", "op2", "op3", "op4", NULL
|
"op1", "op2", "op3", "op4", NULL
|
||||||
};
|
};
|
||||||
|
@ -1347,10 +1351,33 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ImGui::Button(macroTypeLabels[(i.macro->open>>1)&3])) {
|
if (ImGui::Button(macroTypeLabels[(i.macro->open>>1)&3])) {
|
||||||
|
unsigned char prevOpen=i.macro->open;
|
||||||
i.macro->open+=2;
|
i.macro->open+=2;
|
||||||
if (i.macro->open>=6) {
|
if (i.macro->open>=6) {
|
||||||
i.macro->open-=6;
|
i.macro->open-=6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check whether macro type is now ADSR/LFO or sequence
|
||||||
|
if (((prevOpen&6)?1:0)!=((i.macro->open&6)?1:0)) {
|
||||||
|
// swap memory
|
||||||
|
// this way the macro isn't corrupted if the user decides to go
|
||||||
|
// back to sequence mode
|
||||||
|
i.macro->len^=i.macro->lenMemory;
|
||||||
|
i.macro->lenMemory^=i.macro->len;
|
||||||
|
i.macro->len^=i.macro->lenMemory;
|
||||||
|
|
||||||
|
for (int j=0; j<16; j++) {
|
||||||
|
i.macro->val[j]^=i.macro->typeMemory[j];
|
||||||
|
i.macro->typeMemory[j]^=i.macro->val[j];
|
||||||
|
i.macro->val[j]^=i.macro->typeMemory[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
// if ADSR/LFO, populate min/max
|
||||||
|
if (i.macro->open&6) {
|
||||||
|
i.macro->val[0]=i.min;
|
||||||
|
i.macro->val[1]=i.max;
|
||||||
|
}
|
||||||
|
}
|
||||||
PARAMETER;
|
PARAMETER;
|
||||||
}
|
}
|
||||||
if (ImGui::IsItemHovered()) {
|
if (ImGui::IsItemHovered()) {
|
||||||
|
@ -1369,6 +1396,9 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (i.macro->open&6) {
|
||||||
|
i.macro->len=16;
|
||||||
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Button(ICON_FA_ELLIPSIS_H "##IMacroSet");
|
ImGui::Button(ICON_FA_ELLIPSIS_H "##IMacroSet");
|
||||||
if (ImGui::IsItemHovered()) {
|
if (ImGui::IsItemHovered()) {
|
||||||
|
@ -1754,7 +1784,7 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros) {
|
||||||
ImGui::Text("Shape");
|
ImGui::Text("Shape");
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||||
if (CWSliderInt("##MLShape",&i.macro->val[12],0,2)) { PARAMETER
|
if (CWSliderInt("##MLShape",&i.macro->val[12],0,2,macroLFOShapes[i.macro->val[12]&3])) { PARAMETER
|
||||||
if (i.macro->val[12]<0) i.macro->val[12]=0;
|
if (i.macro->val[12]<0) i.macro->val[12]=0;
|
||||||
if (i.macro->val[12]>2) i.macro->val[12]=2;
|
if (i.macro->val[12]>2) i.macro->val[12]=2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue