示例#1
0
/// HandleTextualCommand() allows us a limitted version of script/batch
/// behavior, since we can get from a string command name to the actual
/// code to run.
bool CommandManager::HandleTextualCommand(wxString & Str, wxUint32 flags, wxUint32 mask)
{
   unsigned int i;

   // Linear search for now...
   for(i=0; i<mCommandList.GetCount(); i++) {
      if (!mCommandList[i]->multi)
      {
         if( Str.IsSameAs( mCommandList[i]->name ))
         {
            return HandleCommandEntry( mCommandList[i], flags, mask);
         }
      }
   }
   // Not one of the singleton commands.
   // We could/should try all the list-style commands.
   // instead we only try the effects.
   EffectArray *effects;
   AudacityProject * proj;
   proj = GetActiveProject();
   if( !proj )
      return false;

   int effectFlags = ALL_EFFECTS | CONFIGURED_EFFECT;
   effects = EffectManager::Get().GetEffects(effectFlags);
   for(i=0; i<effects->GetCount(); i++) {
      wxString effectName = (*effects)[i]->GetEffectName();
      if( Str.IsSameAs( effectName ))
      {
         return proj->OnEffect( effectFlags, (*effects)[i] ); 
      }
   }
   return false;
}
示例#2
0
EffectArray *Effect::GetEffects(int flags /* = ALL_EFFECTS */)
{
   EffectArray *results = new EffectArray();

   int len = mEffects.GetCount();
   for(int i=0; i<len; i++) {
      int g = mEffects[i]->GetEffectFlags();
      if ((flags & g) == g)
         results->Add(mEffects[i]);
   }

   return results;
}
示例#3
0
// Gets all commands that are valid for this mode.
wxArrayString BatchCommands::GetAllCommands()
{
   wxArrayString commands;
   wxString command;
   commands.Clear();

   AudacityProject *project = GetActiveProject();
   if (!project)
      return commands;

   EffectArray * effects;
   unsigned int i;

   // CLEANSPEECH remnant
   for(i=0;i<sizeof(SpecialCommands)/sizeof(SpecialCommands[0]);i++)
   {
      commands.Add( SpecialCommands[i] );
   }
   // end CLEANSPEECH remnant
   
   int additionalEffects=ADVANCED_EFFECT;
#ifdef CLEANSPEECH
   if( project->GetCleanSpeechMode() )
       additionalEffects = 0;
#endif   // CLEANSPEECH

   effects = EffectManager::Get().GetEffects(PROCESS_EFFECT | BUILTIN_EFFECT | PLUGIN_EFFECT | additionalEffects);
   for(i=0; i<effects->GetCount(); i++) {
      if ((*effects)[i]->SupportsChains()) {
         command=(*effects)[i]->GetEffectIdentifier();
         if (!command.IsEmpty()) {
            commands.Add( command);
         }
      }
   }
   delete effects;

   /* This is for later in development: include the menu commands.
         CommandManager * mManager = project->GetCommandManager();
         wxArrayString mNames;
         mNames.Clear();
         mManager->GetAllCommandNames(mNames, false);
         for(i=0; i<mNames.GetCount(); i++) {
            commands.Add( mNames[i] );
         }
   */
   return commands;
}
示例#4
0
Effect * BatchCommands::GetEffectFromCommandName(wxString inCommand)
{
   unsigned int i;
   wxString command;
   Effect * f;
   EffectArray * effects = Effect::GetEffects( ALL_EFFECTS );
   for(i=0; i<effects->GetCount(); i++) {
      f = (*effects)[i];
      command=f->GetEffectName();
      command.Replace( wxT("..."), wxT(""));
      if( command.IsSameAs( inCommand ))
      {  
         delete effects;
         return f;
      }
   }
   delete effects;
   return NULL;
}
示例#5
0
// Gets all commands that are valid for this mode.
wxArrayString BatchCommands::GetAllCommands()
{
   wxArrayString commands;
   wxString command;
   commands.Clear();

   AudacityProject *project = GetActiveProject();
   if (!project)
      return commands;

   EffectArray * effects;
   unsigned int i;

   for(i=0;i<sizeof(SpecialCommands)/sizeof(SpecialCommands[0]);i++)
   {
      commands.Add( SpecialCommands[i] );
   }
   
   int additionalEffects=ADVANCED_EFFECT;
   if( project->GetCleanSpeechMode() )
       additionalEffects = 0;
   effects = Effect::GetEffects(PROCESS_EFFECT | BUILTIN_EFFECT | additionalEffects);
   for(i=0; i<effects->GetCount(); i++) {
      command=(*effects)[i]->GetEffectName();
      command.Replace( wxT("..."), wxT(""));
      commands.Add( command);
   }
   delete effects;

/* This is for later in development: include the menu commands.
   CommandManager * mManager = project->GetCommandManager();
   wxArrayString mNames;
   mNames.Clear();
   mManager->GetAllCommandNames(mNames, false);
   for(i=0; i<mNames.GetCount(); i++) {
      commands.Add( mNames[i] );
   }
*/
   return commands;
}
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();
}