2022-03-21 18:34:43 -04:00
|
|
|
/**
|
|
|
|
* Furnace Tracker - multi-system chiptune tracker
|
2024-01-16 21:26:57 -05:00
|
|
|
* Copyright (C) 2021-2024 tildearrow and contributors
|
2022-03-21 18:34:43 -04:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gui.h"
|
2022-04-09 06:02:24 -04:00
|
|
|
#include "imgui_internal.h"
|
2022-05-23 18:42:25 -04:00
|
|
|
#include <imgui.h>
|
2023-08-05 03:52:02 -04:00
|
|
|
#include "../ta-log.h"
|
|
|
|
#include "../engine/filter.h"
|
2022-04-09 03:42:58 -04:00
|
|
|
|
|
|
|
void FurnaceGUI::readOsc() {
|
|
|
|
int writePos=e->oscWritePos;
|
|
|
|
int readPos=e->oscReadPos;
|
|
|
|
int avail=0;
|
|
|
|
int total=0;
|
2022-04-12 02:51:15 -04:00
|
|
|
if (firstFrame) {
|
|
|
|
readPos=writePos;
|
|
|
|
}
|
2022-04-09 03:42:58 -04:00
|
|
|
if (writePos>=readPos) {
|
|
|
|
avail=writePos-readPos;
|
|
|
|
} else {
|
|
|
|
avail=writePos-readPos+32768;
|
|
|
|
}
|
|
|
|
if (oscTotal==0) {
|
|
|
|
oscTotal=ImGui::GetIO().DeltaTime*e->getAudioDescGot().rate;
|
|
|
|
} else {
|
|
|
|
oscTotal=(oscTotal+(int)round(ImGui::GetIO().DeltaTime*e->getAudioDescGot().rate))>>1;
|
|
|
|
}
|
|
|
|
int bias=avail-oscTotal-e->getAudioDescGot().bufsize;
|
|
|
|
if (bias<0) bias=0;
|
|
|
|
total=oscTotal+(bias>>6);
|
|
|
|
if (total>avail) total=avail;
|
|
|
|
//printf("total: %d. avail: %d bias: %d\n",total,avail,bias);
|
2022-05-30 22:40:07 -04:00
|
|
|
|
|
|
|
int winSize=e->getAudioDescGot().rate*(oscWindowSize/1000.0);
|
|
|
|
int oscReadPos=(writePos-winSize)&0x7fff;
|
2023-08-05 03:52:02 -04:00
|
|
|
|
2023-08-05 04:26:36 -04:00
|
|
|
for (int ch=0; ch<e->getAudioDescGot().outChans; ch++) {
|
|
|
|
if (oscValues[ch]==NULL) {
|
2023-09-08 01:41:47 -04:00
|
|
|
oscValues[ch]=new float[2048];
|
2023-01-05 02:40:17 -05:00
|
|
|
}
|
2023-09-08 01:41:47 -04:00
|
|
|
memset(oscValues[ch],0,2048*sizeof(float));
|
2023-09-08 00:37:17 -04:00
|
|
|
float* sincITable=DivFilterTables::getSincIntegralSmallTable();
|
2023-01-05 02:40:17 -05:00
|
|
|
|
2023-08-05 04:26:36 -04:00
|
|
|
float posFrac=0.0;
|
|
|
|
float factor=(float)oscWidth/(float)winSize;
|
2023-09-07 23:38:37 -04:00
|
|
|
int posInt=oscReadPos-(8.0f/factor);
|
2023-09-08 01:41:47 -04:00
|
|
|
for (int i=7; i<oscWidth-9; i++) {
|
|
|
|
oscValues[ch][i]+=e->oscBuf[ch][posInt&0x7fff];
|
2023-08-05 03:52:02 -04:00
|
|
|
|
2023-08-05 04:26:36 -04:00
|
|
|
posFrac+=1.0;
|
|
|
|
while (posFrac>=1.0) {
|
2023-09-08 01:41:47 -04:00
|
|
|
unsigned int n=((unsigned int)(posFrac*64.0))&63;
|
2023-08-05 04:26:36 -04:00
|
|
|
posFrac-=factor;
|
|
|
|
posInt++;
|
2023-08-05 03:52:02 -04:00
|
|
|
|
2023-09-08 01:41:47 -04:00
|
|
|
float* t1=&sincITable[(63-n)<<3];
|
2023-08-05 04:26:36 -04:00
|
|
|
float* t2=&sincITable[n<<3];
|
|
|
|
float delta=e->oscBuf[ch][posInt&0x7fff]-e->oscBuf[ch][(posInt-1)&0x7fff];
|
2023-08-05 03:52:02 -04:00
|
|
|
|
2023-09-08 01:46:09 -04:00
|
|
|
oscValues[ch][i-7]+=t1[7]*-delta;
|
|
|
|
oscValues[ch][i-6]+=t1[6]*-delta;
|
|
|
|
oscValues[ch][i-5]+=t1[5]*-delta;
|
|
|
|
oscValues[ch][i-4]+=t1[4]*-delta;
|
|
|
|
oscValues[ch][i-3]+=t1[3]*-delta;
|
|
|
|
oscValues[ch][i-2]+=t1[2]*-delta;
|
|
|
|
oscValues[ch][i-1]+=t1[1]*-delta;
|
|
|
|
oscValues[ch][i] +=t1[0]*-delta;
|
|
|
|
|
|
|
|
oscValues[ch][i+1]+=t2[0]*delta;
|
|
|
|
oscValues[ch][i+2]+=t2[1]*delta;
|
|
|
|
oscValues[ch][i+3]+=t2[2]*delta;
|
|
|
|
oscValues[ch][i+4]+=t2[3]*delta;
|
|
|
|
oscValues[ch][i+5]+=t2[4]*delta;
|
|
|
|
oscValues[ch][i+6]+=t2[5]*delta;
|
|
|
|
oscValues[ch][i+7]+=t2[6]*delta;
|
|
|
|
oscValues[ch][i+8]+=t2[7]*delta;
|
2023-08-05 03:52:02 -04:00
|
|
|
}
|
2022-04-16 19:35:25 -04:00
|
|
|
}
|
2022-04-09 03:42:58 -04:00
|
|
|
|
2023-08-05 04:26:36 -04:00
|
|
|
for (int i=0; i<oscWidth; i++) {
|
|
|
|
if (oscValues[ch][i]>0.001f || oscValues[ch][i]<-0.001f) {
|
|
|
|
WAKE_UP;
|
|
|
|
}
|
2023-08-05 03:52:02 -04:00
|
|
|
}
|
2023-08-05 03:54:09 -04:00
|
|
|
}
|
2023-08-05 03:52:02 -04:00
|
|
|
|
2024-02-09 19:20:09 -05:00
|
|
|
if (oscValuesAverage==NULL) {
|
|
|
|
oscValuesAverage=new float[2048];
|
|
|
|
}
|
|
|
|
memset(oscValuesAverage,0,2048*sizeof(float));
|
|
|
|
for (int i=0; i<oscWidth; i++) {
|
|
|
|
float avg=0;
|
|
|
|
for (int j=0; j<e->getAudioDescGot().outChans; j++) {
|
|
|
|
avg+=oscValues[j][i];
|
|
|
|
}
|
|
|
|
avg/=e->getAudioDescGot().outChans;
|
2024-02-19 23:56:39 -05:00
|
|
|
oscValuesAverage[i]=avg*oscZoom*2.0f;
|
2024-02-09 19:20:09 -05:00
|
|
|
}
|
|
|
|
|
2023-08-05 03:52:02 -04:00
|
|
|
/*for (int i=0; i<oscWidth; i++) {
|
|
|
|
oscValues[i]=(i&1)?0.3:0;
|
|
|
|
}*/
|
|
|
|
|
2022-04-09 03:42:58 -04:00
|
|
|
float peakDecay=0.05f*60.0f*ImGui::GetIO().DeltaTime;
|
2023-01-05 02:40:17 -05:00
|
|
|
for (int i=0; i<e->getAudioDescGot().outChans; i++) {
|
2022-04-09 03:42:58 -04:00
|
|
|
peak[i]*=1.0-peakDecay;
|
2022-04-16 19:35:25 -04:00
|
|
|
if (peak[i]<0.0001) {
|
|
|
|
peak[i]=0.0;
|
|
|
|
} else {
|
|
|
|
WAKE_UP;
|
|
|
|
}
|
2022-04-09 03:42:58 -04:00
|
|
|
float newPeak=peak[i];
|
|
|
|
for (int j=0; j<total; j++) {
|
|
|
|
int pos=(readPos+j)&0x7fff;
|
|
|
|
if (fabs(e->oscBuf[i][pos])>newPeak) {
|
|
|
|
newPeak=fabs(e->oscBuf[i][pos]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
peak[i]+=(newPeak-peak[i])*0.9;
|
|
|
|
}
|
|
|
|
|
|
|
|
readPos=(readPos+total)&0x7fff;
|
|
|
|
e->oscReadPos=readPos;
|
|
|
|
}
|
2022-03-21 18:34:43 -04:00
|
|
|
|
2024-02-09 19:20:09 -05:00
|
|
|
PendingDrawOsc _do;
|
|
|
|
|
2024-02-12 18:56:39 -05:00
|
|
|
static void _drawOsc(const ImDrawList* drawList, const ImDrawCmd* cmd) {
|
2024-02-09 02:57:25 -05:00
|
|
|
if (cmd!=NULL) {
|
|
|
|
if (cmd->UserCallbackData!=NULL) {
|
2024-02-09 19:20:09 -05:00
|
|
|
((FurnaceGUI*)(((PendingDrawOsc*)cmd->UserCallbackData)->gui))->runPendingDrawOsc((PendingDrawOsc*)cmd->UserCallbackData);
|
2024-02-09 02:57:25 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-09 19:20:09 -05:00
|
|
|
void FurnaceGUI::runPendingDrawOsc(PendingDrawOsc* which) {
|
2024-02-19 15:49:56 -05:00
|
|
|
rend->drawOsc(which->data,which->len,which->pos0,which->pos1,which->color,ImVec2(canvasW,canvasH),which->lineSize);
|
2024-02-09 19:20:09 -05:00
|
|
|
}
|
|
|
|
|
2022-03-21 18:34:43 -04:00
|
|
|
void FurnaceGUI::drawOsc() {
|
|
|
|
if (nextWindow==GUI_WINDOW_OSCILLOSCOPE) {
|
|
|
|
oscOpen=true;
|
|
|
|
ImGui::SetNextWindowFocus();
|
|
|
|
nextWindow=GUI_WINDOW_NOTHING;
|
|
|
|
}
|
|
|
|
if (!oscOpen) return;
|
2022-10-20 03:34:14 -04:00
|
|
|
ImGui::SetNextWindowSizeConstraints(ImVec2(64.0f*dpiScale,32.0f*dpiScale),ImVec2(canvasW,canvasH));
|
2022-04-11 04:34:38 -04:00
|
|
|
if (settings.oscTakesEntireWindow) {
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding,ImVec2(0,0));
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,ImVec2(0,0));
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemInnerSpacing,ImVec2(0,0));
|
|
|
|
}
|
2024-05-27 18:53:46 -04:00
|
|
|
if (ImGui::Begin("Oscilloscope",&oscOpen,globalWinFlags,_("Oscilloscope"))) {
|
2022-04-09 06:02:24 -04:00
|
|
|
if (oscZoomSlider) {
|
|
|
|
if (ImGui::VSliderFloat("##OscZoom",ImVec2(20.0f*dpiScale,ImGui::GetContentRegionAvail().y),&oscZoom,0.5,2.0)) {
|
|
|
|
if (oscZoom<0.5) oscZoom=0.5;
|
|
|
|
if (oscZoom>2.0) oscZoom=2.0;
|
2023-04-20 05:01:00 -04:00
|
|
|
} rightClickable
|
2022-05-30 23:22:53 -04:00
|
|
|
if (ImGui::IsItemHovered()) {
|
2024-05-26 20:31:17 -04:00
|
|
|
ImGui::SetTooltip(_("zoom: %.2fx (%.1fdB)"),oscZoom,20.0*log10(oscZoom*2.0));
|
2022-05-30 23:22:53 -04:00
|
|
|
}
|
|
|
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Middle)) {
|
|
|
|
oscZoom=0.5;
|
|
|
|
}
|
2022-04-09 06:02:24 -04:00
|
|
|
ImGui::SameLine();
|
2022-05-30 22:40:07 -04:00
|
|
|
if (ImGui::VSliderFloat("##OscWinSize",ImVec2(20.0f*dpiScale,ImGui::GetContentRegionAvail().y),&oscWindowSize,5.0,100.0)) {
|
|
|
|
if (oscWindowSize<5.0) oscWindowSize=5.0;
|
|
|
|
if (oscWindowSize>100.0) oscWindowSize=100.0;
|
2023-04-20 05:01:00 -04:00
|
|
|
} rightClickable
|
2022-05-30 23:22:53 -04:00
|
|
|
if (ImGui::IsItemHovered()) {
|
2024-05-26 20:31:17 -04:00
|
|
|
ImGui::SetTooltip(_("window size: %.1fms"),oscWindowSize);
|
2022-05-30 23:22:53 -04:00
|
|
|
}
|
2022-05-30 22:40:07 -04:00
|
|
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Middle)) {
|
|
|
|
oscWindowSize=20.0;
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
2022-04-09 06:02:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ImDrawList* dl=ImGui::GetWindowDrawList();
|
|
|
|
ImGuiWindow* window=ImGui::GetCurrentWindow();
|
|
|
|
|
2023-09-08 01:41:47 -04:00
|
|
|
static ImVec2 waveform[2048];
|
2022-04-09 06:02:24 -04:00
|
|
|
ImVec2 size=ImGui::GetContentRegionAvail();
|
|
|
|
|
|
|
|
ImVec2 minArea=window->DC.CursorPos;
|
|
|
|
ImVec2 maxArea=ImVec2(
|
|
|
|
minArea.x+size.x,
|
|
|
|
minArea.y+size.y
|
|
|
|
);
|
|
|
|
ImRect rect=ImRect(minArea,maxArea);
|
2022-04-09 19:25:25 -04:00
|
|
|
ImRect inRect=rect;
|
|
|
|
inRect.Min.x+=dpiScale;
|
|
|
|
inRect.Min.y+=dpiScale;
|
|
|
|
inRect.Max.x-=dpiScale;
|
|
|
|
inRect.Max.y-=dpiScale;
|
2022-04-09 06:02:24 -04:00
|
|
|
ImGuiStyle& style=ImGui::GetStyle();
|
2024-02-09 19:20:09 -05:00
|
|
|
ImU32 color=ImGui::GetColorU32(isClipping?uiColors[GUI_COLOR_OSC_WAVE_PEAK]:uiColors[GUI_COLOR_OSC_WAVE]);
|
2022-04-09 06:02:24 -04:00
|
|
|
ImU32 borderColor=ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_BORDER]);
|
2022-04-09 19:25:25 -04:00
|
|
|
ImU32 refColor=ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_REF]);
|
2022-04-12 01:17:34 -04:00
|
|
|
ImU32 guideColor=ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_GUIDE]);
|
2022-04-09 06:02:24 -04:00
|
|
|
ImGui::ItemSize(size,style.FramePadding.y);
|
|
|
|
if (ImGui::ItemAdd(rect,ImGui::GetID("wsDisplay"))) {
|
2024-04-08 23:24:08 -04:00
|
|
|
if (safeMode || renderBackend==GUI_BACKEND_SOFTWARE) {
|
|
|
|
dl->AddRectFilled(
|
|
|
|
inRect.Min,
|
|
|
|
inRect.Max,
|
|
|
|
ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_BG4])
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
dl->AddRectFilledMultiColor(
|
|
|
|
inRect.Min,
|
|
|
|
inRect.Max,
|
|
|
|
ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_BG1]),
|
|
|
|
ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_BG2]),
|
|
|
|
ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_BG4]),
|
|
|
|
ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_BG3]),
|
|
|
|
settings.oscRoundedCorners?(8.0f*dpiScale):0.0f
|
|
|
|
);
|
|
|
|
}
|
2022-04-09 06:02:24 -04:00
|
|
|
|
2022-04-09 19:25:25 -04:00
|
|
|
dl->AddLine(
|
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(0.0f,0.5f)),
|
2022-04-12 01:17:34 -04:00
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(1.0f,0.5f)),
|
2022-04-09 19:25:25 -04:00
|
|
|
refColor,
|
|
|
|
dpiScale
|
|
|
|
);
|
|
|
|
|
2022-04-12 01:17:34 -04:00
|
|
|
dl->AddLine(
|
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(0.48f,0.125f)),
|
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(0.52f,0.125f)),
|
|
|
|
guideColor,
|
|
|
|
dpiScale
|
|
|
|
);
|
|
|
|
|
|
|
|
dl->AddLine(
|
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(0.47f,0.25f)),
|
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(0.53f,0.25f)),
|
|
|
|
guideColor,
|
|
|
|
dpiScale
|
|
|
|
);
|
|
|
|
|
|
|
|
dl->AddLine(
|
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(0.45f,0.375f)),
|
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(0.55f,0.375f)),
|
|
|
|
guideColor,
|
|
|
|
dpiScale
|
|
|
|
);
|
|
|
|
|
|
|
|
dl->AddLine(
|
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(0.45f,0.625f)),
|
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(0.55f,0.625f)),
|
|
|
|
guideColor,
|
|
|
|
dpiScale
|
|
|
|
);
|
|
|
|
|
|
|
|
dl->AddLine(
|
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(0.47f,0.75f)),
|
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(0.53f,0.75f)),
|
|
|
|
guideColor,
|
|
|
|
dpiScale
|
|
|
|
);
|
|
|
|
|
|
|
|
dl->AddLine(
|
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(0.48f,0.875f)),
|
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(0.52f,0.875f)),
|
|
|
|
guideColor,
|
|
|
|
dpiScale
|
|
|
|
);
|
|
|
|
|
|
|
|
dl->AddLine(
|
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(0.5f,0.08f)),
|
|
|
|
ImLerp(rect.Min,rect.Max,ImVec2(0.5f,0.92f)),
|
|
|
|
guideColor,
|
|
|
|
dpiScale
|
|
|
|
);
|
|
|
|
|
2023-09-08 01:41:47 -04:00
|
|
|
oscWidth=round(inRect.Max.x-inRect.Min.x)+24;
|
|
|
|
if (oscWidth<17) oscWidth=17;
|
|
|
|
if (oscWidth>2048) oscWidth=2048;
|
2023-08-05 03:52:02 -04:00
|
|
|
|
2023-08-05 04:26:36 -04:00
|
|
|
ImDrawListFlags prevFlags=dl->Flags;
|
2023-10-16 07:53:21 -04:00
|
|
|
if (!settings.oscAntiAlias || safeMode) {
|
2023-08-05 04:26:36 -04:00
|
|
|
dl->Flags&=~(ImDrawListFlags_AntiAliasedLines|ImDrawListFlags_AntiAliasedLinesUseTex);
|
2022-04-09 06:02:24 -04:00
|
|
|
}
|
2023-08-05 04:26:36 -04:00
|
|
|
|
2023-09-08 01:41:47 -04:00
|
|
|
if ((oscWidth-24)>0) {
|
|
|
|
if (settings.oscMono) {
|
2024-02-19 02:57:48 -05:00
|
|
|
if (rend->supportsDrawOsc() && settings.shaderOsc) {
|
2024-02-10 14:50:23 -05:00
|
|
|
_do.gui=this;
|
|
|
|
_do.data=&oscValuesAverage[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];
|
2024-02-19 15:49:56 -05:00
|
|
|
_do.lineSize=dpiScale*settings.oscLineSize;
|
2024-02-10 14:50:23 -05:00
|
|
|
|
|
|
|
dl->AddCallback(_drawOsc,&_do);
|
|
|
|
dl->AddCallback(ImDrawCallback_ResetRenderState,NULL);
|
2023-08-05 04:26:36 -04:00
|
|
|
} else {
|
2024-02-11 17:57:50 -05:00
|
|
|
for (int i=0; i<oscWidth-24; i++) {
|
|
|
|
float x=(float)i/(float)(oscWidth-24);
|
2024-02-20 15:40:48 -05:00
|
|
|
float y=oscValuesAverage[i+12]*0.5f;
|
2024-02-11 17:57:50 -05:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2024-02-10 14:50:23 -05:00
|
|
|
if (settings.oscEscapesBoundary) {
|
|
|
|
dl->PushClipRectFullScreen();
|
2024-02-19 15:49:56 -05:00
|
|
|
dl->AddPolyline(waveform,oscWidth-24,color,ImDrawFlags_None,dpiScale*settings.oscLineSize);
|
2024-02-10 14:50:23 -05:00
|
|
|
dl->PopClipRect();
|
|
|
|
} else {
|
2024-02-19 15:49:56 -05:00
|
|
|
dl->AddPolyline(waveform,oscWidth-24,color,ImDrawFlags_None,dpiScale*settings.oscLineSize);
|
2024-02-10 14:50:23 -05:00
|
|
|
}
|
2023-09-08 01:41:47 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int ch=0; ch<e->getAudioDescGot().outChans; ch++) {
|
|
|
|
if (!isClipping) {
|
2024-02-19 15:49:56 -05:00
|
|
|
color=ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_WAVE_CH0+ch]);
|
2023-09-08 01:41:47 -04:00
|
|
|
}
|
2024-02-19 15:49:56 -05:00
|
|
|
|
|
|
|
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);
|
2023-09-08 01:41:47 -04:00
|
|
|
} else {
|
2024-02-19 15:49:56 -05:00
|
|
|
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);
|
|
|
|
}
|
2023-09-08 01:41:47 -04:00
|
|
|
}
|
2023-08-05 04:26:36 -04:00
|
|
|
}
|
|
|
|
}
|
2022-05-23 18:42:25 -04:00
|
|
|
}
|
2023-08-05 04:26:36 -04:00
|
|
|
|
|
|
|
dl->Flags=prevFlags;
|
|
|
|
|
2022-04-11 04:34:38 -04:00
|
|
|
if (settings.oscBorder) {
|
2024-04-08 23:24:08 -04:00
|
|
|
dl->AddRect(inRect.Min,inRect.Max,borderColor,(settings.oscRoundedCorners && !(safeMode || renderBackend==GUI_BACKEND_SOFTWARE))?(8.0f*dpiScale):0.0f,0,1.5f*dpiScale);
|
2022-04-11 04:34:38 -04:00
|
|
|
}
|
2022-04-09 06:02:24 -04:00
|
|
|
}
|
2022-05-30 23:22:53 -04:00
|
|
|
if (oscZoomSlider && ImGui::IsItemHovered()) {
|
|
|
|
float val=20.0*log10(2.0*fabs(0.5-((ImGui::GetMousePos().y-inRect.Min.y)/(inRect.Max.y-inRect.Min.y))));
|
|
|
|
if (val>0.0f) val=0.0f;
|
|
|
|
if (val<=-INFINITY) {
|
2024-05-26 20:31:17 -04:00
|
|
|
ImGui::SetTooltip(_("(-Infinity)dB"));
|
2022-05-30 23:22:53 -04:00
|
|
|
} else {
|
|
|
|
ImGui::SetTooltip("%.1fdB",val);
|
|
|
|
}
|
|
|
|
}
|
2022-04-09 06:02:24 -04:00
|
|
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
|
|
|
oscZoomSlider=!oscZoomSlider;
|
|
|
|
}
|
2024-02-19 18:22:08 -05:00
|
|
|
if (mobileUI && ImGui::IsItemHovered() && CHECK_LONG_HOLD) {
|
|
|
|
oscZoomSlider=!oscZoomSlider;
|
|
|
|
NOTIFY_LONG_HOLD;
|
|
|
|
}
|
2022-03-21 18:34:43 -04:00
|
|
|
}
|
2022-04-11 04:34:38 -04:00
|
|
|
if (settings.oscTakesEntireWindow) {
|
|
|
|
ImGui::PopStyleVar(3);
|
|
|
|
}
|
2022-03-21 18:34:43 -04:00
|
|
|
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_OSCILLOSCOPE;
|
|
|
|
ImGui::End();
|
2022-04-09 06:02:24 -04:00
|
|
|
}
|