Ver código fonte

cmProc3.h : Added equal power cross fade to XFader object.

master
kevin 11 anos atrás
pai
commit
fadafa8e6b
2 arquivos alterados com 6 adições e 1 exclusões
  1. 5
    1
      cmProc3.c
  2. 1
    0
      cmProc3.h

+ 5
- 1
cmProc3.c Ver arquivo

@@ -2055,10 +2055,14 @@ cmRC_t    cmXfaderExec(  cmXfader* p, unsigned procSmpCnt, const bool* chGateV,
2055 2055
     cmReal_t g = cp->gain;
2056 2056
 
2057 2057
     if( cp->gateFl )
2058
+    {
2058 2059
       cp->gain = cmMin(cp->gain + i_dgain,1.0); 
2060
+      cp->ep_gain = sqrt(0.5 + 0.5 * cos(3.14159*cp->gain));
2061
+    }
2059 2062
     else
2060 2063
     {
2061 2064
       cp->gain = cmMax(cp->gain - o_dgain,0.0); 
2065
+      cp->ep_gain = sqrt(0.5 - 0.5 * cos(3.14159*cp->gain));
2062 2066
       cp->offFl = g>0.0 && cp->gain==0.0; // notice fade-out transition end
2063 2067
     }
2064 2068
 
@@ -2094,7 +2098,7 @@ cmRC_t    cmXfaderExecAudio( cmXfader* p, unsigned procSmpCnt, const bool* gateV
2094 2098
   unsigned i;
2095 2099
   for(i=0; i<chCnt; ++i)
2096 2100
     if( x[i] != NULL )
2097
-      cmVOS_MultVaVS(y,procSmpCnt,x[i],p->chArray[i].gain);
2101
+      cmVOS_MultVaVS(y,procSmpCnt,x[i],p->chArray[i].ep_gain);
2098 2102
 
2099 2103
   return rc;  
2100 2104
 }

+ 1
- 0
cmProc3.h Ver arquivo

@@ -299,6 +299,7 @@ extern "C" {
299 299
   // to the audio signal - unless you use cmXfaderExecAudio()
300 300
   typedef struct
301 301
   {
302
+    cmReal_t ep_gain;
302 303
     cmReal_t gain;
303 304
     bool     gateFl; // true if channel is on
304 305
     bool     onFl;   // true if gateFl transitioned to true on this cycle  

Carregando…
Cancelar
Salvar