GUI: new osc renderer, part 2 - warning
why does it crash...
This commit is contained in:
parent
5ec7c4a541
commit
e41e8ed962
6 changed files with 83 additions and 29 deletions
|
|
@ -100,6 +100,19 @@ void FurnaceGUI::readOsc() {
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
oscValuesAverage[i]=avg;
|
||||
}
|
||||
|
||||
/*for (int i=0; i<oscWidth; i++) {
|
||||
oscValues[i]=(i&1)?0.3:0;
|
||||
}*/
|
||||
|
|
@ -126,14 +139,20 @@ void FurnaceGUI::readOsc() {
|
|||
e->oscReadPos=readPos;
|
||||
}
|
||||
|
||||
void _pushPartBlend(const ImDrawList* drawList, const ImDrawCmd* cmd) {
|
||||
PendingDrawOsc _do;
|
||||
|
||||
void _drawOsc(const ImDrawList* drawList, const ImDrawCmd* cmd) {
|
||||
if (cmd!=NULL) {
|
||||
if (cmd->UserCallbackData!=NULL) {
|
||||
((FurnaceGUI*)cmd->UserCallbackData)->pushPartBlend();
|
||||
((FurnaceGUI*)(((PendingDrawOsc*)cmd->UserCallbackData)->gui))->runPendingDrawOsc((PendingDrawOsc*)cmd->UserCallbackData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FurnaceGUI::runPendingDrawOsc(PendingDrawOsc* which) {
|
||||
rend->drawOsc(which->data,which->len,which->pos0,which->pos1,which->color,ImVec2(canvasW,canvasH),dpiScale);
|
||||
}
|
||||
|
||||
void FurnaceGUI::drawOsc() {
|
||||
if (nextWindow==GUI_WINDOW_OSCILLOSCOPE) {
|
||||
oscOpen=true;
|
||||
|
|
@ -191,7 +210,7 @@ void FurnaceGUI::drawOsc() {
|
|||
inRect.Max.x-=dpiScale;
|
||||
inRect.Max.y-=dpiScale;
|
||||
ImGuiStyle& style=ImGui::GetStyle();
|
||||
//ImU32 color=ImGui::GetColorU32(isClipping?uiColors[GUI_COLOR_OSC_WAVE_PEAK]:uiColors[GUI_COLOR_OSC_WAVE]);
|
||||
ImU32 color=ImGui::GetColorU32(isClipping?uiColors[GUI_COLOR_OSC_WAVE_PEAK]:uiColors[GUI_COLOR_OSC_WAVE]);
|
||||
ImU32 borderColor=ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_BORDER]);
|
||||
ImU32 refColor=ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_REF]);
|
||||
ImU32 guideColor=ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_GUIDE]);
|
||||
|
|
@ -276,13 +295,7 @@ void FurnaceGUI::drawOsc() {
|
|||
if (settings.oscMono) {
|
||||
for (int i=0; i<oscWidth-24; i++) {
|
||||
float x=(float)i/(float)(oscWidth-24);
|
||||
float avg=0;
|
||||
for (int j=0; j<e->getAudioDescGot().outChans; j++) {
|
||||
avg+=oscValues[j][i+12];
|
||||
}
|
||||
avg/=e->getAudioDescGot().outChans;
|
||||
|
||||
float y=avg*oscZoom;
|
||||
float y=oscValuesAverage[i+12]*oscZoom;
|
||||
if (!settings.oscEscapesBoundary) {
|
||||
if (y<-0.5f) y=-0.5f;
|
||||
if (y>0.5f) y=0.5f;
|
||||
|
|
@ -290,7 +303,6 @@ void FurnaceGUI::drawOsc() {
|
|||
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);
|
||||
|
|
@ -298,8 +310,15 @@ void FurnaceGUI::drawOsc() {
|
|||
} else {
|
||||
dl->AddPolyline(waveform,oscWidth-24,color,ImDrawFlags_None,dpiScale);
|
||||
}
|
||||
*/
|
||||
//dl->AddCallback(_renderOsc,this);
|
||||
|
||||
_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];
|
||||
|
||||
dl->AddCallback(_drawOsc,&_do);
|
||||
} else {
|
||||
for (int ch=0; ch<e->getAudioDescGot().outChans; ch++) {
|
||||
for (int i=0; i<oscWidth-24; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue