GUI: new osc renderer, part 21

part 11? I must have been drunk
alternate approach for OpenGL ES (no more hangs)
This commit is contained in:
tildearrow 2024-02-19 15:49:56 -05:00
parent 89249d4a2b
commit cfee9b3810
6 changed files with 82 additions and 40 deletions

View file

@ -182,16 +182,30 @@ void FurnaceGUI::drawChanOsc() {
ImGui::TableNextColumn();
if (ImGui::Checkbox("Randomize phase on note",&chanOscRandomPhase)) {
}
ImGui::EndTable();
}
ImGui::AlignTextToFramePadding();
ImGui::Text("Amplitude");
ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
if (CWSliderFloat("##COSAmp",&chanOscAmplify,0.0f,2.0f)) {
if (chanOscAmplify<0.0f) chanOscAmplify=0.0f;
if (chanOscAmplify>2.0f) chanOscAmplify=2.0f;
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::AlignTextToFramePadding();
ImGui::Text("Amplitude");
ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
if (CWSliderFloat("##COSAmp",&chanOscAmplify,0.0f,2.0f)) {
if (chanOscAmplify<0.0f) chanOscAmplify=0.0f;
if (chanOscAmplify>2.0f) chanOscAmplify=2.0f;
}
ImGui::TableNextColumn();
ImGui::AlignTextToFramePadding();
ImGui::Text("Line size");
ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
if (CWSliderFloat("##COSLine",&chanOscLineSize,0.25f,16.0f)) {
if (chanOscLineSize<0.25f) chanOscLineSize=0.26f;
if (chanOscLineSize>16.0f) chanOscLineSize=16.0f;
}
ImGui::EndTable();
}
ImGui::Checkbox("Gradient",&chanOscUseGrad);
@ -706,6 +720,7 @@ void FurnaceGUI::drawChanOsc() {
fft->drawOp.pos0=inRect.Min;
fft->drawOp.pos1=inRect.Max;
fft->drawOp.color=ImGui::ColorConvertU32ToFloat4(color);
fft->drawOp.lineSize=dpiScale*chanOscLineSize;
dl->AddCallback(_drawOsc,&fft->drawOp);
dl->AddCallback(ImDrawCallback_ResetRenderState,NULL);
@ -713,7 +728,7 @@ void FurnaceGUI::drawChanOsc() {
//ImGui::PushClipRect(inRect.Min,inRect.Max,false);
//ImDrawListFlags prevFlags=dl->Flags;
//dl->Flags&=~(ImDrawListFlags_AntiAliasedLines|ImDrawListFlags_AntiAliasedLinesUseTex);
dl->AddPolyline(waveform,precision,color,ImDrawFlags_None,dpiScale);
dl->AddPolyline(waveform,precision,color,ImDrawFlags_None,dpiScale*chanOscLineSize);
//dl->Flags=prevFlags;
//ImGui::PopClipRect();
}

View file

@ -6613,6 +6613,7 @@ bool FurnaceGUI::init() {
chanOscTextX=e->getConfFloat("chanOscTextX",0.0f);
chanOscTextY=e->getConfFloat("chanOscTextY",0.0f);
chanOscAmplify=e->getConfFloat("chanOscAmplify",0.95f);
chanOscLineSize=e->getConfFloat("chanOscLineSize",1.0f);
chanOscWindowSize=e->getConfFloat("chanOscWindowSize",20.0f);
chanOscWaveCorr=e->getConfBool("chanOscWaveCorr",true);
chanOscOptions=e->getConfBool("chanOscOptions",false);
@ -6935,8 +6936,6 @@ bool FurnaceGUI::init() {
}
}
newOscLineWidth=dpiScale;
updateWindowTitle();
rend->clear(ImVec4(0.0,0.0,0.0,1.0));
@ -7165,6 +7164,7 @@ void FurnaceGUI::commitState() {
e->setConf("chanOscTextX",chanOscTextX);
e->setConf("chanOscTextY",chanOscTextY);
e->setConf("chanOscAmplify",chanOscAmplify);
e->setConf("chanOscLineSize",chanOscLineSize);
e->setConf("chanOscWindowSize",chanOscWindowSize);
e->setConf("chanOscWaveCorr",chanOscWaveCorr);
e->setConf("chanOscOptions",chanOscOptions);
@ -7314,7 +7314,6 @@ FurnaceGUI::FurnaceGUI():
shallDetectScale(0),
cpuCores(0),
secondTimer(0.0f),
newOscLineWidth(2.0f),
userEvents(0xffffffff),
mobileMenuPos(0.0f),
autoButtonSize(0.0f),
@ -7680,6 +7679,7 @@ FurnaceGUI::FurnaceGUI():
chanOscTextX(0.0f),
chanOscTextY(0.0f),
chanOscAmplify(0.95f),
chanOscLineSize(1.0f),
chanOscWaveCorr(true),
chanOscOptions(false),
updateChanOscGradTex(true),

View file

@ -1455,13 +1455,15 @@ struct PendingDrawOsc {
ImVec2 pos0;
ImVec2 pos1;
ImVec4 color;
float lineSize;
PendingDrawOsc():
gui(NULL),
data(NULL),
len(0),
pos0(0,0),
pos1(0,0),
color(0,0,0,0) {}
color(0,0,0,0),
lineSize(0.0f) {}
};
class FurnaceGUI {
@ -1521,7 +1523,7 @@ class FurnaceGUI {
int wheelCalmDown;
int shallDetectScale;
int cpuCores;
float secondTimer, newOscLineWidth;
float secondTimer;
unsigned int userEvents;
float mobileMenuPos, autoButtonSize, mobileEditAnim;
ImVec2 mobileEditButtonPos, mobileEditButtonSize;
@ -1684,6 +1686,7 @@ class FurnaceGUI {
int oscEscapesBoundary;
int oscMono;
int oscAntiAlias;
float oscLineSize;
int separateFMColors;
int insEditColorize;
int metroVol;
@ -1886,6 +1889,7 @@ class FurnaceGUI {
oscEscapesBoundary(0),
oscMono(1),
oscAntiAlias(1),
oscLineSize(1.0f),
separateFMColors(0),
insEditColorize(0),
metroVol(100),
@ -2284,7 +2288,7 @@ class FurnaceGUI {
// per-channel oscilloscope
int chanOscCols, chanOscAutoColsType, chanOscColorX, chanOscColorY;
float chanOscWindowSize, chanOscTextX, chanOscTextY, chanOscAmplify;
float chanOscWindowSize, chanOscTextX, chanOscTextY, chanOscAmplify, chanOscLineSize;
bool chanOscWaveCorr, chanOscOptions, updateChanOscGradTex, chanOscUseGrad, chanOscNormalize, chanOscRandomPhase;
String chanOscTextFormat;
ImVec4 chanOscColor, chanOscTextColor;

View file

@ -110,7 +110,7 @@ void FurnaceGUI::readOsc() {
avg+=oscValues[j][i];
}
avg/=e->getAudioDescGot().outChans;
oscValuesAverage[i]=avg;
oscValuesAverage[i]=avg*oscZoom;
}
/*for (int i=0; i<oscWidth; i++) {
@ -150,7 +150,7 @@ static void _drawOsc(const ImDrawList* drawList, const ImDrawCmd* cmd) {
}
void FurnaceGUI::runPendingDrawOsc(PendingDrawOsc* which) {
rend->drawOsc(which->data,which->len,which->pos0,which->pos1,which->color,ImVec2(canvasW,canvasH),newOscLineWidth);
rend->drawOsc(which->data,which->len,which->pos0,which->pos1,which->color,ImVec2(canvasW,canvasH),which->lineSize);
}
void FurnaceGUI::drawOsc() {
@ -300,6 +300,7 @@ void FurnaceGUI::drawOsc() {
_do.pos0=inRect.Min;
_do.pos1=inRect.Max;
_do.color=isClipping?uiColors[GUI_COLOR_OSC_WAVE_PEAK]:uiColors[GUI_COLOR_OSC_WAVE];
_do.lineSize=dpiScale*settings.oscLineSize;
dl->AddCallback(_drawOsc,&_do);
dl->AddCallback(ImDrawCallback_ResetRenderState,NULL);
@ -316,37 +317,49 @@ void FurnaceGUI::drawOsc() {
if (settings.oscEscapesBoundary) {
dl->PushClipRectFullScreen();
dl->AddPolyline(waveform,oscWidth-24,color,ImDrawFlags_None,dpiScale);
dl->AddPolyline(waveform,oscWidth-24,color,ImDrawFlags_None,dpiScale*settings.oscLineSize);
dl->PopClipRect();
} else {
dl->AddPolyline(waveform,oscWidth-24,color,ImDrawFlags_None,dpiScale);
dl->AddPolyline(waveform,oscWidth-24,color,ImDrawFlags_None,dpiScale*settings.oscLineSize);
}
}
} else {
for (int ch=0; ch<e->getAudioDescGot().outChans; ch++) {
for (int i=0; i<oscWidth-24; i++) {
float x=(float)i/(float)(oscWidth-24);
float y=oscValues[ch][i+12]*oscZoom;
if (!settings.oscEscapesBoundary) {
if (y<-0.5f) y=-0.5f;
if (y>0.5f) y=0.5f;
}
waveform[i]=ImLerp(inRect.Min,inRect.Max,ImVec2(x,0.5f-y));
if (!isClipping) {
color=ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_WAVE_CH0+ch]);
}
if (!isClipping) {
//color=ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_WAVE_CH0+ch]);
}
/*
if (settings.oscEscapesBoundary) {
dl->PushClipRectFullScreen();
dl->AddPolyline(waveform,oscWidth-24,color,ImDrawFlags_None,dpiScale);
dl->PopClipRect();
if (rend->supportsDrawOsc() && settings.shaderOsc) {
_do.gui=this;
_do.data=&oscValues[ch][12];
_do.len=oscWidth-24;
_do.pos0=inRect.Min;
_do.pos1=inRect.Max;
_do.color=isClipping?uiColors[GUI_COLOR_OSC_WAVE_PEAK]:uiColors[GUI_COLOR_OSC_WAVE_CH0+ch];
_do.lineSize=dpiScale*settings.oscLineSize;
dl->AddCallback(_drawOsc,&_do);
dl->AddCallback(ImDrawCallback_ResetRenderState,NULL);
} else {
dl->AddPolyline(waveform,oscWidth-24,color,ImDrawFlags_None,dpiScale);
for (int i=0; i<oscWidth-24; i++) {
float x=(float)i/(float)(oscWidth-24);
float y=oscValues[ch][i+12]*oscZoom;
if (!settings.oscEscapesBoundary) {
if (y<-0.5f) y=-0.5f;
if (y>0.5f) y=0.5f;
}
waveform[i]=ImLerp(inRect.Min,inRect.Max,ImVec2(x,0.5f-y));
}
if (settings.oscEscapesBoundary) {
dl->PushClipRectFullScreen();
dl->AddPolyline(waveform,oscWidth-24,color,ImDrawFlags_None,dpiScale*settings.oscLineSize);
dl->PopClipRect();
} else {
dl->AddPolyline(waveform,oscWidth-24,color,ImDrawFlags_None,dpiScale*settings.oscLineSize);
}
}
*/
}
}
}

View file

@ -116,7 +116,8 @@ const char* sh_oscRender_srcF=
" float slope=abs(valmax-valmin)*uResolution.y*0.5;\n"
" float slopeDiv=min(uAdvance,(uAdvance/slope));\n"
" float xRight=uv.x+((uLineWidth)/uResolution.x);\n"
" for (float x=max(0.0,uv.x-(uLineWidth/uResolution.x)); x<=xRight; x+=slopeDiv) {\n"
" for (float s=0.0; s<max(1,slope); s+=1.0) {\n"
" float x=max(0.0,uv.x-(uLineWidth/uResolution.x)+s*slopeDiv);\n"
" float val=texture2D(oscVal,vec2(x,1.0)).x*uResolution.y*0.5;\n"
" alpha+=clamp(uLineWidth-distance(vec2(fur_fragCoord.x,fur_fragCoord.y),vec2(x*uResolution.x,val)),0.0,1.0);\n"
" }\n"

View file

@ -3200,6 +3200,12 @@ void FurnaceGUI::drawSettings() {
settingsChanged=true;
}
if (ImGui::SliderFloat("Line size",&settings.oscLineSize,0.25f,16.0f,"%.1f")) {
if (settings.oscLineSize<0.25f) settings.oscLineSize=0.25f;
if (settings.oscLineSize>16.0f) settings.oscLineSize=16.0f;
settingsChanged=true;
} rightClickable
// SUBSECTION WINDOWS
CONFIG_SUBSECTION("Windows");
bool roundedWindowsB=settings.roundedWindows;
@ -3977,6 +3983,7 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
settings.oscEscapesBoundary=conf.getInt("oscEscapesBoundary",0);
settings.oscMono=conf.getInt("oscMono",1);
settings.oscAntiAlias=conf.getInt("oscAntiAlias",1);
settings.oscLineSize=conf.getFloat("oscLineSize",1.0f);
settings.channelColors=conf.getInt("channelColors",1);
settings.channelTextColors=conf.getInt("channelTextColors",0);
@ -4263,6 +4270,7 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
clampSetting(settings.basicColors,0,1);
clampSetting(settings.playbackTime,0,1);
clampSetting(settings.shaderOsc,0,1);
clampSetting(settings.oscLineSize,0.25f,16.0f);
if (settings.exportLoops<0.0) settings.exportLoops=0.0;
if (settings.exportFadeOut<0.0) settings.exportFadeOut=0.0;
@ -4443,6 +4451,7 @@ void FurnaceGUI::writeConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
conf.set("oscEscapesBoundary",settings.oscEscapesBoundary);
conf.set("oscMono",settings.oscMono);
conf.set("oscAntiAlias",settings.oscAntiAlias);
conf.set("oscLineSize",settings.oscLineSize);
conf.set("channelColors",settings.channelColors);
conf.set("channelTextColors",settings.channelTextColors);