Browse Source

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

master
kevin 11 years ago
parent
commit
fadafa8e6b
2 changed files with 6 additions and 1 deletions
  1. 5
    1
      cmProc3.c
  2. 1
    0
      cmProc3.h

+ 5
- 1
cmProc3.c View File

2055
     cmReal_t g = cp->gain;
2055
     cmReal_t g = cp->gain;
2056
 
2056
 
2057
     if( cp->gateFl )
2057
     if( cp->gateFl )
2058
+    {
2058
       cp->gain = cmMin(cp->gain + i_dgain,1.0); 
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
     else
2062
     else
2060
     {
2063
     {
2061
       cp->gain = cmMax(cp->gain - o_dgain,0.0); 
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
       cp->offFl = g>0.0 && cp->gain==0.0; // notice fade-out transition end
2066
       cp->offFl = g>0.0 && cp->gain==0.0; // notice fade-out transition end
2063
     }
2067
     }
2064
 
2068
 
2094
   unsigned i;
2098
   unsigned i;
2095
   for(i=0; i<chCnt; ++i)
2099
   for(i=0; i<chCnt; ++i)
2096
     if( x[i] != NULL )
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
   return rc;  
2103
   return rc;  
2100
 }
2104
 }

+ 1
- 0
cmProc3.h View File

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

Loading…
Cancel
Save