From 8a2bf3ae3945211e4d8f5c0f281ff8282e01dbf6 Mon Sep 17 00:00:00 2001 From: BlastBrothers Date: Fri, 8 Apr 2022 00:01:42 -0400 Subject: [PATCH 1/9] Thin sample editor --- src/gui/sampleEdit.cpp | 194 ++++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/src/gui/sampleEdit.cpp b/src/gui/sampleEdit.cpp index b976ab92f..cd9f76b7e 100644 --- a/src/gui/sampleEdit.cpp +++ b/src/gui/sampleEdit.cpp @@ -53,7 +53,7 @@ void FurnaceGUI::drawSampleEdit() { MARK_MODIFIED; } - if (ImGui::BeginTable("SampleProps",4,ImGuiTableFlags_SizingStretchSame)) { + if (ImGui::BeginTable("SampleProps",2,ImGuiTableFlags_SizingStretchSame)) { ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::Text("Type"); @@ -82,6 +82,7 @@ void FurnaceGUI::drawSampleEdit() { if (sample->rate>96000) sample->rate=96000; } + ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::Text("C-4 (Hz)"); ImGui::SameLine(); @@ -142,7 +143,7 @@ void FurnaceGUI::drawSampleEdit() { ImGui::SetTooltip("Edit mode: Draw"); } ImGui::SameLine(); - ImGui::Dummy(ImVec2(4.0*dpiScale,dpiScale)); + ImGui::Dummy(ImVec2(7.0*dpiScale,dpiScale)); ImGui::SameLine(); ImGui::Button(ICON_FA_ARROWS_H "##SResize"); if (ImGui::IsItemClicked()) { @@ -234,23 +235,7 @@ void FurnaceGUI::drawSampleEdit() { resampleTarget=sample->rate; } ImGui::SameLine(); - ImGui::Dummy(ImVec2(4.0*dpiScale,dpiScale)); - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_UNDO "##SUndo")) { - doUndoSample(); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Undo"); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_REPEAT "##SRedo")) { - doRedoSample(); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Redo"); - } - ImGui::SameLine(); - ImGui::Dummy(ImVec2(4.0*dpiScale,dpiScale)); + ImGui::Dummy(ImVec2(0.5*dpiScale,dpiScale)); ImGui::SameLine(); ImGui::Button(ICON_FA_VOLUME_UP "##SAmplify"); if (ImGui::IsItemHovered()) { @@ -321,80 +306,7 @@ void FurnaceGUI::drawSampleEdit() { ImGui::SetTooltip("Fade out"); } ImGui::SameLine(); - ImGui::Button(ICON_FA_ADJUST "##SInsertSilence"); - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Insert silence"); - } - if (openSampleSilenceOpt) { - openSampleSilenceOpt=false; - ImGui::OpenPopup("SSilenceOpt"); - } - if (ImGui::BeginPopupContextItem("SSilenceOpt",ImGuiPopupFlags_MouseButtonLeft)) { - if (ImGui::InputInt("Samples",&silenceSize,1,64)) { - if (silenceSize<0) silenceSize=0; - if (silenceSize>16777215) silenceSize=16777215; - } - if (ImGui::Button("Resize")) { - int pos=(sampleSelStart==-1 || sampleSelStart==sampleSelEnd)?sample->samples:sampleSelStart; - sample->prepareUndo(true); - e->lockEngine([this,sample,pos]() { - if (!sample->insert(pos,silenceSize)) { - showError("couldn't insert! make sure your sample is 8 or 16-bit."); - } - e->renderSamples(); - }); - updateSampleTex=true; - sampleSelStart=pos; - sampleSelEnd=pos+silenceSize; - MARK_MODIFIED; - ImGui::CloseCurrentPopup(); - } - ImGui::EndPopup(); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_ERASER "##SSilence")) { - doAction(GUI_ACTION_SAMPLE_SILENCE); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Apply silence"); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_TIMES "##SDelete")) { - doAction(GUI_ACTION_SAMPLE_DELETE); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Delete"); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_CROP "##STrim")) { - doAction(GUI_ACTION_SAMPLE_TRIM); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Trim"); - } - ImGui::SameLine(); - ImGui::Dummy(ImVec2(4.0*dpiScale,dpiScale)); - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_BACKWARD "##SReverse")) { - doAction(GUI_ACTION_SAMPLE_REVERSE); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Reverse"); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_SORT_AMOUNT_ASC "##SInvert")) { - doAction(GUI_ACTION_SAMPLE_INVERT); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Invert"); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_LEVEL_DOWN "##SSign")) { - doAction(GUI_ACTION_SAMPLE_SIGN); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Signed/unsigned exchange"); - } + ImGui::Dummy(ImVec2(0.5*dpiScale,dpiScale)); ImGui::SameLine(); ImGui::Button(ICON_FA_INDUSTRY "##SFilter"); if (ImGui::IsItemHovered()) { @@ -508,23 +420,111 @@ void FurnaceGUI::drawSampleEdit() { } ImGui::EndPopup(); } + + if (ImGui::Button(ICON_FA_UNDO "##SUndo")) { + doUndoSample(); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Undo"); + } ImGui::SameLine(); - ImGui::Dummy(ImVec2(4.0*dpiScale,dpiScale)); + if (ImGui::Button(ICON_FA_REPEAT "##SRedo")) { + doRedoSample(); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Redo"); + } ImGui::SameLine(); - if (ImGui::Button(ICON_FA_VOLUME_UP "##PreviewSample")) { + ImGui::Dummy(ImVec2(7.0*dpiScale,dpiScale)); + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_BACKWARD "##SReverse")) { + doAction(GUI_ACTION_SAMPLE_REVERSE); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Reverse"); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_SORT_AMOUNT_ASC "##SInvert")) { + doAction(GUI_ACTION_SAMPLE_INVERT); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Invert"); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_LEVEL_DOWN "##SSign")) { + doAction(GUI_ACTION_SAMPLE_SIGN); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Signed/unsigned exchange"); + } + ImGui::SameLine(); + ImGui::Dummy(ImVec2(7.0*dpiScale,dpiScale)); + ImGui::SameLine(); + ImGui::Button(ICON_FA_ADJUST "##SInsertSilence"); + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Insert silence"); + } + if (openSampleSilenceOpt) { + openSampleSilenceOpt=false; + ImGui::OpenPopup("SSilenceOpt"); + } + if (ImGui::BeginPopupContextItem("SSilenceOpt",ImGuiPopupFlags_MouseButtonLeft)) { + if (ImGui::InputInt("Samples",&silenceSize,1,64)) { + if (silenceSize<0) silenceSize=0; + if (silenceSize>16777215) silenceSize=16777215; + } + if (ImGui::Button("Resize")) { + int pos=(sampleSelStart==-1 || sampleSelStart==sampleSelEnd)?sample->samples:sampleSelStart; + sample->prepareUndo(true); + e->lockEngine([this,sample,pos]() { + if (!sample->insert(pos,silenceSize)) { + showError("couldn't insert! make sure your sample is 8 or 16-bit."); + } + e->renderSamples(); + }); + updateSampleTex=true; + sampleSelStart=pos; + sampleSelEnd=pos+silenceSize; + MARK_MODIFIED; + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_ERASER "##SSilence")) { + doAction(GUI_ACTION_SAMPLE_SILENCE); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Apply silence"); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_TIMES "##SDelete")) { + doAction(GUI_ACTION_SAMPLE_DELETE); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Delete"); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_CROP "##STrim")) { + doAction(GUI_ACTION_SAMPLE_TRIM); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Trim"); + } + + if (ImGui::Button(ICON_FA_PLAY "##PreviewSample")) { e->previewSample(curSample); } if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Preview sample"); } ImGui::SameLine(); - if (ImGui::Button(ICON_FA_VOLUME_OFF "##StopSample")) { + if (ImGui::Button(ICON_FA_STOP "##StopSample")) { e->stopSamplePreview(); } if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Stop sample preview"); } - ImGui::SameLine(); double zoomPercent=100.0/sampleZoom; ImGui::Text("Zoom"); From 1151db50912cb17491937e84459454fbb369576f Mon Sep 17 00:00:00 2001 From: BlastBrothers Date: Fri, 8 Apr 2022 10:23:51 -0400 Subject: [PATCH 2/9] Sample preview has maximum y height relative to x --- src/gui/sampleEdit.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gui/sampleEdit.cpp b/src/gui/sampleEdit.cpp index cd9f76b7e..f4c1e8bbc 100644 --- a/src/gui/sampleEdit.cpp +++ b/src/gui/sampleEdit.cpp @@ -554,8 +554,14 @@ void FurnaceGUI::drawSampleEdit() { ImGui::Separator(); - ImVec2 avail=ImGui::GetContentRegionAvail(); + ImVec2 avail=ImGui::GetContentRegionAvail(); // graph size determined here + if (ImGui::GetContentRegionAvail().y > (ImGui::GetContentRegionAvail().x / 2.0f)) { + avail=ImVec2(ImGui::GetContentRegionAvail().x,ImGui::GetContentRegionAvail().x / 2.0f); + } avail.y-=ImGui::GetFontSize()+ImGui::GetStyle().ItemSpacing.y+ImGui::GetStyle().ScrollbarSize; + if (avail.y < 1.0){ //Prevents crash + avail.y = 1.0; + } int availX=avail.x; int availY=avail.y; From 052a0923fee89c60787d438ca74d63abf693396b Mon Sep 17 00:00:00 2001 From: BlastBrothers Date: Fri, 8 Apr 2022 10:48:42 -0400 Subject: [PATCH 3/9] Rearrange buttons --- src/gui/sampleEdit.cpp | 148 +++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 72 deletions(-) diff --git a/src/gui/sampleEdit.cpp b/src/gui/sampleEdit.cpp index f4c1e8bbc..d83505dfc 100644 --- a/src/gui/sampleEdit.cpp +++ b/src/gui/sampleEdit.cpp @@ -237,77 +237,6 @@ void FurnaceGUI::drawSampleEdit() { ImGui::SameLine(); ImGui::Dummy(ImVec2(0.5*dpiScale,dpiScale)); ImGui::SameLine(); - ImGui::Button(ICON_FA_VOLUME_UP "##SAmplify"); - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Amplify"); - } - if (openSampleAmplifyOpt) { - openSampleAmplifyOpt=false; - ImGui::OpenPopup("SAmplifyOpt"); - } - if (ImGui::BeginPopupContextItem("SAmplifyOpt",ImGuiPopupFlags_MouseButtonLeft)) { - ImGui::Text("Volume"); - if (ImGui::InputFloat("##SRVolume",&lifyVol,10.0,50.0,"%g%%")) { - if (amplifyVol<0) amplifyVol=0; - if (amplifyVol>10000) amplifyVol=10000; - } - ImGui::SameLine(); - ImGui::Text("(%.1fdB)",20.0*log10(amplifyVol/100.0f)); - if (ImGui::Button("Apply")) { - sample->prepareUndo(true); - e->lockEngine([this,sample]() { - SAMPLE_OP_BEGIN; - float vol=amplifyVol/100.0f; - - if (sample->depth==16) { - for (unsigned int i=start; idata16[i]*vol; - if (val<-32768) val=-32768; - if (val>32767) val=32767; - sample->data16[i]=val; - } - } else if (sample->depth==8) { - for (unsigned int i=start; idata8[i]*vol; - if (val<-128) val=-128; - if (val>127) val=127; - sample->data8[i]=val; - } - } - - updateSampleTex=true; - - e->renderSamples(); - }); - MARK_MODIFIED; - ImGui::CloseCurrentPopup(); - } - ImGui::EndPopup(); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_ARROWS_V "##SNormalize")) { - doAction(GUI_ACTION_SAMPLE_NORMALIZE); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Normalize"); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_ARROW_UP "##SFadeIn")) { - doAction(GUI_ACTION_SAMPLE_FADE_IN); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Fade in"); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_ARROW_DOWN "##SFadeOut")) { - doAction(GUI_ACTION_SAMPLE_FADE_OUT); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Fade out"); - } - ImGui::SameLine(); - ImGui::Dummy(ImVec2(0.5*dpiScale,dpiScale)); - ImGui::SameLine(); ImGui::Button(ICON_FA_INDUSTRY "##SFilter"); if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Apply filter"); @@ -420,6 +349,79 @@ void FurnaceGUI::drawSampleEdit() { } ImGui::EndPopup(); } + ImGui::SameLine(); + ImGui::Dummy(ImVec2(0.5*dpiScale,dpiScale)); + ImGui::SameLine(); + + + ImGui::Button(ICON_FA_VOLUME_UP "##SAmplify"); + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Amplify"); + } + if (openSampleAmplifyOpt) { + openSampleAmplifyOpt=false; + ImGui::OpenPopup("SAmplifyOpt"); + } + if (ImGui::BeginPopupContextItem("SAmplifyOpt",ImGuiPopupFlags_MouseButtonLeft)) { + ImGui::Text("Volume"); + if (ImGui::InputFloat("##SRVolume",&lifyVol,10.0,50.0,"%g%%")) { + if (amplifyVol<0) amplifyVol=0; + if (amplifyVol>10000) amplifyVol=10000; + } + ImGui::SameLine(); + ImGui::Text("(%.1fdB)",20.0*log10(amplifyVol/100.0f)); + if (ImGui::Button("Apply")) { + sample->prepareUndo(true); + e->lockEngine([this,sample]() { + SAMPLE_OP_BEGIN; + float vol=amplifyVol/100.0f; + + if (sample->depth==16) { + for (unsigned int i=start; idata16[i]*vol; + if (val<-32768) val=-32768; + if (val>32767) val=32767; + sample->data16[i]=val; + } + } else if (sample->depth==8) { + for (unsigned int i=start; idata8[i]*vol; + if (val<-128) val=-128; + if (val>127) val=127; + sample->data8[i]=val; + } + } + + updateSampleTex=true; + + e->renderSamples(); + }); + MARK_MODIFIED; + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_ARROWS_V "##SNormalize")) { + doAction(GUI_ACTION_SAMPLE_NORMALIZE); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Normalize"); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_ARROW_UP "##SFadeIn")) { + doAction(GUI_ACTION_SAMPLE_FADE_IN); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Fade in"); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_ARROW_DOWN "##SFadeOut")) { + doAction(GUI_ACTION_SAMPLE_FADE_OUT); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Fade out"); + } if (ImGui::Button(ICON_FA_UNDO "##SUndo")) { doUndoSample(); @@ -451,6 +453,8 @@ void FurnaceGUI::drawSampleEdit() { ImGui::SetTooltip("Invert"); } ImGui::SameLine(); + ImGui::Dummy(ImVec2(0.5*dpiScale,dpiScale)); + ImGui::SameLine(); if (ImGui::Button(ICON_FA_LEVEL_DOWN "##SSign")) { doAction(GUI_ACTION_SAMPLE_SIGN); } @@ -458,7 +462,7 @@ void FurnaceGUI::drawSampleEdit() { ImGui::SetTooltip("Signed/unsigned exchange"); } ImGui::SameLine(); - ImGui::Dummy(ImVec2(7.0*dpiScale,dpiScale)); + ImGui::Dummy(ImVec2(0.5*dpiScale,dpiScale)); ImGui::SameLine(); ImGui::Button(ICON_FA_ADJUST "##SInsertSilence"); if (ImGui::IsItemHovered()) { From 0094e75bcf700e5bd283cc05fea909c79aec847a Mon Sep 17 00:00:00 2001 From: BlastBrothers Date: Mon, 11 Apr 2022 12:15:11 -0400 Subject: [PATCH 4/9] Pass sus to drawFMEnv- but is this the right var? --- src/gui/gui.h | 2 +- src/gui/insEdit.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/gui.h b/src/gui/gui.h index 7cc66c847..b3bf1af12 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1016,7 +1016,7 @@ class FurnaceGUI { void drawSSGEnv(unsigned char type, const ImVec2& size); void drawWaveform(unsigned char type, bool opz, const ImVec2& size); void drawAlgorithm(unsigned char alg, FurnaceGUIFMAlgs algType, const ImVec2& size); - void drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, unsigned char d2r, unsigned char rr, unsigned char sl, float maxTl, float maxArDr, const ImVec2& size); + void drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, unsigned char d2r, unsigned char rr, unsigned char sl, unsigned char sus, float maxTl, float maxArDr, const ImVec2& size); void drawSysConf(int i); // these ones offer ctrl-wheel fine value changes. diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 3e1416128..05df40ad6 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -901,7 +901,7 @@ void FurnaceGUI::drawAlgorithm(unsigned char alg, FurnaceGUIFMAlgs algType, cons } } -void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, unsigned char d2r, unsigned char rr, unsigned char sl, float maxTl, float maxArDr, const ImVec2& size) { +void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, unsigned char d2r, unsigned char rr, unsigned char sl, unsigned char sus, float maxTl, float maxArDr, const ImVec2& size) { ImDrawList* dl=ImGui::GetWindowDrawList(); ImGuiWindow* window=ImGui::GetCurrentWindow(); @@ -1806,7 +1806,7 @@ void FurnaceGUI::drawInsEdit() { } ImGui::TableNextColumn(); - drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,maxTl,maxArDr,ImVec2(ImGui::GetContentRegionAvail().x,sliderHeight)); + drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,ins->fm.op->sus,maxTl,maxArDr,ImVec2(ImGui::GetContentRegionAvail().x,sliderHeight)); ImGui::PopID(); } @@ -1889,7 +1889,7 @@ void FurnaceGUI::drawInsEdit() { } //52.0 controls vert scaling; default 96 - drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,maxTl,maxArDr,ImVec2(ImGui::GetContentRegionAvail().x,52.0*dpiScale)); + drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,ins->fm.op->sus,maxTl,maxArDr,ImVec2(ImGui::GetContentRegionAvail().x,52.0*dpiScale)); //P(CWSliderScalar(FM_NAME(FM_AR),ImGuiDataType_U8,&op.ar,&_ZERO,&_THIRTY_ONE)); rightClickable if (ImGui::BeginTable("opParams",2,ImGuiTableFlags_SizingStretchProp)) { ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,0.0); \ From 62ea4696008b4461aaa420c1215e2070534ec05f Mon Sep 17 00:00:00 2001 From: BlastBrothers Date: Mon, 11 Apr 2022 13:55:20 -0400 Subject: [PATCH 5/9] Works for OPLx --- src/gui/insEdit.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 05df40ad6..bb699522e 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -951,7 +951,7 @@ void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, //addAALine(dl,pos3,posSLineVEnd,colorS); //draw vert. line through sustain level addAALine(dl,pos1,pos2,color); //A addAALine(dl,pos2,posDecayRate0Pt,color); //Line from A to end of graph - } else if (d2r==0.0) { //if D2R = 0, the envelope stays at the sustain level forever + } else if (d2r==0.0 || sus==1.0) { //if D2R = 0, the envelope stays at the sustain level forever dl->AddTriangleFilled(posRStart,posREnd,pos1,colorS); //draw release as shaded triangle behind everything addAALine(dl,pos3,posSLineHEnd,colorS); //draw horiz line through sustain level addAALine(dl,pos3,posSLineVEnd,colorS); //draw vert. line through sustain level @@ -1806,7 +1806,7 @@ void FurnaceGUI::drawInsEdit() { } ImGui::TableNextColumn(); - drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,ins->fm.op->sus,maxTl,maxArDr,ImVec2(ImGui::GetContentRegionAvail().x,sliderHeight)); + drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,op.sus,maxTl,maxArDr,ImVec2(ImGui::GetContentRegionAvail().x,sliderHeight)); ImGui::PopID(); } @@ -1889,7 +1889,7 @@ void FurnaceGUI::drawInsEdit() { } //52.0 controls vert scaling; default 96 - drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,ins->fm.op->sus,maxTl,maxArDr,ImVec2(ImGui::GetContentRegionAvail().x,52.0*dpiScale)); + drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,op.sus,maxTl,maxArDr,ImVec2(ImGui::GetContentRegionAvail().x,52.0*dpiScale)); //P(CWSliderScalar(FM_NAME(FM_AR),ImGuiDataType_U8,&op.ar,&_ZERO,&_THIRTY_ONE)); rightClickable if (ImGui::BeginTable("opParams",2,ImGuiTableFlags_SizingStretchProp)) { ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,0.0); \ From 83baae92d9a9ba4371aa9a6a8ad0a777aff60562 Mon Sep 17 00:00:00 2001 From: BlastBrothers Date: Mon, 11 Apr 2022 17:26:40 -0400 Subject: [PATCH 6/9] Now it works ofr OPLL too, plus global sus --- src/gui/gui.h | 2 +- src/gui/insEdit.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gui/gui.h b/src/gui/gui.h index b3bf1af12..631d52a6d 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1016,7 +1016,7 @@ class FurnaceGUI { void drawSSGEnv(unsigned char type, const ImVec2& size); void drawWaveform(unsigned char type, bool opz, const ImVec2& size); void drawAlgorithm(unsigned char alg, FurnaceGUIFMAlgs algType, const ImVec2& size); - void drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, unsigned char d2r, unsigned char rr, unsigned char sl, unsigned char sus, float maxTl, float maxArDr, const ImVec2& size); + void drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, unsigned char d2r, unsigned char rr, unsigned char sl, unsigned char sus, unsigned char egt, unsigned char algOrGlobalSus, float maxTl, float maxArDr, const ImVec2& size, unsigned short instType); void drawSysConf(int i); // these ones offer ctrl-wheel fine value changes. diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index bb699522e..73ae54c46 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -901,7 +901,7 @@ void FurnaceGUI::drawAlgorithm(unsigned char alg, FurnaceGUIFMAlgs algType, cons } } -void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, unsigned char d2r, unsigned char rr, unsigned char sl, unsigned char sus, float maxTl, float maxArDr, const ImVec2& size) { +void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, unsigned char d2r, unsigned char rr, unsigned char sl, unsigned char sus, unsigned char egt, unsigned char algOrGlobalSus, float maxTl, float maxArDr, const ImVec2& size, unsigned short instType) { ImDrawList* dl=ImGui::GetWindowDrawList(); ImGuiWindow* window=ImGui::GetCurrentWindow(); @@ -918,6 +918,10 @@ void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, if (ImGui::ItemAdd(rect,ImGui::GetID("alg"))) { ImGui::RenderFrame(rect.Min,rect.Max,ImGui::GetColorU32(ImGuiCol_FrameBg),true,style.FrameRounding); + //Adjust for OPLL global sustain setting + if (instType==DIV_INS_OPLL && algOrGlobalSus==1.0){ + rr = 5.0; + } //calculate x positions float arPos=float(maxArDr-ar)/maxArDr; //peak of AR, start of DR float drPos=arPos+((sl/15.0)*(float(maxArDr-dr)/maxArDr)); //end of DR, start of D2R @@ -951,7 +955,7 @@ void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, //addAALine(dl,pos3,posSLineVEnd,colorS); //draw vert. line through sustain level addAALine(dl,pos1,pos2,color); //A addAALine(dl,pos2,posDecayRate0Pt,color); //Line from A to end of graph - } else if (d2r==0.0 || sus==1.0) { //if D2R = 0, the envelope stays at the sustain level forever + } else if (d2r==0.0 || (instType==DIV_INS_OPL && sus==1.0) || (instType==DIV_INS_OPLL && egt!=0.0)) { //envelope stays at the sustain level forever dl->AddTriangleFilled(posRStart,posREnd,pos1,colorS); //draw release as shaded triangle behind everything addAALine(dl,pos3,posSLineHEnd,colorS); //draw horiz line through sustain level addAALine(dl,pos3,posSLineVEnd,colorS); //draw vert. line through sustain level @@ -1806,7 +1810,7 @@ void FurnaceGUI::drawInsEdit() { } ImGui::TableNextColumn(); - drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,op.sus,maxTl,maxArDr,ImVec2(ImGui::GetContentRegionAvail().x,sliderHeight)); + drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,op.sus,op.ssgEnv&8,ins->fm.alg,maxTl,maxArDr,ImVec2(ImGui::GetContentRegionAvail().x,sliderHeight),ins->type); ImGui::PopID(); } @@ -1889,7 +1893,7 @@ void FurnaceGUI::drawInsEdit() { } //52.0 controls vert scaling; default 96 - drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,op.sus,maxTl,maxArDr,ImVec2(ImGui::GetContentRegionAvail().x,52.0*dpiScale)); + drawFMEnv(op.tl&maxTl,op.ar&maxArDr,op.dr&maxArDr,(ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL)?((op.rr&15)*2):op.d2r&31,op.rr&15,op.sl&15,op.sus,op.ssgEnv&8,ins->fm.alg,maxTl,maxArDr,ImVec2(ImGui::GetContentRegionAvail().x,52.0*dpiScale),ins->type); //P(CWSliderScalar(FM_NAME(FM_AR),ImGuiDataType_U8,&op.ar,&_ZERO,&_THIRTY_ONE)); rightClickable if (ImGui::BeginTable("opParams",2,ImGuiTableFlags_SizingStretchProp)) { ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,0.0); \ From af2b19ae622e7a5fff8fd4bd3640a17dc391a8dd Mon Sep 17 00:00:00 2001 From: BlastBrothers Date: Mon, 11 Apr 2022 20:15:03 -0400 Subject: [PATCH 7/9] Revert "Sample preview has maximum y height relative to x" This reverts commit 1151db50912cb17491937e84459454fbb369576f. --- src/gui/sampleEdit.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/gui/sampleEdit.cpp b/src/gui/sampleEdit.cpp index a4c744b19..bbd946819 100644 --- a/src/gui/sampleEdit.cpp +++ b/src/gui/sampleEdit.cpp @@ -564,14 +564,8 @@ void FurnaceGUI::drawSampleEdit() { ImGui::Separator(); - ImVec2 avail=ImGui::GetContentRegionAvail(); // graph size determined here - if (ImGui::GetContentRegionAvail().y > (ImGui::GetContentRegionAvail().x / 2.0f)) { - avail=ImVec2(ImGui::GetContentRegionAvail().x,ImGui::GetContentRegionAvail().x / 2.0f); - } + ImVec2 avail=ImGui::GetContentRegionAvail(); avail.y-=ImGui::GetFontSize()+ImGui::GetStyle().ItemSpacing.y+ImGui::GetStyle().ScrollbarSize; - if (avail.y < 1.0){ //Prevents crash - avail.y = 1.0; - } int availX=avail.x; int availY=avail.y; From 61715fd8b0be63aa9c4768a408e048d27b9acf27 Mon Sep 17 00:00:00 2001 From: BlastBrothers Date: Mon, 11 Apr 2022 20:15:46 -0400 Subject: [PATCH 8/9] Revert "Rearrange buttons" This reverts commit 052a0923fee89c60787d438ca74d63abf693396b. --- src/gui/sampleEdit.cpp | 148 ++++++++++++++++++++--------------------- 1 file changed, 72 insertions(+), 76 deletions(-) diff --git a/src/gui/sampleEdit.cpp b/src/gui/sampleEdit.cpp index bbd946819..4065e074a 100644 --- a/src/gui/sampleEdit.cpp +++ b/src/gui/sampleEdit.cpp @@ -243,6 +243,77 @@ void FurnaceGUI::drawSampleEdit() { ImGui::SameLine(); ImGui::Dummy(ImVec2(0.5*dpiScale,dpiScale)); ImGui::SameLine(); + ImGui::Button(ICON_FA_VOLUME_UP "##SAmplify"); + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Amplify"); + } + if (openSampleAmplifyOpt) { + openSampleAmplifyOpt=false; + ImGui::OpenPopup("SAmplifyOpt"); + } + if (ImGui::BeginPopupContextItem("SAmplifyOpt",ImGuiPopupFlags_MouseButtonLeft)) { + ImGui::Text("Volume"); + if (ImGui::InputFloat("##SRVolume",&lifyVol,10.0,50.0,"%g%%")) { + if (amplifyVol<0) amplifyVol=0; + if (amplifyVol>10000) amplifyVol=10000; + } + ImGui::SameLine(); + ImGui::Text("(%.1fdB)",20.0*log10(amplifyVol/100.0f)); + if (ImGui::Button("Apply")) { + sample->prepareUndo(true); + e->lockEngine([this,sample]() { + SAMPLE_OP_BEGIN; + float vol=amplifyVol/100.0f; + + if (sample->depth==16) { + for (unsigned int i=start; idata16[i]*vol; + if (val<-32768) val=-32768; + if (val>32767) val=32767; + sample->data16[i]=val; + } + } else if (sample->depth==8) { + for (unsigned int i=start; idata8[i]*vol; + if (val<-128) val=-128; + if (val>127) val=127; + sample->data8[i]=val; + } + } + + updateSampleTex=true; + + e->renderSamples(); + }); + MARK_MODIFIED; + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_ARROWS_V "##SNormalize")) { + doAction(GUI_ACTION_SAMPLE_NORMALIZE); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Normalize"); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_ARROW_UP "##SFadeIn")) { + doAction(GUI_ACTION_SAMPLE_FADE_IN); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Fade in"); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_ARROW_DOWN "##SFadeOut")) { + doAction(GUI_ACTION_SAMPLE_FADE_OUT); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Fade out"); + } + ImGui::SameLine(); + ImGui::Dummy(ImVec2(0.5*dpiScale,dpiScale)); + ImGui::SameLine(); ImGui::Button(ICON_FA_INDUSTRY "##SFilter"); if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Apply filter"); @@ -355,79 +426,6 @@ void FurnaceGUI::drawSampleEdit() { } ImGui::EndPopup(); } - ImGui::SameLine(); - ImGui::Dummy(ImVec2(0.5*dpiScale,dpiScale)); - ImGui::SameLine(); - - - ImGui::Button(ICON_FA_VOLUME_UP "##SAmplify"); - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Amplify"); - } - if (openSampleAmplifyOpt) { - openSampleAmplifyOpt=false; - ImGui::OpenPopup("SAmplifyOpt"); - } - if (ImGui::BeginPopupContextItem("SAmplifyOpt",ImGuiPopupFlags_MouseButtonLeft)) { - ImGui::Text("Volume"); - if (ImGui::InputFloat("##SRVolume",&lifyVol,10.0,50.0,"%g%%")) { - if (amplifyVol<0) amplifyVol=0; - if (amplifyVol>10000) amplifyVol=10000; - } - ImGui::SameLine(); - ImGui::Text("(%.1fdB)",20.0*log10(amplifyVol/100.0f)); - if (ImGui::Button("Apply")) { - sample->prepareUndo(true); - e->lockEngine([this,sample]() { - SAMPLE_OP_BEGIN; - float vol=amplifyVol/100.0f; - - if (sample->depth==16) { - for (unsigned int i=start; idata16[i]*vol; - if (val<-32768) val=-32768; - if (val>32767) val=32767; - sample->data16[i]=val; - } - } else if (sample->depth==8) { - for (unsigned int i=start; idata8[i]*vol; - if (val<-128) val=-128; - if (val>127) val=127; - sample->data8[i]=val; - } - } - - updateSampleTex=true; - - e->renderSamples(); - }); - MARK_MODIFIED; - ImGui::CloseCurrentPopup(); - } - ImGui::EndPopup(); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_ARROWS_V "##SNormalize")) { - doAction(GUI_ACTION_SAMPLE_NORMALIZE); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Normalize"); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_ARROW_UP "##SFadeIn")) { - doAction(GUI_ACTION_SAMPLE_FADE_IN); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Fade in"); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_ARROW_DOWN "##SFadeOut")) { - doAction(GUI_ACTION_SAMPLE_FADE_OUT); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Fade out"); - } if (ImGui::Button(ICON_FA_UNDO "##SUndo")) { doUndoSample(); @@ -459,8 +457,6 @@ void FurnaceGUI::drawSampleEdit() { ImGui::SetTooltip("Invert"); } ImGui::SameLine(); - ImGui::Dummy(ImVec2(0.5*dpiScale,dpiScale)); - ImGui::SameLine(); if (ImGui::Button(ICON_FA_LEVEL_DOWN "##SSign")) { doAction(GUI_ACTION_SAMPLE_SIGN); } @@ -468,7 +464,7 @@ void FurnaceGUI::drawSampleEdit() { ImGui::SetTooltip("Signed/unsigned exchange"); } ImGui::SameLine(); - ImGui::Dummy(ImVec2(0.5*dpiScale,dpiScale)); + ImGui::Dummy(ImVec2(7.0*dpiScale,dpiScale)); ImGui::SameLine(); ImGui::Button(ICON_FA_ADJUST "##SInsertSilence"); if (ImGui::IsItemHovered()) { From f6381771a9708ce1b6c5f1c162e40c44da03a504 Mon Sep 17 00:00:00 2001 From: BlastBrothers Date: Mon, 11 Apr 2022 20:16:51 -0400 Subject: [PATCH 9/9] Revert "Thin sample editor" This reverts commit 8a2bf3ae3945211e4d8f5c0f281ff8282e01dbf6. --- src/gui/sampleEdit.cpp | 194 ++++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/src/gui/sampleEdit.cpp b/src/gui/sampleEdit.cpp index 4065e074a..34cb23d5f 100644 --- a/src/gui/sampleEdit.cpp +++ b/src/gui/sampleEdit.cpp @@ -59,7 +59,7 @@ void FurnaceGUI::drawSampleEdit() { MARK_MODIFIED; } - if (ImGui::BeginTable("SampleProps",2,ImGuiTableFlags_SizingStretchSame)) { + if (ImGui::BeginTable("SampleProps",4,ImGuiTableFlags_SizingStretchSame)) { ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::Text("Type"); @@ -88,7 +88,6 @@ void FurnaceGUI::drawSampleEdit() { if (sample->rate>96000) sample->rate=96000; } - ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::Text("C-4 (Hz)"); ImGui::SameLine(); @@ -149,7 +148,7 @@ void FurnaceGUI::drawSampleEdit() { ImGui::SetTooltip("Edit mode: Draw"); } ImGui::SameLine(); - ImGui::Dummy(ImVec2(7.0*dpiScale,dpiScale)); + ImGui::Dummy(ImVec2(4.0*dpiScale,dpiScale)); ImGui::SameLine(); ImGui::Button(ICON_FA_ARROWS_H "##SResize"); if (ImGui::IsItemClicked()) { @@ -241,7 +240,23 @@ void FurnaceGUI::drawSampleEdit() { resampleTarget=sample->rate; } ImGui::SameLine(); - ImGui::Dummy(ImVec2(0.5*dpiScale,dpiScale)); + ImGui::Dummy(ImVec2(4.0*dpiScale,dpiScale)); + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_UNDO "##SUndo")) { + doUndoSample(); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Undo"); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_REPEAT "##SRedo")) { + doRedoSample(); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Redo"); + } + ImGui::SameLine(); + ImGui::Dummy(ImVec2(4.0*dpiScale,dpiScale)); ImGui::SameLine(); ImGui::Button(ICON_FA_VOLUME_UP "##SAmplify"); if (ImGui::IsItemHovered()) { @@ -312,7 +327,80 @@ void FurnaceGUI::drawSampleEdit() { ImGui::SetTooltip("Fade out"); } ImGui::SameLine(); - ImGui::Dummy(ImVec2(0.5*dpiScale,dpiScale)); + ImGui::Button(ICON_FA_ADJUST "##SInsertSilence"); + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Insert silence"); + } + if (openSampleSilenceOpt) { + openSampleSilenceOpt=false; + ImGui::OpenPopup("SSilenceOpt"); + } + if (ImGui::BeginPopupContextItem("SSilenceOpt",ImGuiPopupFlags_MouseButtonLeft)) { + if (ImGui::InputInt("Samples",&silenceSize,1,64)) { + if (silenceSize<0) silenceSize=0; + if (silenceSize>16777215) silenceSize=16777215; + } + if (ImGui::Button("Resize")) { + int pos=(sampleSelStart==-1 || sampleSelStart==sampleSelEnd)?sample->samples:sampleSelStart; + sample->prepareUndo(true); + e->lockEngine([this,sample,pos]() { + if (!sample->insert(pos,silenceSize)) { + showError("couldn't insert! make sure your sample is 8 or 16-bit."); + } + e->renderSamples(); + }); + updateSampleTex=true; + sampleSelStart=pos; + sampleSelEnd=pos+silenceSize; + MARK_MODIFIED; + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_ERASER "##SSilence")) { + doAction(GUI_ACTION_SAMPLE_SILENCE); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Apply silence"); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_TIMES "##SDelete")) { + doAction(GUI_ACTION_SAMPLE_DELETE); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Delete"); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_CROP "##STrim")) { + doAction(GUI_ACTION_SAMPLE_TRIM); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Trim"); + } + ImGui::SameLine(); + ImGui::Dummy(ImVec2(4.0*dpiScale,dpiScale)); + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_BACKWARD "##SReverse")) { + doAction(GUI_ACTION_SAMPLE_REVERSE); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Reverse"); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_SORT_AMOUNT_ASC "##SInvert")) { + doAction(GUI_ACTION_SAMPLE_INVERT); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Invert"); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_LEVEL_DOWN "##SSign")) { + doAction(GUI_ACTION_SAMPLE_SIGN); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Signed/unsigned exchange"); + } ImGui::SameLine(); ImGui::Button(ICON_FA_INDUSTRY "##SFilter"); if (ImGui::IsItemHovered()) { @@ -426,111 +514,23 @@ void FurnaceGUI::drawSampleEdit() { } ImGui::EndPopup(); } - - if (ImGui::Button(ICON_FA_UNDO "##SUndo")) { - doUndoSample(); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Undo"); - } ImGui::SameLine(); - if (ImGui::Button(ICON_FA_REPEAT "##SRedo")) { - doRedoSample(); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Redo"); - } + ImGui::Dummy(ImVec2(4.0*dpiScale,dpiScale)); ImGui::SameLine(); - ImGui::Dummy(ImVec2(7.0*dpiScale,dpiScale)); - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_BACKWARD "##SReverse")) { - doAction(GUI_ACTION_SAMPLE_REVERSE); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Reverse"); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_SORT_AMOUNT_ASC "##SInvert")) { - doAction(GUI_ACTION_SAMPLE_INVERT); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Invert"); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_LEVEL_DOWN "##SSign")) { - doAction(GUI_ACTION_SAMPLE_SIGN); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Signed/unsigned exchange"); - } - ImGui::SameLine(); - ImGui::Dummy(ImVec2(7.0*dpiScale,dpiScale)); - ImGui::SameLine(); - ImGui::Button(ICON_FA_ADJUST "##SInsertSilence"); - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Insert silence"); - } - if (openSampleSilenceOpt) { - openSampleSilenceOpt=false; - ImGui::OpenPopup("SSilenceOpt"); - } - if (ImGui::BeginPopupContextItem("SSilenceOpt",ImGuiPopupFlags_MouseButtonLeft)) { - if (ImGui::InputInt("Samples",&silenceSize,1,64)) { - if (silenceSize<0) silenceSize=0; - if (silenceSize>16777215) silenceSize=16777215; - } - if (ImGui::Button("Resize")) { - int pos=(sampleSelStart==-1 || sampleSelStart==sampleSelEnd)?sample->samples:sampleSelStart; - sample->prepareUndo(true); - e->lockEngine([this,sample,pos]() { - if (!sample->insert(pos,silenceSize)) { - showError("couldn't insert! make sure your sample is 8 or 16-bit."); - } - e->renderSamples(); - }); - updateSampleTex=true; - sampleSelStart=pos; - sampleSelEnd=pos+silenceSize; - MARK_MODIFIED; - ImGui::CloseCurrentPopup(); - } - ImGui::EndPopup(); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_ERASER "##SSilence")) { - doAction(GUI_ACTION_SAMPLE_SILENCE); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Apply silence"); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_TIMES "##SDelete")) { - doAction(GUI_ACTION_SAMPLE_DELETE); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Delete"); - } - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_CROP "##STrim")) { - doAction(GUI_ACTION_SAMPLE_TRIM); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Trim"); - } - - if (ImGui::Button(ICON_FA_PLAY "##PreviewSample")) { + if (ImGui::Button(ICON_FA_VOLUME_UP "##PreviewSample")) { e->previewSample(curSample); } if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Preview sample"); } ImGui::SameLine(); - if (ImGui::Button(ICON_FA_STOP "##StopSample")) { + if (ImGui::Button(ICON_FA_VOLUME_OFF "##StopSample")) { e->stopSamplePreview(); } if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Stop sample preview"); } + ImGui::SameLine(); double zoomPercent=100.0/sampleZoom; ImGui::Text("Zoom");