Kaynağa Gözat

cmProc3.h/c : Changes to cmXFader to implement equal power cross-fade and

addition of cmXFaderJumpToDestinationGain().
master
kevin 10 yıl önce
ebeveyn
işleme
29c10b0a88
2 değiştirilmiş dosya ile 20 ekleme ve 3 silme
  1. 17
    1
      cmProc3.c
  2. 3
    2
      cmProc3.h

+ 17
- 1
cmProc3.c Dosyayı Görüntüle

@@ -2057,7 +2057,7 @@ cmRC_t    cmXfaderExec(  cmXfader* p, unsigned procSmpCnt, const bool* chGateV,
2057 2057
     if( cp->gateFl )
2058 2058
     {
2059 2059
       cp->gain = cmMin(cp->gain + i_dgain,1.0); 
2060
-      cp->ep_gain = sqrt(0.5 + 0.5 * cos(3.14159*cp->gain));
2060
+      cp->ep_gain = sqrt(0.5 - 0.5 * cos(3.14159*cp->gain));
2061 2061
     }
2062 2062
     else
2063 2063
     {
@@ -2133,6 +2133,22 @@ void      cmXfaderAllOff( cmXfader* p )
2133 2133
     p->chArray[i].gateFl = false;
2134 2134
 }
2135 2135
 
2136
+void      cmXfaderJumpToDestinationGain( cmXfader* p )
2137
+{
2138
+  unsigned i = 0;
2139
+  for(i=0; i<p->chCnt; ++i)
2140
+  {
2141
+    if( p->chArray[i].gateFl )
2142
+      p->chArray[i].gain = 1.0;
2143
+    else
2144
+      p->chArray[i].gain = 0.0;
2145
+
2146
+    p->chArray[i].onFl = false;
2147
+    p->chArray[i].offFl = false;
2148
+    p->chArray[i].ep_gain = p->chArray[i].gain;
2149
+  }
2150
+}
2151
+
2136 2152
 //==========================================================================================================================================
2137 2153
 cmFader*  cmFaderAlloc( cmCtx*c, cmFader* p, cmReal_t srate, cmReal_t fadeTimeMs  )
2138 2154
 {

+ 3
- 2
cmProc3.h Dosyayı Görüntüle

@@ -299,8 +299,8 @@ extern "C" {
299 299
   // to the audio signal - unless you use cmXfaderExecAudio()
300 300
   typedef struct
301 301
   {
302
-    cmReal_t ep_gain;
303
-    cmReal_t gain;
302
+    cmReal_t ep_gain; // equal power xfade gain
303
+    cmReal_t gain;    // linear gain
304 304
     bool     gateFl; // true if channel is on
305 305
     bool     onFl;   // true if gateFl transitioned to true on this cycle  
306 306
     bool     offFl;  // true if gateFl transitioned to false on this cycle
@@ -333,6 +333,7 @@ extern "C" {
333 333
   // Set all gates to false except chIdx.
334 334
   void      cmXfaderSelectOne( cmXfader* p, unsigned chIdx );
335 335
   void      cmXfaderAllOff( cmXfader* p );
336
+  void      cmXfaderJumpToDestinationGain( cmXfader* p ); // jump to dest. gain based on gate state
336 337
 
337 338
   //=======================================================================================================================
338 339
   // This fader object accepts a gate signal. When the gate is high it increments

Loading…
İptal
Kaydet