bool EffectManager::DoEffect(const PluginID & ID, wxWindow *parent, double projectRate, TrackList *list, TrackFactory *factory, SelectedRegion *selectedRegion, bool shouldPrompt /* = true */) { this->SetSkipStateFlag(false); Effect *effect = GetEffect(ID); if (!effect) { return false; } #if defined(EXPERIMENTAL_EFFECTS_RACK) if (effect->SupportsRealtime()) { GetRack()->Add(effect); } #endif bool res = effect->DoEffect(parent, projectRate, list, factory, selectedRegion, shouldPrompt); return res; }
bool AudacityProject::ProcessEvent(wxEvent & event) { int numEffects = Effect::GetNumEffects(false); int numPlugins = Effect::GetNumEffects(true); Effect *f = NULL; if (event.GetEventType() == wxEVT_COMMAND_MENU_SELECTED) { // Builtin Effects if(event.GetId() >= FirstEffectID && event.GetId() < FirstEffectID + numEffects) { f = Effect::GetEffect(event.GetId() - FirstEffectID, false); } else if(event.GetId() >= FirstPluginID && event.GetId() < FirstPluginID + numPlugins) { f = Effect::GetEffect(event.GetId() - FirstPluginID, true); } else { if(HandleMenuEvent(event)) return true; } } if (f) { TrackListIterator iter(mTracks); VTrack *t = iter.First(); int count = 0; while (t) { if (t->GetSelected() && t->GetKind() == (VTrack::Wave)) count++; t = iter.Next(); } if (count == 0 || mViewInfo.sel0 == mViewInfo.sel1) { wxMessageBox(_("No audio data is selected.")); return true; } if (f->DoEffect(this, mTracks, mViewInfo.sel0, mViewInfo.sel1)) { PushState(_("Applied an effect.")); // maybe more specific? FixScrollbars(); mTrackPanel->Refresh(false); } else { // TODO: undo the effect if necessary? } // This indicates we handled the event. return true; } return wxFrame::ProcessEvent(event); }