示例#1
0
void EffectManager::RealtimeSetEffects(const EffectArray & effects)
{
   // Block RealtimeProcess()
   RealtimeSuspend();

   // Tell any effects no longer in the chain to clean up
   for (auto e: mRealtimeEffects)
   {
      // Scan the NEW chain for the effect
      for (auto e1: effects)
      {
         // Found it so we're done
         if (e == e1)
         {
            e = NULL;
            break;
         }
      }

      // Must not have been in the NEW chain, so tell it to cleanup
      if (e && mRealtimeActive)
      {
         e->RealtimeFinalize();
      }
   }
      
   // Tell any NEW effects to get ready
   for (auto e : effects)
   {
      // Scan the old chain for the effect
      for (auto e1 : mRealtimeEffects)
      {
         // Found it so tell effect to get ready
         if (e == e1)
         {
            e = NULL;
            break;
         }
      }

      // Must not have been in the old chain, so tell it to initialize
      if (e && mRealtimeActive)
      {
         e->RealtimeInitialize();
      }
   }

   // And install the NEW one
   mRealtimeEffects = effects;

   // Allow RealtimeProcess() to, well, process 
   RealtimeResume();
}
示例#2
0
void EffectManager::RealtimeRemoveEffect(Effect *effect)
{
   // Block RealtimeProcess()
   RealtimeSuspend();

   if (mRealtimeActive)
   {
      // Cleanup realtime processing
      effect->RealtimeFinalize();
   }
      
   // Remove from list of active effects
   mRealtimeEffects.Remove(effect);

   // Allow RealtimeProcess() to, well, process 
   RealtimeResume();
}
示例#3
0
void EffectManager::RealtimeFinalize()
{
   // Make sure nothing is going on
   RealtimeSuspend();

   // It is now safe to clean up
   mRealtimeLatency = 0;

   // Tell each effect to clean up as well
   for (int i = 0, cnt = mRealtimeEffects.GetCount(); i < cnt; i++)
   {
      mRealtimeEffects[i]->RealtimeFinalize();
   }

   // Reset processor parameters
   mRealtimeChans.Clear();
   mRealtimeRates.Clear();

   // No longer active
   mRealtimeActive = false;
}
示例#4
0
void EffectManager::RealtimeInitialize()
{
   // The audio thread should not be running yet, but protect anyway
   RealtimeSuspend();

   // (Re)Set processor parameters
   mRealtimeChans.Clear();
   mRealtimeRates.Clear();

   // RealtimeAdd/RemoveEffect() needs to know when we're active so it can
   // initialize newly added effects
   mRealtimeActive = true;

   // Tell each effect to get ready for action
   for (int i = 0, cnt = mRealtimeEffects.GetCount(); i < cnt; i++)
   {
      mRealtimeEffects[i]->RealtimeInitialize();
   }

   // Get things moving
   RealtimeResume();
}
示例#5
0
void EffectManager::RealtimeAddEffect(Effect *effect)
{
   // Block RealtimeProcess()
   RealtimeSuspend();

   // Initialize effect if realtime is already active
   if (mRealtimeActive)
   {
      // Initialize realtime processing
      effect->RealtimeInitialize();

      // Add the required processors
      for (size_t i = 0, cnt = mRealtimeChans.GetCount(); i < cnt; i++)
      {
         effect->RealtimeAddProcessor(i, mRealtimeChans[i], mRealtimeRates[i]);
      }
   }
   
   // Add to list of active effects
   mRealtimeEffects.Add(effect);

   // Allow RealtimeProcess() to, well, process 
   RealtimeResume();
}
void EffectManager::RealtimeSetEffects(const EffectArray & effects)
{
   int newCount = (int) effects.GetCount();
   Effect **newEffects = new Effect *[newCount];
   for (int i = 0; i < newCount; i++)
   {
      newEffects[i] = effects[i];
   }

   // Block RealtimeProcess()
   RealtimeSuspend();

   // Tell any effects no longer in the chain to clean up
   for (int i = 0; i < mRealtimeCount; i++)
   {
      Effect *e = mRealtimeEffects[i];

      // Scan the NEW chain for the effect
      for (int j = 0; j < newCount; j++)
      {
         // Found it so we're done
         if (e == newEffects[j])
         {
            e = NULL;
            break;
         }
      }

      // Must not have been in the NEW chain, so tell it to cleanup
      if (e && mRealtimeActive)
      {
         e->RealtimeFinalize();
      }
   }
      
   // Tell any NEW effects to get ready
   for (int i = 0; i < newCount; i++)
   {
      Effect *e = newEffects[i];

      // Scan the old chain for the effect
      for (int j = 0; j < mRealtimeCount; j++)
      {
         // Found it so tell effect to get ready
         if (e == mRealtimeEffects[j])
         {
            e = NULL;
         }
      }

      // Must not have been in the old chain, so tell it to initialize
      if (e && mRealtimeActive)
      {
         e->RealtimeInitialize();
      }
   }

   // Get rid of the old chain
   if (mRealtimeEffects)
   {
      delete [] mRealtimeEffects;
   }

   // And install the NEW one
   mRealtimeEffects = newEffects;
   mRealtimeCount = newCount;

   // Allow RealtimeProcess() to, well, process 
   RealtimeResume();
}