*/}}
Sfoglia il codice sorgente

fixed audio logic and scope display

YimingWu 1 anno fa
parent
commit
26784763f0
2 ha cambiato i file con 6 aggiunte e 10 eliminazioni
  1. 3 3
      la_audio.c
  2. 3 7
      resources/la_widgets.c

+ 3 - 3
la_audio.c

@@ -331,14 +331,14 @@ int laEvalSynthGraphs(){
 }
 
 void laaudio_DataCallback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount){
-    float* out=pOutput; int any=0;
+    float* out=pOutput; int any=1;
     for(int i=0;i<frameCount;i++){
         if(MAIN.Audio->NextAudioSample>=LA_SYNTH_PLEN){
             MAIN.Audio->NextAudioSample=0;
-            if(laEvalSynthGraphs()){ any=1;
+            if(laEvalSynthGraphs()){
                 MAIN.Audio->AudioEvalTotalSamples+=LA_SYNTH_PLEN;
                 MAIN.Audio->AudioEvalTime=(real)MAIN.Audio->AudioEvalTotalSamples/MAIN.Audio->AudioSampleRate;
-            }
+            }else{ any=0;}
         }
         out[i]=MAIN.Audio->AudioSamples[MAIN.Audio->NextAudioSample]/10;
         MAIN.Audio->NextAudioSample++;

+ 3 - 7
resources/la_widgets.c

@@ -1557,7 +1557,7 @@ void la_ScopeDraw(laUiItem *ui, int h){
     laBoxedTheme *bt = (*ui->Type->Theme); laSynthNodeScope* s=ui->PP.EndInstance;
     if(!s) return;
     real* lcolor=laAccentColor(LA_BT_TEXT); int plen=LA_SYNTH_PLEN;
-    int cl=ui->L, cr=ui->R, cu=ui->U, cb=ui->B; real cc=(real)(cu+cb)/2;
+    int cl=ui->L+2, cr=ui->R-2, cu=ui->U+2, cb=ui->B-2; real cc=(real)(cu+cb)/2;
     real yfac1=(real)(1<<(s->Gain1+1))/4.0f, yfac2=(real)(1<<(s->Gain2+1))/4.0f; yfac1/=10; yfac2/=10;
     real off1=s->Offset1/20*(cb-cu), off2=s->Offset2/20*(cb-cu);
     real arrx[LA_SYNTH_PLEN];
@@ -1573,9 +1573,6 @@ void la_ScopeDraw(laUiItem *ui, int h){
 
     tnsFlush(); tnsLineWidth(3.0);
 
-    int sx,sy,sw,sh,vl,vr,vu,vb;
-    la_DoUiScissor(ui,&sx,&sy,&sw,&sh,&vl,&vr,&vu,&vb);
-
     pthread_spin_lock(&s->Lock);
 
     real b1=s->Brightness1, b2=s->Brightness2; real hcy[3]; tnsRGB2HCY(lcolor,hcy); hcy[2]=0.75;
@@ -1585,6 +1582,7 @@ void la_ScopeDraw(laUiItem *ui, int h){
         arrx[i]=tnsInterpolate(cl,cr,((real)i)/plen);
         arru1[i]=tnsInterpolate(cc,cb,yfac1*s->Display1[i])-off1;
         arrb1[i]=tnsInterpolate(cc,cb,yfac1*s->Display1[i+plen])-off1;
+        TNS_CLAMP(arru1[i],cu,cb); TNS_CLAMP(arrb1[i],cu,cb);
         tnsVertex2d(arrx[i],arru1[i]); tnsVertex2d(arrx[i],arrb1[i]);
     }
     tnsColor4d(LA_COLOR3(c1),b1*0.4);
@@ -1593,6 +1591,7 @@ void la_ScopeDraw(laUiItem *ui, int h){
     for(int i=0;i<plen;i++){
         arru2[i]=tnsInterpolate(cc,cb,yfac2*s->Display2[i])-off2;
         arrb2[i]=tnsInterpolate(cc,cb,yfac2*s->Display2[i+plen])-off2;
+        TNS_CLAMP(arru2[i],cu,cb); TNS_CLAMP(arrb2[i],cu,cb);
         tnsVertex2d(arrx[i],arru2[i]); tnsVertex2d(arrx[i],arrb2[i]);
     }
     tnsColor4d(LA_COLOR3(c1),b2*0.6);
@@ -1616,9 +1615,6 @@ void la_ScopeDraw(laUiItem *ui, int h){
 
     tnsFlush(); tnsLineWidth(1.0);
 
-    tnsViewportWithScissor(sx,sy,sw,sh);
-    tnsOrtho(vl,vr,vb,vu,-100,100);
-
     tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
     tnsVertex2d(ui->L,ui->U); tnsVertex2d(ui->R,ui->U);
     tnsVertex2d(ui->R,ui->B); tnsVertex2d(ui->L,ui->B);