Audacity  2.2.2
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
Effect Class Reference

Base class for many of the effects in Audacity. More...

#include <Effect.h>

Inheritance diagram for Effect:
EffectClientInterface EffectUIClientInterface EffectHostInterface EffectDefinitionInterface ConfigClientInterface IdentInterface ParamsInterface EffectAmplify EffectAutoDuck EffectBassTreble EffectChangeSpeed EffectClickRemoval EffectDistortion EffectDtmf EffectEcho EffectEqualization EffectFade EffectFindClipping EffectInvert EffectNoise EffectNoiseReduction EffectNormalize EffectPaulstretch EffectPhaser EffectRepair EffectRepeat EffectReverb EffectReverse EffectScienFilter EffectSimpleMono EffectStereoToMono EffectToneGen EffectTruncSilence EffectTwoPassSimpleMono EffectWahwah Generator NyquistEffect

Classes

class  AddedAnalysisTrack
 
class  ModifiedAnalysisTrack
 

Public Types

enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 

Public Member Functions

 Effect ()
 
virtual ~Effect ()
 
wxString GetPath () override
 
IdentInterfaceSymbol GetSymbol () override
 
IdentInterfaceSymbol GetVendor () override
 
wxString GetVersion () override
 
wxString GetDescription () override
 
EffectType GetType () override
 
IdentInterfaceSymbol GetFamilyId () override
 
bool IsInteractive () override
 
bool IsDefault () override
 
bool IsLegacy () override
 
bool SupportsRealtime () override
 
bool SupportsAutomation () override
 
bool SetHost (EffectHostInterface *host) override
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
int GetMidiInCount () override
 
int GetMidiOutCount () override
 
sampleCount GetLatency () override
 
size_t GetTailSize () override
 
void SetSampleRate (double rate) override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
bool IsReady () override
 
bool ProcessInitialize (sampleCount totalLen, ChannelNames chanMap=NULL) override
 
bool ProcessFinalize () override
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 
bool RealtimeInitialize () override
 
bool RealtimeAddProcessor (unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize () override
 
bool RealtimeSuspend () override
 
bool RealtimeResume () override
 
bool RealtimeProcessStart () override
 
size_t RealtimeProcess (int group, float **inbuf, float **outbuf, size_t numSamples) override
 
bool RealtimeProcessEnd () override
 
bool ShowInterface (wxWindow *parent, bool forceModal=false) override
 
bool GetAutomationParameters (CommandParameters &parms) override
 
bool SetAutomationParameters (CommandParameters &parms) override
 
bool LoadUserPreset (const wxString &name) override
 
bool SaveUserPreset (const wxString &name) override
 
wxArrayString GetFactoryPresets () override
 
bool LoadFactoryPreset (int id) override
 
bool LoadFactoryDefaults () override
 
void SetHostUI (EffectUIHostInterface *host) override
 
bool PopulateUI (wxWindow *parent) override
 
bool IsGraphicalUI () override
 
bool ValidateUI () override
 
bool HideUI () override
 
bool CloseUI () override
 
bool CanExportPresets () override
 
void ExportPresets () override
 
void ImportPresets () override
 
bool HasOptions () override
 
void ShowOptions () override
 
double GetDefaultDuration () override
 
double GetDuration () override
 
NumericFormatId GetDurationFormat () override
 
virtual NumericFormatId GetSelectionFormat ()
 
void SetDuration (double duration) override
 
bool Apply () override
 
void Preview () override
 
wxDialog * CreateUI (wxWindow *parent, EffectUIClientInterface *client) override
 
wxString GetUserPresetsGroup (const wxString &name) override
 
wxString GetCurrentSettingsGroup () override
 
wxString GetFactoryDefaultsGroup () override
 
virtual wxString GetSavedStateGroup ()
 
bool HasSharedConfigGroup (const wxString &group) override
 
bool GetSharedConfigSubgroups (const wxString &group, wxArrayString &subgroups) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, wxString &value, const wxString &defval=wxEmptyString) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, int &value, int defval=0) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, bool &value, bool defval=false) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, float &value, float defval=0.0) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, double &value, double defval=0.0) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const wxString &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const int &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const bool &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const float &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const double &value) override
 
bool RemoveSharedConfigSubgroup (const wxString &group) override
 
bool RemoveSharedConfig (const wxString &group, const wxString &key) override
 
bool HasPrivateConfigGroup (const wxString &group) override
 
bool GetPrivateConfigSubgroups (const wxString &group, wxArrayString &subgroups) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, wxString &value, const wxString &defval=wxEmptyString) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, int &value, int defval=0) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, bool &value, bool defval=false) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, float &value, float defval=0.0) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, double &value, double defval=0.0) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const wxString &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const int &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const bool &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const float &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const double &value) override
 
bool RemovePrivateConfigSubgroup (const wxString &group) override
 
bool RemovePrivateConfig (const wxString &group, const wxString &key) override
 
virtual PluginID GetID ()
 
virtual bool Startup (EffectClientInterface *client)
 
virtual bool Startup ()
 
virtual bool GetAutomationParameters (wxString &parms)
 
virtual bool SetAutomationParameters (const wxString &parms)
 
virtual wxArrayString GetUserPresets ()
 
virtual bool HasCurrentSettings ()
 
virtual bool HasFactoryDefaults ()
 
virtual wxString GetPreset (wxWindow *parent, const wxString &parms)
 
virtual wxString ManualPage ()
 
virtual wxString HelpPage ()
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
void SetPresetParameters (const wxArrayString *Names, const wxArrayString *Values)
 
bool DoEffect (wxWindow *parent, double projectRate, TrackList *list, TrackFactory *factory, SelectedRegion *selectedRegion, bool shouldPrompt=true)
 
bool Delegate (Effect &delegate, wxWindow *parent, bool shouldPrompt)
 
bool RealtimeAddProcessor (int group, unsigned chans, float rate)
 
size_t RealtimeProcess (int group, unsigned chans, float **inbuf, float **outbuf, size_t numSamples)
 
bool IsRealtimeActive ()
 
virtual bool IsHidden ()
 
int MessageBox (const wxString &message, long style=DefaultMessageBoxStyle, const wxString &titleStr=wxString{})
 
- Public Member Functions inherited from EffectClientInterface
virtual ~EffectClientInterface ()
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
- Public Member Functions inherited from IdentInterface
virtual ~IdentInterface ()
 
const wxString & GetTranslatedName ()
 
- Public Member Functions inherited from ParamsInterface
virtual ~ParamsInterface ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
- Public Member Functions inherited from EffectHostInterface
virtual ~EffectHostInterface ()
 
- Public Member Functions inherited from ConfigClientInterface
virtual ~ConfigClientInterface ()
 

Protected Member Functions

virtual bool Init ()
 
virtual bool PromptUser (wxWindow *parent)
 
virtual bool CheckWhetherSkipEffect ()
 
virtual bool Process ()
 
virtual bool ProcessPass ()
 
virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual int GetPass ()
 
virtual void End ()
 
virtual double CalcPreviewInputLength (double previewLength)
 
virtual void Preview (bool dryOnly)
 
virtual void PopulateOrExchange (ShuttleGui &S)
 
virtual bool TransferDataToWindow ()
 
virtual bool TransferDataFromWindow ()
 
virtual bool EnableApply (bool enable=true)
 
virtual bool EnablePreview (bool enable=true)
 
virtual void EnableDebug (bool enable=true)
 
bool TotalProgress (double frac)
 
bool TrackProgress (int whichTrack, double frac, const wxString &=wxEmptyString)
 
bool TrackGroupProgress (int whichGroup, double frac, const wxString &=wxEmptyString)
 
int GetNumWaveTracks ()
 
int GetNumWaveGroups ()
 
void GetSamples (const WaveTrack *track, sampleCount *start, sampleCount *len)
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing ()
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void CopyInputTracks ()
 
void CopyInputTracks (int trackType)
 
std::shared_ptr
< AddedAnalysisTrack
AddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
TrackAddToOutputTracks (std::unique_ptr< Track > &&t)
 
TrackListinputTracks () const
 

Protected Attributes

ProgressDialogmProgress
 
double mProjectRate
 
double mSampleRate
 
SelectedRegionmpSelectedRegion {}
 
TrackFactorymFactory
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0
 
double mT1
 
double mF0
 
double mF1
 
wxArrayString mPresetNames
 
wxArrayString mPresetValues
 
int mPass
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 
int mUIResultID
 
sampleCount mSampleCnt
 
int mOutputTracksType
 

Private Member Functions

void CommonInit ()
 
void CountWaveTracks ()
 
bool ProcessTrack (int count, ChannelNames map, WaveTrack *left, WaveTrack *right, sampleCount leftStart, sampleCount rightStart, sampleCount len, FloatBuffers &inBuffer, FloatBuffers &outBuffer, ArrayOf< float * > &inBufPos, ArrayOf< float * > &outBufPos)
 

Private Attributes

TrackListmTracks
 
bool mIsBatch
 
bool mIsLinearEffect
 
bool mPreviewWithNotSelected
 
bool mPreviewFullSelection
 
bool mIsSelection
 
double mDuration
 
NumericFormatId mDurationFormat
 
bool mIsPreview
 
bool mUIDebug
 
std::vector< Track * > mIMap
 
std::vector< Track * > mOMap
 
int mNumTracks
 
int mNumGroups
 
EffectClientInterfacemClient
 
size_t mNumAudioIn
 
size_t mNumAudioOut
 
size_t mBufferSize
 
size_t mBlockSize
 
unsigned mNumChannels
 
std::vector< int > mGroupProcessor
 
int mCurrentProcessor
 
wxCriticalSection mRealtimeSuspendLock
 
int mRealtimeSuspendCount
 

Static Private Attributes

static const wxString kUserPresetIdent = wxT("User Preset:")
 
static const wxString kFactoryPresetIdent = wxT("Factory Preset:")
 
static const wxString kCurrentSettingsIdent = wxT("<Current Settings>")
 
static const wxString kFactoryDefaultsIdent = wxT("<Factory Defaults>")
 

Friends

class EffectManager
 
class EffectRack
 
class EffectUIHost
 
class EffectPresetsDialog
 

Detailed Description

Base class for many of the effects in Audacity.

Definition at line 62 of file Effect.h.

Member Enumeration Documentation

anonymous enum : long
Enumerator
DefaultMessageBoxStyle 

Definition at line 268 of file Effect.h.

268 : long { DefaultMessageBoxStyle = wxOK | wxCENTRE };

Constructor & Destructor Documentation

Effect::Effect ( )

Definition at line 99 of file Effect.cpp.

References GetActiveProject(), AudacityProject::GetRate(), mBlockSize, mBufferSize, mClient, mDuration, mIsBatch, mIsLinearEffect, mIsPreview, mNumAudioIn, mNumAudioOut, mNumChannels, mNumGroups, mNumTracks, mOutputTracksType, mPreviewFullSelection, mPreviewWithNotSelected, mProgress, mProjectRate, mRealtimeSuspendCount, mRealtimeSuspendLock, mT0, mT1, mTracks, mUIDebug, mUIDialog, mUIParent, and Track::None.

100 {
101  mClient = NULL;
102 
103  mTracks = NULL;
105  mT0 = 0.0;
106  mT1 = 0.0;
107  mDuration = 0.0;
108  mIsPreview = false;
109  mIsLinearEffect = false;
110  mPreviewWithNotSelected = false;
111  mPreviewFullSelection = false;
112  mNumTracks = 0;
113  mNumGroups = 0;
114  mProgress = NULL;
115 
116  mRealtimeSuspendLock.Enter();
117  mRealtimeSuspendCount = 1; // Effects are initially suspended
118  mRealtimeSuspendLock.Leave();
119 
120  mUIParent = NULL;
121  mUIDialog = NULL;
122 
123  mNumAudioIn = 0;
124  mNumAudioOut = 0;
125 
126  mBufferSize = 0;
127  mBlockSize = 0;
128  mNumChannels = 0;
129 
130  mUIDebug = false;
131 
133  mProjectRate = p ? p->GetRate() : 44100;
134 
135  mIsBatch = false;
136 }
double mT1
Definition: Effect.h:461
ProgressDialog * mProgress
Definition: Effect.h:452
TrackList * mTracks
Definition: Effect.h:505
int mOutputTracksType
Definition: Effect.h:478
bool mPreviewFullSelection
Definition: Effect.h:510
bool mIsPreview
Definition: Effect.h:516
EffectClientInterface * mClient
Definition: Effect.h:527
size_t mBufferSize
Definition: Effect.h:531
size_t mNumAudioIn
Definition: Effect.h:528
wxCriticalSection mRealtimeSuspendLock
Definition: Effect.h:538
size_t mNumAudioOut
Definition: Effect.h:529
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
size_t mBlockSize
Definition: Effect.h:532
int mNumTracks
Definition: Effect.h:523
bool mIsLinearEffect
Definition: Effect.h:508
int mRealtimeSuspendCount
Definition: Effect.h:539
bool mPreviewWithNotSelected
Definition: Effect.h:509
wxWindow * mUIParent
Definition: Effect.h:472
double mProjectRate
Definition: Effect.h:453
unsigned mNumChannels
Definition: Effect.h:533
wxDialog * mUIDialog
Definition: Effect.h:471
bool mUIDebug
Definition: Effect.h:518
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
double mDuration
Definition: Effect.h:513
double GetRate() const
Definition: Project.h:199
bool mIsBatch
Definition: Effect.h:507
double mT0
Definition: Effect.h:460
int mNumGroups
Definition: Effect.h:524
Effect::~Effect ( )
virtual

Definition at line 138 of file Effect.cpp.

References mUIDialog.

139 {
140  if (mUIDialog)
141  {
142  mUIDialog->Close();
143  }
144 }
wxDialog * mUIDialog
Definition: Effect.h:471

Member Function Documentation

auto Effect::AddAnalysisTrack ( const wxString &  name = wxString())
protected

Definition at line 2104 of file Effect.cpp.

References name, and safenew.

Referenced by EffectFindClipping::Process().

2105 {
2106  return std::shared_ptr<AddedAnalysisTrack>
2107  { safenew AddedAnalysisTrack{ this, name } };
2108 }
#define safenew
Definition: Audacity.h:230
const wxChar * name
Definition: Distortion.cpp:94
Track * Effect::AddToOutputTracks ( std::unique_ptr< Track > &&  t)
protected

Definition at line 2067 of file Effect.cpp.

References mIMap, mOMap, and mOutputTracks.

Referenced by NyquistEffect::ProcessOne().

2068 {
2069  mIMap.push_back(NULL);
2070  mOMap.push_back(t.get());
2071  return mOutputTracks->Add(std::move(t));
2072 }
std::vector< Track * > mOMap
Definition: Effect.h:521
std::vector< Track * > mIMap
Definition: Effect.h:520
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:459
bool Effect::Apply ( )
overridevirtual

Implements EffectHostInterface.

Definition at line 761 of file Effect.cpp.

References AudacityProject::DoEffect(), GetActiveProject(), GetID(), and AudacityProject::OnEffectFlags::kConfigured.

Referenced by EffectUIHost::OnApply().

762 {
763  CommandContext context( *GetActiveProject() );
764  // This is absolute hackage...but easy and I can't think of another way just now.
765  //
766  // It should callback to the EffectManager to kick off the processing
767  return GetActiveProject()->DoEffect(GetID(), context,
769 }
static const int kConfigured
Definition: Project.h:493
bool DoEffect(const PluginID &ID, const CommandContext &context, int flags)
Definition: Menus.cpp:4531
virtual PluginID GetID()
Definition: Effect.cpp:959
CommandContext provides addiitonal information to an 'Apply()' command. It provides the project...
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
double Effect::CalcPreviewInputLength ( double  previewLength)
protectedvirtual

Reimplemented in EffectTruncSilence, EffectChangeSpeed, and EffectPaulstretch.

Definition at line 2274 of file Effect.cpp.

Referenced by Preview(), and ProcessTrack().

2275 {
2276  return previewLength;
2277 }
bool Effect::CanExportPresets ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 693 of file Effect.cpp.

694 {
695  return false;
696 }
virtual bool Effect::CheckWhetherSkipEffect ( )
inlineprotectedvirtual

Reimplemented in NyquistEffect, EffectBassTreble, EffectChangeSpeed, EffectClickRemoval, EffectNormalize, and EffectNoiseReduction.

Definition at line 297 of file Effect.h.

Referenced by DoEffect().

297 { return false; }
bool Effect::CloseUI ( )
overridevirtual

Implements EffectUIClientInterface.

Reimplemented in EffectEqualization.

Definition at line 682 of file Effect.cpp.

References mUIDialog, and mUIParent.

Referenced by EffectEqualization::CloseUI().

683 {
684  if (mUIParent)
685  mUIParent->RemoveEventHandler(this);
686 
687  mUIParent = NULL;
688  mUIDialog = NULL;
689 
690  return true;
691 }
wxWindow * mUIParent
Definition: Effect.h:472
wxDialog * mUIDialog
Definition: Effect.h:471
void Effect::CommonInit ( )
private
void Effect::CopyInputTracks ( )
protected
void Effect::CopyInputTracks ( int  trackType)
protected

Definition at line 2041 of file Effect.cpp.

References Track::All, TrackList::Create(), TrackListCondIterator::First(), mIMap, mOMap, mOutputTracks, mOutputTracksType, mTracks, and TrackListCondIterator::Next().

2042 {
2043  // Reset map
2044  mIMap.clear();
2045  mOMap.clear();
2046 
2048  mOutputTracksType = trackType;
2049 
2050  //iterate over tracks of type trackType (All types if Track::All)
2051  TrackListOfKindIterator aIt(trackType, mTracks);
2052  t2bHash added;
2053 
2054  for (Track *aTrack = aIt.First(); aTrack; aTrack = aIt.Next())
2055  {
2056  // Include selected tracks, plus sync-lock selected tracks for Track::All.
2057  if (aTrack->GetSelected() ||
2058  (trackType == Track::All && aTrack->IsSyncLockSelected()))
2059  {
2060  Track *o = mOutputTracks->Add(aTrack->Duplicate());
2061  mIMap.push_back(aTrack);
2062  mOMap.push_back(o);
2063  }
2064  }
2065 }
std::unordered_map< void *, bool > t2bHash
Definition: Effect.cpp:97
TrackList * mTracks
Definition: Effect.h:505
int mOutputTracksType
Definition: Effect.h:478
static std::shared_ptr< TrackList > Create()
Definition: Track.cpp:792
std::vector< Track * > mOMap
Definition: Effect.h:521
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
std::vector< Track * > mIMap
Definition: Effect.h:520
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:459
void Effect::CountWaveTracks ( )
private

Definition at line 2251 of file Effect.cpp.

References TrackListCondIterator::First(), Track::GetKind(), Track::GetLinked(), Track::GetSelected(), mNumGroups, mNumTracks, mTracks, TrackListCondIterator::Next(), and Track::Wave.

Referenced by DoEffect(), and Preview().

2252 {
2253  mNumTracks = 0;
2254  mNumGroups = 0;
2255 
2257  Track *t = iter.First();
2258 
2259  while(t) {
2260  if (!t->GetSelected()) {
2261  t = iter.Next();
2262  continue;
2263  }
2264 
2265  if (t->GetKind() == Track::Wave) {
2266  mNumTracks++;
2267  if (!t->GetLinked())
2268  mNumGroups++;
2269  }
2270  t = iter.Next();
2271  }
2272 }
TrackList * mTracks
Definition: Effect.h:505
bool GetSelected() const
Definition: Track.h:276
bool GetLinked() const
Definition: Track.h:279
virtual int GetKind() const
Definition: Track.h:330
int mNumTracks
Definition: Effect.h:523
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
int mNumGroups
Definition: Effect.h:524
wxDialog * Effect::CreateUI ( wxWindow *  parent,
EffectUIClientInterface client 
)
overridevirtual

Implements EffectHostInterface.

Definition at line 776 of file Effect.cpp.

References safenew.

Referenced by ShowInterface().

777 {
779  { safenew EffectUIHost{ parent, this, client} };
780 
781  if (dlg->Initialize())
782  {
783  // release() is safe because parent will own it
784  return dlg.release();
785  }
786 
787  return NULL;
788 }
#define safenew
Definition: Audacity.h:230
std::unique_ptr< T, Destroyer< T >> Destroy_ptr
Definition: MemoryX.h:433
bool Effect::Delegate ( Effect delegate,
wxWindow *  parent,
bool  shouldPrompt 
)

Definition at line 1257 of file Effect.cpp.

References DoEffect(), mFactory, mProjectRate, mpSelectedRegion, and mTracks.

Referenced by NyquistEffect::ShowInterface().

1258 {
1259  return delegate.DoEffect( parent, mProjectRate, mTracks, mFactory,
1260  mpSelectedRegion, shouldPrompt );
1261 }
TrackList * mTracks
Definition: Effect.h:505
bool DoEffect(wxWindow *parent, double projectRate, TrackList *list, TrackFactory *factory, SelectedRegion *selectedRegion, bool shouldPrompt=true)
Definition: Effect.cpp:1156
double mProjectRate
Definition: Effect.h:453
TrackFactory * mFactory
Definition: Effect.h:457
SelectedRegion * mpSelectedRegion
Definition: Effect.h:456
bool Effect::DoEffect ( wxWindow *  parent,
double  projectRate,
TrackList list,
TrackFactory factory,
SelectedRegion selectedRegion,
bool  shouldPrompt = true 
)

Definition at line 1156 of file Effect.cpp.

References _(), CheckWhetherSkipEffect(), CountWaveTracks(), NumericConverter::DefaultSelectionFormat(), SelectedRegion::duration(), EffectTypeGenerate, End(), SelectedRegion::f0(), SelectedRegion::f1(), GetCurrentSettingsGroup(), GetDefaultDuration(), GetPrivateConfig(), IdentInterface::GetTranslatedName(), GetType(), Init(), IsInteractive(), mDuration, mDurationFormat, mF0, mF1, mFactory, mOutputTracks, mProgress, mProjectRate, mpSelectedRegion, mT0, mT1, mTracks, name, pdlgHideStopButton, Process(), PromptUser(), QUANTIZED_TIME, ReplaceProcessedTracks(), SetPresetParameters(), SelectedRegion::setTimes(), SelectedRegion::t0(), SelectedRegion::t1(), NumericConverter::TimeAndSampleFormat(), SelectedRegion::UndefinedFrequency, and valueRestorer().

Referenced by Delegate(), and EffectManager::DoEffect().

1162 {
1163  wxASSERT(selectedRegion->duration() >= 0.0);
1164 
1165  mOutputTracks.reset();
1166 
1167  mpSelectedRegion = selectedRegion;
1168  mFactory = factory;
1169  mProjectRate = projectRate;
1170  mTracks = list;
1171 
1172  bool isSelection = false;
1173 
1174  mDuration = 0.0;
1175 
1176  if (GetType() == EffectTypeGenerate)
1177  {
1178  GetPrivateConfig(GetCurrentSettingsGroup(), wxT("LastUsedDuration"), mDuration, GetDefaultDuration());
1179  }
1180 
1181  mT0 = selectedRegion->t0();
1182  mT1 = selectedRegion->t1();
1183  if (mT1 > mT0)
1184  {
1185  // there is a selection: let's fit in there...
1186  // MJS: note that this is just for the TTC and is independent of the track rate
1187  // but we do need to make sure we have the right number of samples at the project rate
1188  double quantMT0 = QUANTIZED_TIME(mT0, mProjectRate);
1189  double quantMT1 = QUANTIZED_TIME(mT1, mProjectRate);
1190  mDuration = quantMT1 - quantMT0;
1191  mT1 = mT0 + mDuration;
1192 
1193  isSelection = true;
1194  }
1195 
1196  mDurationFormat = isSelection
1198  : NumericConverter::DefaultSelectionFormat();
1199 
1200 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
1201  mF0 = selectedRegion->f0();
1202  mF1 = selectedRegion->f1();
1203  wxArrayString Names;
1205  Names.Add(wxT("control-f0"));
1207  Names.Add(wxT("control-f1"));
1208  SetPresetParameters( &Names, NULL );
1209 
1210 #endif
1211  CountWaveTracks();
1212 
1213  // Note: Init may read parameters from preferences
1214  if (!Init())
1215  {
1216  return false;
1217  }
1218 
1219  // Prompting will be bypassed when applying an effect that has already
1220  // been configured, e.g. repeating the last effect on a different selection.
1221  // Prompting may call Effect::Preview
1222  if (shouldPrompt && IsInteractive() && !PromptUser(parent))
1223  {
1224  return false;
1225  }
1226 
1227  auto cleanup = finally( [&] {
1228  End();
1229 
1230  // In case of failed effect, be sure to free memory.
1231  ReplaceProcessedTracks( false );
1232  } );
1233 
1234  bool returnVal = true;
1235  bool skipFlag = CheckWhetherSkipEffect();
1236  if (skipFlag == false)
1237  {
1238  auto name = GetTranslatedName();
1239  ProgressDialog progress{
1240  name,
1241  wxString::Format(_("Applying %s..."), name),
1243  };
1244  auto vr = valueRestorer( mProgress, &progress );
1245 
1246  returnVal = Process();
1247  }
1248 
1249  if (returnVal)
1250  {
1251  selectedRegion->setTimes(mT0, mT1);
1252  }
1253 
1254  return returnVal;
1255 }
double mT1
Definition: Effect.h:461
void CountWaveTracks()
Definition: Effect.cpp:2251
double t0() const
ProgressDialog Class.
ProgressDialog * mProgress
Definition: Effect.h:452
TrackList * mTracks
Definition: Effect.h:505
bool GetPrivateConfig(const wxString &group, const wxString &key, wxString &value, const wxString &defval=wxEmptyString) override
Definition: Effect.cpp:897
wxString GetCurrentSettingsGroup() override
Definition: Effect.cpp:801
virtual bool Init()
Definition: Effect.cpp:1264
#define QUANTIZED_TIME(time, rate)
Definition: Audacity.h:214
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2162
void SetPresetParameters(const wxArrayString *Names, const wxArrayString *Values)
Definition: Effect.h:240
virtual bool Process()
Definition: Effect.cpp:1290
double t1() const
static NumericFormatId TimeAndSampleFormat()
double mF0
Definition: Effect.h:463
double f0() const
EffectType GetType() override
Definition: Effect.cpp:148
NumericConverter provides the advanced formatting control used in the selection bar of Audacity...
virtual void End()
Definition: Effect.cpp:1867
double GetDefaultDuration() override
Definition: Effect.cpp:717
bool IsInteractive() override
Definition: Effect.cpp:220
const wxString & GetTranslatedName()
double mProjectRate
Definition: Effect.h:453
bool setTimes(double t0, double t1)
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
TrackFactory * mFactory
Definition: Effect.h:457
ValueRestorer< T > valueRestorer(T &var)
Definition: MemoryX.h:494
const wxChar * name
Definition: Distortion.cpp:94
NumericFormatId mDurationFormat
Definition: Effect.h:514
SelectedRegion * mpSelectedRegion
Definition: Effect.h:456
double f1() const
double mDuration
Definition: Effect.h:513
double mF1
Definition: Effect.h:464
double duration() const
virtual bool PromptUser(wxWindow *parent)
Definition: Effect.cpp:1270
static const int UndefinedFrequency
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:459
virtual bool CheckWhetherSkipEffect()
Definition: Effect.h:297
double mT0
Definition: Effect.h:460
bool Effect::EnableApply ( bool  enable = true)
protectedvirtual

Definition at line 1886 of file Effect.cpp.

References EnablePreview(), mUIDialog, and mUIParent.

Referenced by EffectAmplify::CheckClip(), EffectRepeat::DisplayNewTime(), EffectAmplify::OnAmpText(), EffectBassTreble::OnBassSlider(), EffectBassTreble::OnBassText(), EffectTruncSilence::OnControlChange(), EffectToneGen::OnControlUpdate(), EffectScienFilter::OnCutoff(), EffectWahwah::OnDepthSlider(), EffectPhaser::OnDepthSlider(), EffectWahwah::OnDepthText(), EffectPhaser::OnDepthText(), EffectPhaser::OnDryWetSlider(), EffectPhaser::OnDryWetText(), EffectPhaser::OnFeedbackSlider(), EffectPhaser::OnFeedbackText(), EffectWahwah::OnFreqOffSlider(), EffectWahwah::OnFreqOffText(), EffectWahwah::OnFreqSlider(), EffectPhaser::OnFreqSlider(), EffectWahwah::OnFreqText(), EffectPhaser::OnFreqText(), EffectWahwah::OnGainSlider(), EffectPhaser::OnGainSlider(), EffectBassTreble::OnGainSlider(), EffectBassTreble::OnGainText(), EffectWahwah::OnGainText(), EffectPhaser::OnGainText(), EffectAmplify::OnPeakText(), EffectWahwah::OnPhaseSlider(), EffectPhaser::OnPhaseSlider(), EffectWahwah::OnPhaseText(), EffectPhaser::OnPhaseText(), EffectWahwah::OnResonanceSlider(), EffectWahwah::OnResonanceText(), EffectScienFilter::OnRipple(), EffectPhaser::OnStagesSlider(), EffectPhaser::OnStagesText(), EffectScienFilter::OnStopbandRipple(), EffectPaulstretch::OnText(), EffectBassTreble::OnTrebleSlider(), EffectBassTreble::OnTrebleText(), EffectNormalize::UpdateUI(), and EffectChangeSpeed::UpdateUI().

1887 {
1888  // May be called during initialization, so try to find the dialog
1889  wxWindow *dlg = mUIDialog;
1890  if (!dlg && mUIParent)
1891  {
1892  dlg = wxGetTopLevelParent(mUIParent);
1893  }
1894 
1895  if (dlg)
1896  {
1897  wxWindow *apply = dlg->FindWindow(wxID_APPLY);
1898 
1899  // Don't allow focus to get trapped
1900  if (!enable)
1901  {
1902  wxWindow *focus = dlg->FindFocus();
1903  if (focus == apply)
1904  {
1905  dlg->FindWindow(wxID_CLOSE)->SetFocus();
1906  }
1907  }
1908 
1909  apply->Enable(enable);
1910  }
1911 
1912  EnablePreview(enable);
1913 
1914  return enable;
1915 }
wxWindow * mUIParent
Definition: Effect.h:472
wxDialog * mUIDialog
Definition: Effect.h:471
virtual bool EnablePreview(bool enable=true)
Definition: Effect.cpp:1917
void Effect::EnableDebug ( bool  enable = true)
protectedvirtual

Definition at line 1956 of file Effect.cpp.

References mUIDebug.

Referenced by NyquistEffect::PopulateOrExchange().

1957 {
1958  mUIDebug = enable;
1959 }
bool mUIDebug
Definition: Effect.h:518
bool Effect::EnablePreview ( bool  enable = true)
protectedvirtual

Definition at line 1917 of file Effect.cpp.

References kFFwdID, kPlayID, kRewindID, mUIDialog, mUIParent, and SupportsRealtime().

Referenced by EnableApply(), and NyquistEffect::TransferDataToWindow().

1918 {
1919  // May be called during initialization, so try to find the dialog
1920  wxWindow *dlg = mUIDialog;
1921  if (!dlg && mUIParent)
1922  {
1923  dlg = wxGetTopLevelParent(mUIParent);
1924  }
1925 
1926  if (dlg)
1927  {
1928  wxWindow *play = dlg->FindWindow(kPlayID);
1929  if (play)
1930  {
1931  wxWindow *rewind = dlg->FindWindow(kRewindID);
1932  wxWindow *ffwd = dlg->FindWindow(kFFwdID);
1933 
1934  // Don't allow focus to get trapped
1935  if (!enable)
1936  {
1937  wxWindow *focus = dlg->FindFocus();
1938  if (focus && (focus == play || focus == rewind || focus == ffwd))
1939  {
1940  dlg->FindWindow(wxID_CLOSE)->SetFocus();
1941  }
1942  }
1943 
1944  play->Enable(enable);
1945  if (SupportsRealtime())
1946  {
1947  rewind->Enable(enable);
1948  ffwd->Enable(enable);
1949  }
1950  }
1951  }
1952 
1953  return enable;
1954 }
static const int kPlayID
Definition: Effect.cpp:83
static const int kFFwdID
Definition: Effect.cpp:85
static const int kRewindID
Definition: Effect.cpp:84
wxWindow * mUIParent
Definition: Effect.h:472
wxDialog * mUIDialog
Definition: Effect.h:471
bool SupportsRealtime() override
Definition: Effect.cpp:250
void Effect::End ( )
protectedvirtual

Reimplemented in EffectAutoDuck, and EffectStereoToMono.

Definition at line 1867 of file Effect.cpp.

Referenced by DoEffect(), and Preview().

1868 {
1869 }
void Effect::ExportPresets ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 698 of file Effect.cpp.

699 {
700 }
unsigned Effect::GetAudioInCount ( )
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectPhaser, EffectWahwah, EffectReverb, EffectScienFilter, EffectInvert, EffectFade, and EffectStereoToMono.

Definition at line 282 of file Effect.cpp.

References EffectClientInterface::GetAudioInCount(), and mClient.

Referenced by Process(), and Startup().

283 {
284  if (mClient)
285  {
286  return mClient->GetAudioInCount();
287  }
288 
289  return 0;
290 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual unsigned GetAudioInCount()=0
unsigned Effect::GetAudioOutCount ( )
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectPhaser, EffectWahwah, EffectReverb, EffectScienFilter, EffectToneGen, EffectNoise, EffectInvert, EffectFade, and EffectStereoToMono.

Definition at line 292 of file Effect.cpp.

References EffectClientInterface::GetAudioOutCount(), and mClient.

Referenced by Process(), and Startup().

293 {
294  if (mClient)
295  {
296  return mClient->GetAudioOutCount();
297  }
298 
299  return 0;
300 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual unsigned GetAudioOutCount()=0
bool Effect::GetAutomationParameters ( CommandParameters parms)
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectEqualization, NyquistEffect, EffectPhaser, EffectWahwah, EffectReverb, EffectScienFilter, EffectTruncSilence, EffectToneGen, EffectNoise, EffectNormalize, EffectFindClipping, EffectRepeat, and EffectPaulstretch.

Definition at line 564 of file Effect.cpp.

References EffectClientInterface::GetAutomationParameters(), and mClient.

Referenced by GetAutomationParameters(), EffectManager::GetEffectParameters(), and SaveUserPreset().

565 {
566  if (mClient)
567  {
568  return mClient->GetAutomationParameters(parms);
569  }
570 
571  return true;
572 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual bool GetAutomationParameters(CommandParameters &parms)=0
bool Effect::GetAutomationParameters ( wxString &  parms)
virtual

Definition at line 1002 of file Effect.cpp.

References ParamsInterface::DefineParams(), GetAutomationParameters(), CommandParameters::GetParameters(), ShuttleParams::mpEap, mUIDialog, and TransferDataFromWindow().

1003 {
1004  CommandParameters eap;
1005 
1007  {
1008  return false;
1009  }
1010 
1012  S.mpEap = &eap;
1013  if( DefineParams( S ) ){
1014  ;// got eap value using DefineParams.
1015  }
1016  // Won't be needed in future
1017  else if (!GetAutomationParameters(eap))
1018  {
1019  return false;
1020  }
1021 
1022  return eap.GetParameters(parms);
1023 }
virtual bool TransferDataFromWindow()
Definition: Effect.cpp:1881
Shuttle that gets parameter values into a string.
Definition: Shuttle.h:87
CommandParameters * mpEap
Definition: Shuttle.h:65
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
bool GetParameters(wxString &parms)
bool GetAutomationParameters(CommandParameters &parms) override
Definition: Effect.cpp:564
wxDialog * mUIDialog
Definition: Effect.h:471
virtual bool DefineParams(ShuttleParams &WXUNUSED(S))
wxString Effect::GetCurrentSettingsGroup ( )
overridevirtual
double Effect::GetDefaultDuration ( )
overridevirtual

Implements EffectHostInterface.

Definition at line 717 of file Effect.cpp.

Referenced by DoEffect().

718 {
719  return 30.0;
720 }
wxString Effect::GetDescription ( )
overridevirtual
double Effect::GetDuration ( )
overridevirtual
NumericFormatId Effect::GetDurationFormat ( )
overridevirtual

Implements EffectHostInterface.

Definition at line 732 of file Effect.cpp.

References mDurationFormat.

Referenced by EffectSilence::PopulateOrExchange(), EffectNoise::PopulateOrExchange(), EffectToneGen::PopulateOrExchange(), and EffectDtmf::PopulateOrExchange().

733 {
734  return mDurationFormat;
735 }
NumericFormatId mDurationFormat
Definition: Effect.h:514
wxString Effect::GetFactoryDefaultsGroup ( )
overridevirtual

Implements EffectHostInterface.

Definition at line 806 of file Effect.cpp.

Referenced by HasFactoryDefaults(), LoadFactoryDefaults(), SetAutomationParameters(), and Startup().

807 {
808  return wxT("FactoryDefaults");
809 }
wxArrayString Effect::GetFactoryPresets ( )
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectReverb.

Definition at line 616 of file Effect.cpp.

References EffectClientInterface::GetFactoryPresets(), and mClient.

Referenced by EffectManager::HasPresets(), EffectUIHost::OnMenu(), and SetAutomationParameters().

617 {
618  if (mClient)
619  {
620  return mClient->GetFactoryPresets();
621  }
622 
623  return wxArrayString();
624 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual wxArrayString GetFactoryPresets()=0
IdentInterfaceSymbol Effect::GetFamilyId ( )
overridevirtual

Implements EffectDefinitionInterface.

Reimplemented in NyquistEffect.

Definition at line 208 of file Effect.cpp.

References EffectDefinitionInterface::GetFamilyId(), mClient, and XO.

Referenced by EffectUIHost::OnHelp(), EffectUIHost::OnMenu(), and Preview().

209 {
210  if (mClient)
211  {
212  return mClient->GetFamilyId();
213  }
214 
215  // Unusually, the internal and visible strings differ for the built-in
216  // effect family.
217  return { wxT("Audacity"), XO("Built-in") };
218 }
virtual IdentInterfaceSymbol GetFamilyId()=0
EffectClientInterface * mClient
Definition: Effect.h:527
#define XO(s)
Definition: Internat.h:33
PluginID Effect::GetID ( )
virtual
sampleCount Effect::GetLatency ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 344 of file Effect.cpp.

References EffectClientInterface::GetLatency(), and mClient.

Referenced by ProcessTrack().

345 {
346  if (mClient)
347  {
348  return mClient->GetLatency();
349  }
350 
351  return 0;
352 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual sampleCount GetLatency()=0
int Effect::GetMidiInCount ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 302 of file Effect.cpp.

References EffectClientInterface::GetMidiInCount(), and mClient.

303 {
304  if (mClient)
305  {
306  return mClient->GetMidiInCount();
307  }
308 
309  return 0;
310 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual int GetMidiInCount()=0
int Effect::GetMidiOutCount ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 312 of file Effect.cpp.

References EffectClientInterface::GetMidiOutCount(), and mClient.

313 {
314  if (mClient)
315  {
316  return mClient->GetMidiOutCount();
317  }
318 
319  return 0;
320 }
virtual int GetMidiOutCount()=0
EffectClientInterface * mClient
Definition: Effect.h:527
int Effect::GetNumWaveGroups ( )
inlineprotected

Definition at line 345 of file Effect.h.

Referenced by NyquistEffect::Process().

345 { return mNumGroups; }
int mNumGroups
Definition: Effect.h:524
int Effect::GetNumWaveTracks ( )
inlineprotected
int Effect::GetPass ( )
protectedvirtual

Definition at line 1275 of file Effect.cpp.

References mPass.

1276 {
1277  return mPass;
1278 }
int mPass
Definition: Effect.h:468
wxString Effect::GetPath ( )
overridevirtual

Implements IdentInterface.

Reimplemented in NyquistEffect.

Definition at line 158 of file Effect.cpp.

References BUILTIN_EFFECT_PREFIX, IdentInterface::GetPath(), GetSymbol(), IdentInterfaceSymbol::Internal(), and mClient.

159 {
160  if (mClient)
161  {
162  return mClient->GetPath();
163  }
164 
166 }
#define BUILTIN_EFFECT_PREFIX
Definition: Effect.h:47
EffectClientInterface * mClient
Definition: Effect.h:527
IdentInterfaceSymbol GetSymbol() override
Definition: Effect.cpp:168
const wxString & Internal() const
virtual wxString GetPath()=0
wxString Effect::GetPreset ( wxWindow *  parent,
const wxString &  parms 
)
virtual

Definition at line 1110 of file Effect.cpp.

References EffectPresetsDialog::GetSelected(), and EffectPresetsDialog::SetSelected().

Referenced by EffectManager::GetPreset().

1111 {
1112  EffectPresetsDialog dlg(parent, this);
1113  dlg.Layout();
1114  dlg.Fit();
1115  dlg.SetSize(dlg.GetMinSize());
1116  dlg.CenterOnParent();
1117  dlg.SetSelected(parms);
1118 
1119  if (dlg.ShowModal())
1120  {
1121  return dlg.GetSelected();
1122  }
1123 
1124  return wxEmptyString;
1125 }
bool Effect::GetPrivateConfig ( const wxString &  group,
const wxString &  key,
wxString &  value,
const wxString &  defval = wxEmptyString 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 897 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::GetPrivateConfig().

Referenced by DoEffect(), LoadUserPreset(), EffectChangeSpeed::PopulateOrExchange(), Startup(), and EffectChangeSpeed::Update_Vinyl().

898 {
899  return PluginManager::Get().GetPrivateConfig(GetID(), group, key, value, defval);
900 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool GetPrivateConfig(const PluginID &ID, const wxString &group, const wxString &key, wxString &value, const wxString &defval=_T("")) override
static PluginManager & Get()
bool Effect::GetPrivateConfig ( const wxString &  group,
const wxString &  key,
int &  value,
int  defval = 0 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 902 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::GetPrivateConfig().

903 {
904  return PluginManager::Get().GetPrivateConfig(GetID(), group, key, value, defval);
905 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool GetPrivateConfig(const PluginID &ID, const wxString &group, const wxString &key, wxString &value, const wxString &defval=_T("")) override
static PluginManager & Get()
bool Effect::GetPrivateConfig ( const wxString &  group,
const wxString &  key,
bool &  value,
bool  defval = false 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 907 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::GetPrivateConfig().

908 {
909  return PluginManager::Get().GetPrivateConfig(GetID(), group, key, value, defval);
910 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool GetPrivateConfig(const PluginID &ID, const wxString &group, const wxString &key, wxString &value, const wxString &defval=_T("")) override
static PluginManager & Get()
bool Effect::GetPrivateConfig ( const wxString &  group,
const wxString &  key,
float &  value,
float  defval = 0.0 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 912 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::GetPrivateConfig().

913 {
914  return PluginManager::Get().GetPrivateConfig(GetID(), group, key, value, defval);
915 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool GetPrivateConfig(const PluginID &ID, const wxString &group, const wxString &key, wxString &value, const wxString &defval=_T("")) override
static PluginManager & Get()
bool Effect::GetPrivateConfig ( const wxString &  group,
const wxString &  key,
double &  value,
double  defval = 0.0 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 917 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::GetPrivateConfig().

918 {
919  return PluginManager::Get().GetPrivateConfig(GetID(), group, key, value, defval);
920 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool GetPrivateConfig(const PluginID &ID, const wxString &group, const wxString &key, wxString &value, const wxString &defval=_T("")) override
static PluginManager & Get()
bool Effect::GetPrivateConfigSubgroups ( const wxString &  group,
wxArrayString &  subgroups 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 892 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::GetPrivateConfigSubgroups().

Referenced by GetUserPresets(), and EffectUIHost::LoadUserPresets().

893 {
894  return PluginManager::Get().GetPrivateConfigSubgroups(GetID(), group, subgroups);
895 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool GetPrivateConfigSubgroups(const PluginID &ID, const wxString &group, wxArrayString &subgroups) override
static PluginManager & Get()
void Effect::GetSamples ( const WaveTrack track,
sampleCount start,
sampleCount len 
)
protected

Definition at line 2001 of file Effect.cpp.

References WaveTrack::GetEndTime(), WaveTrack::GetStartTime(), GetType(), WaveTrack::InsertSilence(), mDuration, mT0, mT1, and WaveTrack::TimeToLongSamples().

Referenced by ProcessPass().

2003 {
2004  double trackStart = track->GetStartTime();
2005  double trackEnd = track->GetEndTime();
2006  double t0 = mT0 < trackStart ? trackStart : mT0;
2007  double t1 = mT1 > trackEnd ? trackEnd : mT1;
2008 
2009 #if 0
2010  if (GetType() & INSERT_EFFECT) {
2011  t1 = t0 + mDuration;
2012  if (mT0 == mT1) {
2013  // Not really part of the calculation, but convenient to put here
2014  track->InsertSilence(t0, t1);
2015  }
2016  }
2017 #endif
2018 
2019  if (t1 > t0) {
2020  *start = track->TimeToLongSamples(t0);
2021  auto end = track->TimeToLongSamples(t1);
2022  *len = end - *start;
2023  }
2024  else {
2025  *start = 0;
2026  *len = 0;
2027  }
2028 }
double mT1
Definition: Effect.h:461
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1873
void InsertSilence(double t, double len) override
Definition: WaveTrack.cpp:1385
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1853
EffectType GetType() override
Definition: Effect.cpp:148
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: WaveTrack.cpp:1843
double mDuration
Definition: Effect.h:513
double mT0
Definition: Effect.h:460
wxString Effect::GetSavedStateGroup ( )
virtual

Definition at line 811 of file Effect.cpp.

Referenced by SetBatchProcessing().

812 {
813  return wxT("SavedState");
814 }
NumericFormatId Effect::GetSelectionFormat ( )
virtual

Definition at line 737 of file Effect.cpp.

References GetActiveProject(), and AudacityProject::GetSelectionFormat().

Referenced by NyquistEffect::BuildEffectWindow(), and EffectRepeat::DisplayNewTime().

738 {
740 }
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
const NumericFormatId & GetSelectionFormat() const
Definition: Project.cpp:1685
bool Effect::GetSharedConfig ( const wxString &  group,
const wxString &  key,
wxString &  value,
const wxString &  defval = wxEmptyString 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 827 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::GetSharedConfig().

828 {
829  return PluginManager::Get().GetSharedConfig(GetID(), group, key, value, defval);
830 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool GetSharedConfig(const PluginID &ID, const wxString &group, const wxString &key, wxString &value, const wxString &defval=_T("")) override
static PluginManager & Get()
bool Effect::GetSharedConfig ( const wxString &  group,
const wxString &  key,
int &  value,
int  defval = 0 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 832 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::GetSharedConfig().

833 {
834  return PluginManager::Get().GetSharedConfig(GetID(), group, key, value, defval);
835 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool GetSharedConfig(const PluginID &ID, const wxString &group, const wxString &key, wxString &value, const wxString &defval=_T("")) override
static PluginManager & Get()
bool Effect::GetSharedConfig ( const wxString &  group,
const wxString &  key,
bool &  value,
bool  defval = false 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 837 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::GetSharedConfig().

838 {
839  return PluginManager::Get().GetSharedConfig(GetID(), group, key, value, defval);
840 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool GetSharedConfig(const PluginID &ID, const wxString &group, const wxString &key, wxString &value, const wxString &defval=_T("")) override
static PluginManager & Get()
bool Effect::GetSharedConfig ( const wxString &  group,
const wxString &  key,
float &  value,
float  defval = 0.0 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 842 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::GetSharedConfig().

843 {
844  return PluginManager::Get().GetSharedConfig(GetID(), group, key, value, defval);
845 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool GetSharedConfig(const PluginID &ID, const wxString &group, const wxString &key, wxString &value, const wxString &defval=_T("")) override
static PluginManager & Get()
bool Effect::GetSharedConfig ( const wxString &  group,
const wxString &  key,
double &  value,
double  defval = 0.0 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 847 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::GetSharedConfig().

848 {
849  return PluginManager::Get().GetSharedConfig(GetID(), group, key, value, defval);
850 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool GetSharedConfig(const PluginID &ID, const wxString &group, const wxString &key, wxString &value, const wxString &defval=_T("")) override
static PluginManager & Get()
bool Effect::GetSharedConfigSubgroups ( const wxString &  group,
wxArrayString &  subgroups 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 822 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::GetSharedConfigSubgroups().

823 {
824  return PluginManager::Get().GetSharedConfigSubgroups(GetID(), group, subgroups);
825 }
bool GetSharedConfigSubgroups(const PluginID &ID, const wxString &group, wxArrayString &subgroups) override
virtual PluginID GetID()
Definition: Effect.cpp:959
static PluginManager & Get()
IdentInterfaceSymbol Effect::GetSymbol ( )
overridevirtual

Implements IdentInterface.

Reimplemented in EffectEqualization, NyquistEffect, EffectPhaser, EffectWahwah, EffectReverb, EffectScienFilter, EffectTruncSilence, EffectToneGen, EffectNormalize, EffectNoise, EffectFindClipping, EffectRepeat, EffectNoiseReduction, EffectSilence, EffectInvert, EffectRepair, EffectReverse, EffectFade, EffectPaulstretch, and EffectStereoToMono.

Definition at line 168 of file Effect.cpp.

References IdentInterface::GetSymbol(), and mClient.

Referenced by GetPath().

169 {
170  if (mClient)
171  {
172  return mClient->GetSymbol();
173  }
174 
175  return {};
176 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual IdentInterfaceSymbol GetSymbol()=0
size_t Effect::GetTailSize ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 354 of file Effect.cpp.

References EffectClientInterface::GetTailSize(), and mClient.

355 {
356  if (mClient)
357  {
358  return mClient->GetTailSize();
359  }
360 
361  return 0;
362 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual size_t GetTailSize()=0
EffectType Effect::GetType ( )
overridevirtual
wxArrayString Effect::GetUserPresets ( )
virtual

Definition at line 1089 of file Effect.cpp.

References GetPrivateConfigSubgroups(), and GetUserPresetsGroup().

Referenced by EffectManager::HasPresets().

1090 {
1091  wxArrayString presets;
1092 
1093  GetPrivateConfigSubgroups(GetUserPresetsGroup(wxEmptyString), presets);
1094 
1095  presets.Sort();
1096 
1097  return presets;
1098 }
wxString GetUserPresetsGroup(const wxString &name) override
Definition: Effect.cpp:790
bool GetPrivateConfigSubgroups(const wxString &group, wxArrayString &subgroups) override
Definition: Effect.cpp:892
wxString Effect::GetUserPresetsGroup ( const wxString &  name)
overridevirtual

Implements EffectHostInterface.

Definition at line 790 of file Effect.cpp.

References name.

Referenced by GetUserPresets(), EffectUIHost::LoadUserPresets(), EffectUIHost::OnDeletePreset(), EffectUIHost::OnSaveAs(), EffectUIHost::OnUserPreset(), SetAutomationParameters(), and EffectReverb::Startup().

791 {
792  wxString group = wxT("UserPresets");
793  if (!name.IsEmpty())
794  {
795  group += wxCONFIG_PATH_SEPARATOR + name;
796  }
797 
798  return group;
799 }
const wxChar * name
Definition: Distortion.cpp:94
IdentInterfaceSymbol Effect::GetVendor ( )
overridevirtual

Implements IdentInterface.

Reimplemented in NyquistEffect.

Definition at line 178 of file Effect.cpp.

References IdentInterface::GetVendor(), mClient, and XO.

Referenced by EffectUIHost::OnMenu().

179 {
180  if (mClient)
181  {
182  return mClient->GetVendor();
183  }
184 
185  return XO("Audacity");
186 }
EffectClientInterface * mClient
Definition: Effect.h:527
#define XO(s)
Definition: Internat.h:33
virtual IdentInterfaceSymbol GetVendor()=0
wxString Effect::GetVersion ( )
overridevirtual

Implements IdentInterface.

Reimplemented in NyquistEffect.

Definition at line 188 of file Effect.cpp.

References AUDACITY_VERSION_STRING, IdentInterface::GetVersion(), and mClient.

Referenced by EffectUIHost::OnMenu().

189 {
190  if (mClient)
191  {
192  return mClient->GetVersion();
193  }
194 
196 }
#define AUDACITY_VERSION_STRING
Definition: Audacity.h:81
EffectClientInterface * mClient
Definition: Effect.h:527
virtual wxString GetVersion()=0
bool Effect::HasCurrentSettings ( )
virtual

Definition at line 1100 of file Effect.cpp.

References GetCurrentSettingsGroup(), and HasPrivateConfigGroup().

Referenced by EffectManager::GetDefaultPreset(), and EffectManager::HasPresets().

1101 {
1103 }
wxString GetCurrentSettingsGroup() override
Definition: Effect.cpp:801
bool HasPrivateConfigGroup(const wxString &group) override
Definition: Effect.cpp:887
bool Effect::HasFactoryDefaults ( )
virtual

Definition at line 1105 of file Effect.cpp.

References GetFactoryDefaultsGroup(), and HasPrivateConfigGroup().

Referenced by EffectManager::GetDefaultPreset(), and EffectManager::HasPresets().

1106 {
1108 }
bool HasPrivateConfigGroup(const wxString &group) override
Definition: Effect.cpp:887
wxString GetFactoryDefaultsGroup() override
Definition: Effect.cpp:806
bool Effect::HasOptions ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 706 of file Effect.cpp.

707 {
708  return false;
709 }
bool Effect::HasPrivateConfigGroup ( const wxString &  group)
overridevirtual

Implements ConfigClientInterface.

Definition at line 887 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::HasPrivateConfigGroup().

Referenced by HasCurrentSettings(), and HasFactoryDefaults().

888 {
890 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool HasPrivateConfigGroup(const PluginID &ID, const wxString &group)
static PluginManager & Get()
bool Effect::HasSharedConfigGroup ( const wxString &  group)
overridevirtual

Implements ConfigClientInterface.

Definition at line 817 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::HasSharedConfigGroup().

818 {
819  return PluginManager::Get().HasSharedConfigGroup(GetID(), group);
820 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool HasSharedConfigGroup(const PluginID &ID, const wxString &group)
static PluginManager & Get()
wxString Effect::HelpPage ( )
virtual

Reimplemented in NyquistEffect.

Definition at line 1132 of file Effect.cpp.

Referenced by EffectUIHost::Initialize(), and EffectUIHost::OnHelp().

1133 {
1134  return wxEmptyString;
1135 }
bool Effect::HideUI ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 677 of file Effect.cpp.

678 {
679  return true;
680 }
void Effect::ImportPresets ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 702 of file Effect.cpp.

703 {
704 }
void Effect::IncludeNotSelectedPreviewTracks ( bool  includeNotSelected)
protected

Definition at line 1972 of file Effect.cpp.

References mPreviewWithNotSelected.

1973 {
1974  mPreviewWithNotSelected = includeNotSelected;
1975 }
bool mPreviewWithNotSelected
Definition: Effect.h:509
bool Effect::Init ( )
protectedvirtual

Reimplemented in EffectEqualization, NyquistEffect, EffectScienFilter, EffectAmplify, EffectChangeSpeed, EffectDtmf, EffectAutoDuck, EffectNoiseReduction, and Generator.

Definition at line 1264 of file Effect.cpp.

Referenced by DoEffect(), and Preview().

1265 {
1266  return true;
1267 }
bool Effect::InitPass1 ( )
protectedvirtual

Reimplemented in EffectCompressor, and EffectTwoPassSimpleMono.

Definition at line 1280 of file Effect.cpp.

Referenced by Process().

1281 {
1282  return true;
1283 }
bool Effect::InitPass2 ( )
protectedvirtual

Reimplemented in EffectCompressor, and EffectTwoPassSimpleMono.

Definition at line 1285 of file Effect.cpp.

Referenced by Process().

1286 {
1287  return false;
1288 }
TrackList* Effect::inputTracks ( ) const
inlineprotected
bool Effect::IsBatchProcessing ( )
virtual
bool Effect::IsDefault ( )
overridevirtual

Implements EffectDefinitionInterface.

Reimplemented in NyquistEffect.

Definition at line 230 of file Effect.cpp.

References EffectDefinitionInterface::IsDefault(), and mClient.

231 {
232  if (mClient)
233  {
234  return mClient->IsDefault();
235  }
236 
237  return true;
238 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual bool IsDefault()=0
bool Effect::IsGraphicalUI ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 667 of file Effect.cpp.

668 {
669  return false;
670 }
bool Effect::IsHidden ( )
virtual

Reimplemented in EffectStereoToMono.

Definition at line 2467 of file Effect.cpp.

Referenced by EffectManager::IsHidden().

2468 {
2469  return false;
2470 }
bool Effect::IsInteractive ( )
overridevirtual

Implements EffectDefinitionInterface.

Reimplemented in NyquistEffect, EffectInvert, EffectRepair, EffectReverse, EffectFade, and EffectStereoToMono.

Definition at line 220 of file Effect.cpp.

References EffectDefinitionInterface::IsInteractive(), and mClient.

Referenced by DoEffect(), and ShowInterface().

221 {
222  if (mClient)
223  {
224  return mClient->IsInteractive();
225  }
226 
227  return true;
228 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual bool IsInteractive()=0
bool Effect::IsLegacy ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 240 of file Effect.cpp.

References mClient.

241 {
242  if (mClient)
243  {
244  return false;
245  }
246 
247  return true;
248 }
EffectClientInterface * mClient
Definition: Effect.h:527
bool Effect::IsPreviewing ( )
inlineprotected

Definition at line 361 of file Effect.h.

Referenced by NyquistEffect::Process(), and EffectPaulstretch::ProcessOne().

361 { return mIsPreview; }
bool mIsPreview
Definition: Effect.h:516
bool Effect::IsReady ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 364 of file Effect.cpp.

References EffectClientInterface::IsReady(), and mClient.

365 {
366  if (mClient)
367  {
368  return mClient->IsReady();
369  }
370 
371  return true;
372 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual bool IsReady()=0
bool Effect::IsRealtimeActive ( )

Definition at line 2462 of file Effect.cpp.

References mRealtimeSuspendCount.

2463 {
2464  return mRealtimeSuspendCount == 0;
2465 }
int mRealtimeSuspendCount
Definition: Effect.h:539
bool Effect::LoadFactoryDefaults ( )
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectEqualization.

Definition at line 636 of file Effect.cpp.

References GetFactoryDefaultsGroup(), EffectClientInterface::LoadFactoryDefaults(), LoadUserPreset(), and mClient.

Referenced by EffectChangeSpeed::LoadFactoryDefaults(), EffectEqualization::LoadFactoryDefaults(), and EffectUIHost::OnDefaults().

637 {
638  if (mClient)
639  {
640  return mClient->LoadFactoryDefaults();
641  }
642 
644 }
EffectClientInterface * mClient
Definition: Effect.h:527
bool LoadUserPreset(const wxString &name) override
Definition: Effect.cpp:584
virtual bool LoadFactoryDefaults()=0
wxString GetFactoryDefaultsGroup() override
Definition: Effect.cpp:806
bool Effect::LoadFactoryPreset ( int  id)
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectReverb.

Definition at line 626 of file Effect.cpp.

References EffectClientInterface::LoadFactoryPreset(), and mClient.

Referenced by EffectUIHost::OnFactoryPreset(), and SetAutomationParameters().

627 {
628  if (mClient)
629  {
630  return mClient->LoadFactoryPreset(id);
631  }
632 
633  return true;
634 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual bool LoadFactoryPreset(int id)=0
bool Effect::LoadUserPreset ( const wxString &  name)
overridevirtual

Implements EffectClientInterface.

Definition at line 584 of file Effect.cpp.

References GetPrivateConfig(), EffectClientInterface::LoadUserPreset(), mClient, and SetAutomationParameters().

Referenced by NyquistEffect::Init(), LoadFactoryDefaults(), EffectUIHost::OnUserPreset(), EffectEqualization::PopulateUI(), SetAutomationParameters(), SetBatchProcessing(), and Startup().

585 {
586  if (mClient)
587  {
588  return mClient->LoadUserPreset(name);
589  }
590 
591  wxString parms;
592  if (!GetPrivateConfig(name, wxT("Parameters"), parms))
593  {
594  return false;
595  }
596 
597  return SetAutomationParameters(parms);
598 }
bool GetPrivateConfig(const wxString &group, const wxString &key, wxString &value, const wxString &defval=wxEmptyString) override
Definition: Effect.cpp:897
bool SetAutomationParameters(CommandParameters &parms) override
Definition: Effect.cpp:574
EffectClientInterface * mClient
Definition: Effect.h:527
const wxChar * name
Definition: Distortion.cpp:94
virtual bool LoadUserPreset(const wxString &name)=0
wxString Effect::ManualPage ( )
virtual
int Effect::MessageBox ( const wxString &  message,
long  style = DefaultMessageBoxStyle,
const wxString &  titleStr = wxString{} 
)

Definition at line 2646 of file Effect.cpp.

References _(), AudacityMessageBox(), IdentInterface::GetTranslatedName(), and mUIParent.

Referenced by EffectAutoDuck::Init(), EffectScienFilter::Init(), NyquistEffect::Init(), EffectEqualization::Init(), EffectEqualization::LoadCurves(), NyquistEffect::OnFileButton(), NyquistEffect::OnLoad(), NyquistEffect::OnSave(), NyquistEffect::OnTime(), NyquistEffect::ParseProgram(), EffectRepair::Process(), EffectNoiseReduction::Process(), Generator::Process(), EffectClickRemoval::Process(), NyquistEffect::Process(), EffectTruncSilence::ProcessIndependently(), EffectEcho::ProcessInitialize(), EffectPaulstretch::ProcessOne(), EffectFindClipping::ProcessOne(), EffectClickRemoval::ProcessOne(), NyquistEffect::ProcessOne(), SetAutomationParameters(), EffectEqualization::setCurve(), NyquistEffect::TransferDataFromEffectWindow(), and EffectEqualization::ValidateUI().

2647 {
2648  wxString title;
2649  if (titleStr.empty())
2650  title = GetTranslatedName();
2651  else
2652  title = wxString::Format(_("%s: %s"), GetTranslatedName(), titleStr);
2653  return AudacityMessageBox(message, title, style, mUIParent);
2654 }
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
wxWindow * mUIParent
Definition: Effect.h:472
const wxString & GetTranslatedName()
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
auto Effect::ModifyAnalysisTrack ( const LabelTrack pOrigTrack,
const wxString &  name = wxString() 
)
protected

Definition at line 2155 of file Effect.cpp.

Referenced by EffectFindClipping::Process().

2156 {
2157  return{ this, pOrigTrack, name };
2158 }
const wxChar * name
Definition: Distortion.cpp:94
void Effect::PopulateOrExchange ( ShuttleGui S)
protectedvirtual
bool Effect::PopulateUI ( wxWindow *  parent)
overridevirtual

Implements EffectUIClientInterface.

Reimplemented in EffectEqualization.

Definition at line 652 of file Effect.cpp.

References eIsCreating, mUIParent, and PopulateOrExchange().

653 {
654  mUIParent = parent;
655  mUIParent->PushEventHandler(this);
656 
657 // LoadUserPreset(GetCurrentSettingsGroup());
658 
661 
662  mUIParent->SetMinSize(mUIParent->GetSizer()->GetMinSize());
663 
664  return true;
665 }
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
wxWindow * mUIParent
Definition: Effect.h:472
virtual void PopulateOrExchange(ShuttleGui &S)
Definition: Effect.cpp:1871
void Effect::Preview ( )
overridevirtual

Implements EffectHostInterface.

Definition at line 771 of file Effect.cpp.

Referenced by EffectUIHost::OnPlay(), and EffectAmplify::Preview().

772 {
773  Preview(false);
774 }
void Preview() override
Definition: Effect.cpp:771
void Effect::Preview ( bool  dryOnly)
protectedvirtual

Reimplemented in EffectAmplify.

Definition at line 2472 of file Effect.cpp.

References _(), TrackList::Add(), CalcPreviewInputLength(), WaveTrack::Copy(), CountWaveTracks(), TrackList::Create(), EffectTypeGenerate, End(), TrackListCondIterator::First(), floatSample, gAudioIO, GetAllPlaybackTracks(), GetFamilyId(), Track::GetSelected(), AudioIO::GetStreamTime(), IdentInterface::GetTranslatedName(), GetType(), gPrefs, GuardedCall(), Init(), AudioIO::IsBusy(), AudioIO::IsStreamActive(), mDuration, mFactory, min(), mIsLinearEffect, mIsPreview, MixAndRender(), mNumTracks, mPreviewFullSelection, mPreviewWithNotSelected, mProgress, mProjectRate, mT0, mT1, mTracks, TrackListCondIterator::Next(), WaveTrack::NoDisplay, NYQUISTEFFECTS_FAMILY, Track::Offset(), pdlgHideCancelButton, Process(), ReplaceProcessedTracks(), ShowErrorDialog(), AudioIO::StartStream(), AudioIO::StopStream(), Success, ProgressDialog::Update(), valueRestorer(), and Track::Wave.

2473 {
2474  if (mNumTracks == 0) { // nothing to preview
2475  return;
2476  }
2477 
2478  if (gAudioIO->IsBusy()) {
2479  return;
2480  }
2481 
2482  wxWindow *FocusDialog = wxWindow::FindFocus();
2483 
2484  double previewDuration;
2485  bool isNyquist = GetFamilyId() == NYQUISTEFFECTS_FAMILY;
2486  bool isGenerator = GetType() == EffectTypeGenerate;
2487 
2488  // Mix a few seconds of audio from all of the tracks
2489  double previewLen;
2490  gPrefs->Read(wxT("/AudioIO/EffectsPreviewLen"), &previewLen, 6.0);
2491 
2492  const double rate = mProjectRate;
2493 
2494  if (isNyquist && isGenerator) {
2495  previewDuration = CalcPreviewInputLength(previewLen);
2496  }
2497  else {
2498  previewDuration = wxMin(mDuration, CalcPreviewInputLength(previewLen));
2499  }
2500 
2501  double t1 = mT0 + previewDuration;
2502 
2503  if ((t1 > mT1) && !(isNyquist && isGenerator)) {
2504  t1 = mT1;
2505  }
2506 
2507  if (t1 <= mT0)
2508  return;
2509 
2510  bool success = true;
2511 
2512  auto cleanup = finally( [&] {
2513 
2514  // Effect is already inited; we will call Process, End, and then Init
2515  // again, so the state is exactly the way it was before Preview
2516  // was called.
2517  if (!dryOnly) {
2518  End();
2519  GuardedCall( [&]{ Init(); } );
2520  }
2521  } );
2522 
2523  auto vr0 = valueRestorer( mT0 );
2524  auto vr1 = valueRestorer( mT1 );
2525  // Most effects should stop at t1.
2526  if (!mPreviewFullSelection)
2527  mT1 = t1;
2528 
2529  // Save the original track list
2530  TrackList *saveTracks = mTracks;
2531 
2532  auto cleanup2 = finally( [&] {
2533  mTracks = saveTracks;
2534  if (FocusDialog) {
2535  FocusDialog->SetFocus();
2536  }
2537 
2538  // In case of failed effect, be sure to free memory.
2539  ReplaceProcessedTracks( false );
2540  } );
2541 
2542  // Build NEW tracklist from rendering tracks
2543  auto uTracks = TrackList::Create();
2544  mTracks = uTracks.get();
2545 
2546  // Linear Effect preview optimised by pre-mixing to one track.
2547  // Generators need to generate per track.
2548  if (mIsLinearEffect && !isGenerator) {
2549  WaveTrack::Holder mixLeft, mixRight;
2550  MixAndRender(saveTracks, mFactory, rate, floatSample, mT0, t1, mixLeft, mixRight);
2551  if (!mixLeft)
2552  return;
2553 
2554  mixLeft->Offset(-mixLeft->GetStartTime());
2555  mixLeft->SetSelected(true);
2556  mixLeft->SetDisplay(WaveTrack::NoDisplay);
2557  mTracks->Add(std::move(mixLeft));
2558  if (mixRight) {
2559  mixRight->Offset(-mixRight->GetStartTime());
2560  mixRight->SetSelected(true);
2561  mTracks->Add(std::move(mixRight));
2562  }
2563  }
2564  else {
2565  TrackListOfKindIterator iter(Track::Wave, saveTracks);
2566  WaveTrack *src = (WaveTrack *) iter.First();
2567  while (src)
2568  {
2569  if (src->GetSelected() || mPreviewWithNotSelected) {
2570  auto dest = src->Copy(mT0, t1);
2571  dest->SetSelected(src->GetSelected());
2572  static_cast<WaveTrack*>(dest.get())->SetDisplay(WaveTrack::NoDisplay);
2573  mTracks->Add(std::move(dest));
2574  }
2575  src = (WaveTrack *) iter.Next();
2576  }
2577  }
2578 
2579  // NEW tracks start at time zero.
2580  // Adjust mT0 and mT1 to be the times to process, and to
2581  // play back in these tracks
2582  mT1 -= mT0;
2583  mT0 = 0.0;
2584 
2585 
2586  // Update track/group counts
2587  CountWaveTracks();
2588 
2589  // Apply effect
2590  if (!dryOnly) {
2591  ProgressDialog progress{
2593  _("Preparing preview"),
2595  }; // Have only "Stop" button.
2596  auto vr = valueRestorer( mProgress, &progress );
2597 
2598  auto vr2 = valueRestorer( mIsPreview, true );
2599 
2600  success = Process();
2601  }
2602 
2603  if (success)
2604  {
2605  auto tracks = GetAllPlaybackTracks(*mTracks, true);
2606 
2607  // Some effects (Paulstretch) may need to generate more
2608  // than previewLen, so take the min.
2609  t1 = std::min(mT0 + previewLen, mT1);
2610 
2611  // Start audio playing
2612  AudioIOStartStreamOptions options { rate };
2613  int token =
2614  gAudioIO->StartStream(tracks, mT0, t1, options);
2615 
2616  if (token) {
2617  auto previewing = ProgressResult::Success;
2618  // The progress dialog must be deleted before stopping the stream
2619  // to allow events to flow to the app during StopStream processing.
2620  // The progress dialog blocks these events.
2621  {
2622  ProgressDialog progress
2623  (GetTranslatedName(), _("Previewing"), pdlgHideCancelButton);
2624 
2625  while (gAudioIO->IsStreamActive(token) && previewing == ProgressResult::Success) {
2626  ::wxMilliSleep(100);
2627  previewing = progress.Update(gAudioIO->GetStreamTime() - mT0, t1 - mT0);
2628  }
2629  }
2630 
2631  gAudioIO->StopStream();
2632 
2633  while (gAudioIO->IsBusy()) {
2634  ::wxMilliSleep(100);
2635  }
2636  }
2637  else {
2638  ShowErrorDialog(FocusDialog, _("Error"),
2639  _("Error opening sound device.\nTry changing the audio host, playback device and the project sample rate."),
2640  wxT("Error_opening_sound_device"));
2641  }
2642  }
2643 }
int StartStream(const TransportTracks &tracks, double t0, double t1, const AudioIOStartStreamOptions &options)
Start recording or playing back audio.
Definition: AudioIO.cpp:1864
IdentInterfaceSymbol GetFamilyId() override
Definition: Effect.cpp:208
double mT1
Definition: Effect.h:461
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
A list of TrackListNode items.
Definition: Track.h:619
void StopStream()
Stop recording, playback or input monitoring.
Definition: AudioIO.cpp:2562
void CountWaveTracks()
Definition: Effect.cpp:2251
ProgressDialog Class.
ProgressDialog * mProgress
Definition: Effect.h:452
double GetStreamTime()
During playback, the (unwarped) track time most recently played.
Definition: AudioIO.cpp:2960
TrackList * mTracks
Definition: Effect.h:505
bool GetSelected() const
Definition: Track.h:276
bool IsStreamActive()
Returns true if the audio i/o is running at all, but not during cleanup.
Definition: AudioIO.cpp:2890
bool mPreviewFullSelection
Definition: Effect.h:510
virtual bool Init()
Definition: Effect.cpp:1264
bool mIsPreview
Definition: Effect.h:516
Track * Add(std::unique_ptr< TrackKind > &&t)
Add a Track, giving it a fresh id.
Definition: Track.cpp:906
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2162
void Offset(double t)
Definition: Track.h:289
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: WaveTrack.cpp:605
virtual bool Process()
Definition: Effect.cpp:1290
bool IsBusy()
Returns true if audio i/o is busy starting, stopping, playing, or recording.
Definition: AudioIO.cpp:2882
void ShowErrorDialog(wxWindow *parent, const wxString &dlogTitle, const wxString &message, const wxString &helpPage, const bool Close)
Displays an error dialog with a button that offers help.
static std::shared_ptr< TrackList > Create()
Definition: Track.cpp:792
EffectType GetType() override
Definition: Effect.cpp:148
std::unique_ptr< WaveTrack > Holder
Definition: WaveTrack.h:90
struct holding stream options, including a pointer to the TimeTrack and AudioIOListener and whether t...
Definition: AudioIO.h:123
virtual void End()
Definition: Effect.cpp:1867
int mNumTracks
Definition: Effect.h:523
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
virtual double CalcPreviewInputLength(double previewLength)
Definition: Effect.cpp:2274
bool mIsLinearEffect
Definition: Effect.h:508
int min(int a, int b)
R GuardedCall(const F1 &body, const F2 &handler=F2::Default(), const F3 &delayedHandler={})
bool mPreviewWithNotSelected
Definition: Effect.h:509
#define NYQUISTEFFECTS_FAMILY
Definition: Nyquist.h:35
TransportTracks GetAllPlaybackTracks(const TrackList &trackList, bool selectedOnly, bool useMidi)
Definition: Track.cpp:1579
const wxString & GetTranslatedName()
double mProjectRate
Definition: Effect.h:453
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
TrackFactory * mFactory
Definition: Effect.h:457
ValueRestorer< T > valueRestorer(T &var)
Definition: MemoryX.h:494
AudioIO * gAudioIO
Definition: AudioIO.cpp:482
void MixAndRender(TrackList *tracks, TrackFactory *trackFactory, double rate, sampleFormat format, double startTime, double endTime, WaveTrack::Holder &uLeft, WaveTrack::Holder &uRight)
Mixes together all input tracks, applying any envelopes, amplitude gain, panning, and real-time effec...
Definition: Mix.cpp:44
double mDuration
Definition: Effect.h:513
double mT0
Definition: Effect.h:460
bool Effect::Process ( )
protectedvirtual

Reimplemented in EffectEqualization, NyquistEffect, EffectTruncSilence, EffectChangeSpeed, EffectAutoDuck, EffectClickRemoval, Generator, EffectNormalize, EffectFindClipping, EffectRepeat, EffectNoiseReduction, EffectPaulstretch, EffectStereoToMono, EffectRepair, EffectReverse, EffectSimpleMono, and EffectTwoPassSimpleMono.

Definition at line 1290 of file Effect.cpp.

References Track::All, CopyInputTracks(), GetAudioInCount(), GetAudioOutCount(), InitPass1(), InitPass2(), mNumAudioIn, mNumAudioOut, mPass, ProcessPass(), and ReplaceProcessedTracks().

Referenced by DoEffect(), and Preview().

1291 {
1293  bool bGoodResult = true;
1294 
1295  // It's possible that the number of channels the effect expects changed based on
1296  // the parameters (the Audacity Reverb effect does when the stereo width is 0).
1299 
1300  mPass = 1;
1301  if (InitPass1())
1302  {
1303  bGoodResult = ProcessPass();
1304  mPass = 2;
1305  if (bGoodResult && InitPass2())
1306  {
1307  bGoodResult = ProcessPass();
1308  }
1309  }
1310 
1311  ReplaceProcessedTracks(bGoodResult);
1312 
1313  return bGoodResult;
1314 }
unsigned GetAudioInCount() override
Definition: Effect.cpp:282
int mPass
Definition: Effect.h:468
void CopyInputTracks()
Definition: Effect.cpp:2036
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2162
virtual bool ProcessPass()
Definition: Effect.cpp:1316
size_t mNumAudioIn
Definition: Effect.h:528
size_t mNumAudioOut
Definition: Effect.h:529
virtual bool InitPass2()
Definition: Effect.cpp:1285
virtual bool InitPass1()
Definition: Effect.cpp:1280
unsigned GetAudioOutCount() override
Definition: Effect.cpp:292
size_t Effect::ProcessBlock ( float **  inBlock,
float **  outBlock,
size_t  blockLen 
)
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectPhaser, EffectWahwah, EffectReverb, EffectScienFilter, EffectToneGen, EffectNoise, EffectFade, and EffectInvert.

Definition at line 394 of file Effect.cpp.

References mClient, and EffectClientInterface::ProcessBlock().

Referenced by ProcessTrack().

395 {
396  if (mClient)
397  {
398  return mClient->ProcessBlock(inBlock, outBlock, blockLen);
399  }
400 
401  return 0;
402 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen)=0
bool Effect::ProcessFinalize ( )
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectReverb.

Definition at line 384 of file Effect.cpp.

References mClient, and EffectClientInterface::ProcessFinalize().

Referenced by ProcessTrack().

385 {
386  if (mClient)
387  {
388  return mClient->ProcessFinalize();
389  }
390 
391  return true;
392 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual bool ProcessFinalize()=0
bool Effect::ProcessInitialize ( sampleCount  totalLen,
ChannelNames  chanMap = NULL 
)
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectPhaser, EffectWahwah, EffectReverb, EffectScienFilter, EffectToneGen, and EffectFade.

Definition at line 374 of file Effect.cpp.

References mClient, and EffectClientInterface::ProcessInitialize().

Referenced by ProcessTrack().

375 {
376  if (mClient)
377  {
378  return mClient->ProcessInitialize(totalLen, chanMap);
379  }
380 
381  return true;
382 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL)=0
bool Effect::ProcessPass ( )
protectedvirtual

Reimplemented in EffectTwoPassSimpleMono.

Definition at line 1316 of file Effect.cpp.

References ChannelNameEOL, ChannelNameFrontLeft, ChannelNameFrontRight, ChannelNameMono, EffectTypeGenerate, WaveTrack::GetChannel(), Track::GetKind(), Track::GetLinked(), WaveTrack::GetMaxBlockSize(), WaveTrack::GetRate(), GetSamples(), Track::GetSelected(), GetType(), Track::IsSyncLockSelected(), Track::LeftChannel, mBlockSize, mBufferSize, mDuration, mNumAudioIn, mNumAudioOut, mNumChannels, mOutputTracks, mSampleCnt, mT0, mT1, ProcessTrack(), ArrayOf< X >::reinit(), ArraysOf< X >::reinit(), Track::RightChannel, SetBlockSize(), SetSampleRate(), Track::SyncLockAdjust(), WaveTrack::TimeToLongSamples(), and Track::Wave.

Referenced by Process().

1317 {
1318  bool bGoodResult = true;
1319  bool isGenerator = GetType() == EffectTypeGenerate;
1320 
1321  FloatBuffers inBuffer, outBuffer;
1322  ArrayOf<float *> inBufPos, outBufPos;
1323 
1324  ChannelName map[3];
1325 
1326  mBufferSize = 0;
1327  mBlockSize = 0;
1328 
1329  TrackListIterator iter(mOutputTracks.get());
1330  int count = 0;
1331  bool clear = false;
1332  Track* t = iter.First();
1333 
1334  for (t = iter.First(); t; t = iter.Next())
1335  {
1336  if (t->GetKind() != Track::Wave || !t->GetSelected())
1337  {
1338  if (t->IsSyncLockSelected())
1339  {
1341  }
1342  continue;
1343  }
1344 
1345  WaveTrack *left = (WaveTrack *)t;
1346  WaveTrack *right;
1347  sampleCount len;
1348  sampleCount leftStart;
1349  sampleCount rightStart;
1350 
1351  if (!isGenerator)
1352  {
1353  GetSamples(left, &leftStart, &len);
1354  mSampleCnt = len;
1355  }
1356  else
1357  {
1358  len = 0;
1359  leftStart = 0;
1361  }
1362 
1363  mNumChannels = 1;
1364 
1365  if (left->GetChannel() == Track::LeftChannel)
1366  {
1367  map[0] = ChannelNameFrontLeft;
1368  }
1369  else if (left->GetChannel() == Track::RightChannel)
1370  {
1371  map[0] = ChannelNameFrontRight;
1372  }
1373  else
1374  {
1375  map[0] = ChannelNameMono;
1376  }
1377  map[1] = ChannelNameEOL;
1378 
1379  right = NULL;
1380  rightStart = 0;
1381  if (left->GetLinked() && mNumAudioIn > 1)
1382  {
1383  // Assume linked track is wave
1384  right = static_cast<WaveTrack *>(iter.Next());
1385  if (!isGenerator)
1386  {
1387  GetSamples(right, &rightStart, &len);
1388  }
1389  clear = false;
1390  mNumChannels = 2;
1391 
1392  if (right->GetChannel() == Track::LeftChannel)
1393  {
1394  map[1] = ChannelNameFrontLeft;
1395  }
1396  else if (right->GetChannel() == Track::RightChannel)
1397  {
1398  map[1] = ChannelNameFrontRight;
1399  }
1400  else
1401  {
1402  map[1] = ChannelNameMono;
1403  }
1404  map[2] = ChannelNameEOL;
1405  }
1406 
1407  // Let the client know the sample rate
1408  SetSampleRate(left->GetRate());
1409 
1410  // Get the block size the client wants to use
1411  auto max = left->GetMaxBlockSize() * 2;
1412  mBlockSize = SetBlockSize(max);
1413 
1414  // Calculate the buffer size to be at least the max rounded up to the clients
1415  // selected block size.
1416  const auto prevBufferSize = mBufferSize;
1417  mBufferSize = ((max + (mBlockSize - 1)) / mBlockSize) * mBlockSize;
1418 
1419  // If the buffer size has changed, then (re)allocate the buffers
1420  if (prevBufferSize != mBufferSize)
1421  {
1422  // Always create the number of input buffers the client expects even if we don't have
1423  // the same number of channels.
1424  inBufPos.reinit( mNumAudioIn );
1425  inBuffer.reinit( mNumAudioIn, mBufferSize );
1426 
1427  // We won't be using more than the first 2 buffers, so clear the rest (if any)
1428  for (size_t i = 2; i < mNumAudioIn; i++)
1429  {
1430  for (size_t j = 0; j < mBufferSize; j++)
1431  {
1432  inBuffer[i][j] = 0.0;
1433  }
1434  }
1435 
1436  // Always create the number of output buffers the client expects even if we don't have
1437  // the same number of channels.
1438  // Output buffers get an extra mBlockSize worth to give extra room if
1439  // the plugin adds latency
1440  outBufPos.reinit( mNumAudioOut );
1441  outBuffer.reinit( mNumAudioOut, mBufferSize + mBlockSize );
1442  }
1443 
1444  // (Re)Set the input buffer positions
1445  for (size_t i = 0; i < mNumAudioIn; i++)
1446  {
1447  inBufPos[i] = inBuffer[i].get();
1448  }
1449 
1450  // (Re)Set the output buffer positions
1451  for (size_t i = 0; i < mNumAudioOut; i++)
1452  {
1453  outBufPos[i] = outBuffer[i].get();
1454  }
1455 
1456  // Clear unused input buffers
1457  if (!right && !clear && mNumAudioIn > 1)
1458  {
1459  for (size_t j = 0; j < mBufferSize; j++)
1460  {
1461  inBuffer[1][j] = 0.0;
1462  }
1463  clear = true;
1464  }
1465 
1466  // Go process the track(s)
1467  bGoodResult = ProcessTrack(
1468  count, map, left, right, leftStart, rightStart, len,
1469  inBuffer, outBuffer, inBufPos, outBufPos);
1470  if (!bGoodResult)
1471  {
1472  break;
1473  }
1474 
1475  count++;
1476  }
1477 
1478  if (bGoodResult && GetType() == EffectTypeGenerate)
1479  {
1480  mT1 = mT0 + mDuration;
1481  }
1482 
1483  return bGoodResult;
1484 }
double mT1
Definition: Effect.h:461
bool GetSelected() const
Definition: Track.h:276
size_t SetBlockSize(size_t maxBlockSize) override
Definition: Effect.cpp:332
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:117
bool IsSyncLockSelected() const
Definition: Track.cpp:295
bool GetLinked() const
Definition: Track.h:279
size_t mBufferSize
Definition: Effect.h:531
void SetSampleRate(double rate) override
Definition: Effect.cpp:322
void GetSamples(const WaveTrack *track, sampleCount *start, sampleCount *len)
Definition: Effect.cpp:2001
size_t mNumAudioIn
Definition: Effect.h:528
virtual int GetKind() const
Definition: Track.h:330
size_t mNumAudioOut
Definition: Effect.h:529
EffectType GetType() override
Definition: Effect.cpp:148
size_t mBlockSize
Definition: Effect.h:532
ChannelName
Definition: Types.h:215
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
size_t GetMaxBlockSize() const
Definition: WaveTrack.cpp:1625
An iterator for a TrackList.
Definition: Track.h:402
unsigned mNumChannels
Definition: Effect.h:533
bool ProcessTrack(int count, ChannelNames map, WaveTrack *left, WaveTrack *right, sampleCount leftStart, sampleCount rightStart, sampleCount len, FloatBuffers &inBuffer, FloatBuffers &outBuffer, ArrayOf< float * > &inBufPos, ArrayOf< float * > &outBufPos)
Definition: Effect.cpp:1486
void reinit(Integral count)
Definition: MemoryX.h:166
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: WaveTrack.cpp:1843
Memory.h template class for making an array of float, bool, etc.
Definition: MemoryX.h:86
double mDuration
Definition: Effect.h:513
sampleCount mSampleCnt
Definition: Effect.h:475
double GetRate() const
Definition: WaveTrack.cpp:398
virtual void SyncLockAdjust(double oldT1, double newT1)
Definition: Track.cpp:320
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:459
virtual int GetChannel() const override
Definition: WaveTrack.cpp:236
double mT0
Definition: Effect.h:460
bool Effect::ProcessTrack ( int  count,
ChannelNames  map,
WaveTrack left,
WaveTrack right,
sampleCount  leftStart,
sampleCount  rightStart,
sampleCount  len,
FloatBuffers inBuffer,
FloatBuffers outBuffer,
ArrayOf< float * > &  inBufPos,
ArrayOf< float * > &  outBufPos 
)
private

Definition at line 1486 of file Effect.cpp.

References CalcPreviewInputLength(), WaveTrack::ClearAndPaste(), EffectTypeGenerate, EffectTypeProcess, floatSample, WaveTrack::Get(), GetActiveProject(), GetLatency(), WaveTrack::GetRate(), WaveTrack::GetSampleFormat(), AudacityProject::GetSel1(), GetType(), WaveTrack::GetWaveColorIndex(), gPrefs, limitSampleBufferSize(), mBlockSize, mBufferSize, mDuration, mFactory, mIsPreview, mNumAudioOut, mNumChannels, mT0, mT1, TrackFactory::NewWaveTrack(), ProcessBlock(), ProcessFinalize(), ProcessInitialize(), WaveTrack::Set(), TrackGroupProgress(), and TrackProgress().

Referenced by ProcessPass().

1497 {
1498  bool rc = true;
1499 
1500  // Give the plugin a chance to initialize
1501  if (!ProcessInitialize(len, map))
1502  {
1503  return false;
1504  }
1505 
1506  { // Start scope for cleanup
1507  auto cleanup = finally( [&] {
1508  // Allow the plugin to cleanup
1509  if (!ProcessFinalize())
1510  {
1511  // In case of non-exceptional flow of control, set rc
1512  rc = false;
1513  }
1514  } );
1515 
1516  // For each input block of samples, we pass it to the effect along with a
1517  // variable output location. This output location is simply a pointer into a
1518  // much larger buffer. This reduces the number of calls required to add the
1519  // samples to the output track.
1520  //
1521  // Upon return from the effect, the output samples are "moved to the left" by
1522  // the number of samples in the current latency setting, effectively removing any
1523  // delay introduced by the effect.
1524  //
1525  // At the same time the total number of delayed samples are gathered and when
1526  // there is no further input data to process, the loop continues to call the
1527  // effect with an empty input buffer until the effect has had a chance to
1528  // return all of the remaining delayed samples.
1529  auto inLeftPos = leftStart;
1530  auto inRightPos = rightStart;
1531  auto outLeftPos = leftStart;
1532  auto outRightPos = rightStart;
1533 
1534  auto inputRemaining = len;
1535  decltype(GetLatency()) curDelay = 0, delayRemaining = 0;
1536  decltype(mBlockSize) curBlockSize = 0;
1537 
1538  decltype(mBufferSize) inputBufferCnt = 0;
1539  decltype(mBufferSize) outputBufferCnt = 0;
1540  bool cleared = false;
1541 
1542  auto chans = std::min<unsigned>(mNumAudioOut, mNumChannels);
1543 
1544  std::unique_ptr<WaveTrack> genLeft, genRight;
1545 
1546  decltype(len) genLength = 0;
1547  bool isGenerator = GetType() == EffectTypeGenerate;
1548  bool isProcessor = GetType() == EffectTypeProcess;
1549  double genDur = 0;
1550  if (isGenerator)
1551  {
1552  if (mIsPreview) {
1553  gPrefs->Read(wxT("/AudioIO/EffectsPreviewLen"), &genDur, 6.0);
1554  genDur = wxMin(mDuration, CalcPreviewInputLength(genDur));
1555  }
1556  else {
1557  genDur = mDuration;
1558  }
1559 
1560  genLength = sampleCount((left->GetRate() * genDur) + 0.5); // round to nearest sample
1561  delayRemaining = genLength;
1562  cleared = true;
1563 
1564  // Create temporary tracks
1565  genLeft = mFactory->NewWaveTrack(left->GetSampleFormat(), left->GetRate());
1566  genLeft->SetWaveColorIndex( left->GetWaveColorIndex() );
1567 
1568  if (right)
1569  {
1570  genRight = mFactory->NewWaveTrack(right->GetSampleFormat(), right->GetRate());
1571  genRight->SetWaveColorIndex( right->GetWaveColorIndex() );
1572  }
1573  }
1574 
1575  // Call the effect until we run out of input or delayed samples
1576  while (inputRemaining != 0 || delayRemaining != 0)
1577  {
1578  // Still working on the input samples
1579  if (inputRemaining != 0)
1580  {
1581  // Need to refill the input buffers
1582  if (inputBufferCnt == 0)
1583  {
1584  // Calculate the number of samples to get
1585  inputBufferCnt =
1586  limitSampleBufferSize( mBufferSize, inputRemaining );
1587 
1588  // Fill the input buffers
1589  left->Get((samplePtr) inBuffer[0].get(), floatSample, inLeftPos, inputBufferCnt);
1590  if (right)
1591  {
1592  right->Get((samplePtr) inBuffer[1].get(), floatSample, inRightPos, inputBufferCnt);
1593  }
1594 
1595  // Reset the input buffer positions
1596  for (size_t i = 0; i < mNumChannels; i++)
1597  {
1598  inBufPos[i] = inBuffer[i].get();
1599  }
1600  }
1601 
1602  // Calculate the number of samples to process
1603  curBlockSize = mBlockSize;
1604  if (curBlockSize > inputRemaining)
1605  {
1606  // We've reached the last block...set current block size to what's left
1607  // inputRemaining is positive and bounded by a size_t
1608  curBlockSize = inputRemaining.as_size_t();
1609  inputRemaining = 0;
1610 
1611  // Clear the remainder of the buffers so that a full block can be passed
1612  // to the effect
1613  auto cnt = mBlockSize - curBlockSize;
1614  for (size_t i = 0; i < mNumChannels; i++)
1615  {
1616  for (decltype(cnt) j = 0 ; j < cnt; j++)
1617  {
1618  inBufPos[i][j + curBlockSize] = 0.0;
1619  }
1620  }
1621 
1622  // Might be able to use up some of the delayed samples
1623  if (delayRemaining != 0)
1624  {
1625  // Don't use more than needed
1626  cnt = limitSampleBufferSize(cnt, delayRemaining);
1627  delayRemaining -= cnt;
1628  curBlockSize += cnt;
1629  }
1630  }
1631  }
1632  // We've exhausted the input samples and are now working on the delay
1633  else if (delayRemaining != 0)
1634  {
1635  // Calculate the number of samples to process
1636  curBlockSize = limitSampleBufferSize( mBlockSize, delayRemaining );
1637  delayRemaining -= curBlockSize;
1638 
1639  // From this point on, we only want to feed zeros to the plugin
1640  if (!cleared)
1641  {
1642  // Reset the input buffer positions
1643  for (size_t i = 0; i < mNumChannels; i++)
1644  {
1645  inBufPos[i] = inBuffer[i].get();
1646 
1647  // And clear
1648  for (size_t j = 0; j < mBlockSize; j++)
1649  {
1650  inBuffer[i][j] = 0.0;
1651  }
1652  }
1653  cleared = true;
1654  }
1655  }
1656 
1657  // Finally call the plugin to process the block
1658  decltype(curBlockSize) processed;
1659  try
1660  {
1661  processed = ProcessBlock(inBufPos.get(), outBufPos.get(), curBlockSize);
1662  }
1663  catch( const AudacityException & WXUNUSED(e) )
1664  {
1665  // PRL: Bug 437:
1666  // Pass this along to our application-level handler
1667  throw;
1668  }
1669  catch(...)
1670  {
1671  // PRL:
1672  // Exceptions for other reasons, maybe in third-party code...
1673  // Continue treating them as we used to, but I wonder if these
1674  // should now be treated the same way.
1675  return false;
1676  }
1677  wxASSERT(processed == curBlockSize);
1678  wxUnusedVar(processed);
1679 
1680  // Bump to next input buffer position
1681  if (inputRemaining != 0)
1682  {
1683  for (size_t i = 0; i < mNumChannels; i++)
1684  {
1685  inBufPos[i] += curBlockSize;
1686  }
1687  inputRemaining -= curBlockSize;
1688  inputBufferCnt -= curBlockSize;
1689  }
1690 
1691  // "ls" and "rs" serve as the input sample index for the left and
1692  // right channels when processing the input samples. If we flip
1693  // over to processing delayed samples, they simply become counters
1694  // for the progress display.
1695  inLeftPos += curBlockSize;
1696  inRightPos += curBlockSize;
1697 
1698  // Get the current number of delayed samples and accumulate
1699  if (isProcessor)
1700  {
1701  auto delay = GetLatency();
1702  curDelay += delay;
1703  delayRemaining += delay;
1704 
1705  // If the plugin has delayed the output by more samples than our current
1706  // block size, then we leave the output pointers alone. This effectively
1707  // removes those delayed samples from the output buffer.
1708  if (curDelay >= curBlockSize)
1709  {
1710  curDelay -= curBlockSize;
1711  curBlockSize = 0;
1712  }
1713  // We have some delayed samples, at the beginning of the output samples,
1714  // so overlay them by shifting the remaining output samples.
1715  else if (curDelay > 0)
1716  {
1717  // curDelay is bounded by curBlockSize:
1718  auto delay = curDelay.as_size_t();
1719  curBlockSize -= delay;
1720  for (size_t i = 0; i < chans; i++)
1721  {
1722  memmove(outBufPos[i], outBufPos[i] + delay, sizeof(float) * curBlockSize);
1723  }
1724  curDelay = 0;
1725  }
1726  }
1727 
1728  // Adjust the number of samples in the output buffers
1729  outputBufferCnt += curBlockSize;
1730 
1731  // Still have room in the output buffers
1732  if (outputBufferCnt < mBufferSize)
1733  {
1734  // Bump to next output buffer position
1735  for (size_t i = 0; i < chans; i++)
1736  {
1737  outBufPos[i] += curBlockSize;
1738  }
1739  }
1740  // Output buffers have filled
1741  else
1742  {
1743  if (isProcessor)
1744  {
1745  // Write them out
1746  left->Set((samplePtr) outBuffer[0].get(), floatSample, outLeftPos, outputBufferCnt);
1747  if (right)
1748  {
1749  if (chans >= 2)
1750  {
1751  right->Set((samplePtr) outBuffer[1].get(), floatSample, outRightPos, outputBufferCnt);
1752  }
1753  else
1754  {
1755  right->Set((samplePtr) outBuffer[0].get(), floatSample, outRightPos, outputBufferCnt);
1756  }
1757  }
1758  }
1759  else if (isGenerator)
1760  {
1761  genLeft->Append((samplePtr) outBuffer[0].get(), floatSample, outputBufferCnt);
1762  if (genRight)
1763  {
1764  genRight->Append((samplePtr) outBuffer[1].get(), floatSample, outputBufferCnt);
1765  }
1766  }
1767 
1768  // Reset the output buffer positions
1769  for (size_t i = 0; i < chans; i++)
1770  {
1771  outBufPos[i] = outBuffer[i].get();
1772  }
1773 
1774  // Bump to the next track position
1775  outLeftPos += outputBufferCnt;
1776  outRightPos += outputBufferCnt;
1777  outputBufferCnt = 0;
1778  }
1779 
1780  if (mNumChannels > 1)
1781  {
1782  if (TrackGroupProgress(count,
1783  (inLeftPos - leftStart).as_double() /
1784  (isGenerator ? genLength : len).as_double()))
1785  {
1786  rc = false;
1787  break;
1788  }
1789  }
1790  else
1791  {
1792  if (TrackProgress(count,
1793  (inLeftPos - leftStart).as_double() /
1794  (isGenerator ? genLength : len).as_double()))
1795  {
1796  rc = false;
1797  break;
1798  }
1799  }
1800  }
1801 
1802  // Put any remaining output
1803  if (rc && outputBufferCnt)
1804  {
1805  if (isProcessor)
1806  {
1807  left->Set((samplePtr) outBuffer[0].get(), floatSample, outLeftPos, outputBufferCnt);
1808  if (right)
1809  {
1810  if (chans >= 2)
1811  {
1812  right->Set((samplePtr) outBuffer[1].get(), floatSample, outRightPos, outputBufferCnt);
1813  }
1814  else
1815  {
1816  right->Set((samplePtr) outBuffer[0].get(), floatSample, outRightPos, outputBufferCnt);
1817  }
1818  }
1819  }
1820  else if (isGenerator)
1821  {
1822  genLeft->Append((samplePtr) outBuffer[0].get(), floatSample, outputBufferCnt);
1823  if (genRight)
1824  {
1825  genRight->Append((samplePtr) outBuffer[1].get(), floatSample, outputBufferCnt);
1826  }
1827  }
1828  }
1829 
1830  if (rc && isGenerator)
1831  {
1833 
1834  // PRL: this code was here and could not have been the right
1835  // intent, mixing time and sampleCount values:
1836  // StepTimeWarper warper(mT0 + genLength, genLength - (mT1 - mT0));
1837 
1838  // This looks like what it should have been:
1839  // StepTimeWarper warper(mT0 + genDur, genDur - (mT1 - mT0));
1840  // But rather than fix it, I will just disable the use of it for now.
1841  // The purpose was to remap split lines inside the selected region when
1842  // a generator replaces it with sound of different duration. But
1843  // the "correct" version might have the effect of mapping some splits too
1844  // far left, to before the selection.
1845  // In practice the wrong version probably did nothing most of the time,
1846  // because the cutoff time for the step time warper was 44100 times too
1847  // far from mT0.
1848 
1849  // Transfer the data from the temporary tracks to the actual ones
1850  genLeft->Flush();
1851  // mT1 gives us the NEW selection. We want to replace up to GetSel1().
1852  left->ClearAndPaste(mT0, p->GetSel1(), genLeft.get(), true, true,
1853  nullptr /* &warper */);
1854 
1855  if (genRight)
1856  {
1857  genRight->Flush();
1858  right->ClearAndPaste(mT0, mT1, genRight.get(), true, true,
1859  nullptr /* &warper */);
1860  }
1861  }
1862 
1863  } // End scope for cleanup
1864  return rc;
1865 }
double mT1
Definition: Effect.h:461
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
bool TrackProgress(int whichTrack, double frac, const wxString &=wxEmptyString)
Definition: Effect.cpp:1985
root of a hierarchy of classes that are thrown and caught by Audacity.
bool mIsPreview
Definition: Effect.h:516
void ClearAndPaste(double t0, double t1, const Track *src, bool preserve=true, bool merge=true, const TimeWarper *effectWarper=NULL)
Definition: WaveTrack.cpp:782
size_t mBufferSize
Definition: Effect.h:531
int GetWaveColorIndex() const
Definition: WaveTrack.h:143
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: Types.h:178
size_t mNumAudioOut
Definition: Effect.h:529
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
EffectType GetType() override
Definition: Effect.cpp:148
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL) override
Definition: Effect.cpp:374
void Set(samplePtr buffer, sampleFormat format, sampleCount start, size_t len)
Definition: WaveTrack.cpp:2052
size_t mBlockSize
Definition: Effect.h:532
char * samplePtr
Definition: Types.h:203
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
bool ProcessFinalize() override
Definition: Effect.cpp:384
virtual double CalcPreviewInputLength(double previewLength)
Definition: Effect.cpp:2274
if(pTrack &&pTrack->GetDisplay()!=WaveTrack::Spectrum)
int min(int a, int b)
std::unique_ptr< WaveTrack > NewWaveTrack(sampleFormat format=(sampleFormat) 0, double rate=0)
Definition: WaveTrack.cpp:78
unsigned mNumChannels
Definition: Effect.h:533
TrackFactory * mFactory
Definition: Effect.h:457
sampleCount GetLatency() override
Definition: Effect.cpp:344
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
sampleFormat GetSampleFormat() const
Definition: WaveTrack.h:146
bool TrackGroupProgress(int whichGroup, double frac, const wxString &=wxEmptyString)
Definition: Effect.cpp:1993
double mDuration
Definition: Effect.h:513
double GetRate() const
Definition: WaveTrack.cpp:398
bool Get(samplePtr buffer, sampleFormat format, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumCopied=nullptr) const
Definition: WaveTrack.cpp:1971
double GetSel1() const
Definition: Project.h:205
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
Definition: Effect.cpp:394
double mT0
Definition: Effect.h:460
bool Effect::PromptUser ( wxWindow *  parent)
protectedvirtual

Reimplemented in EffectNoiseReduction.

Definition at line 1270 of file Effect.cpp.

References IsBatchProcessing(), and ShowInterface().

Referenced by DoEffect(), and EffectManager::PromptUser().

1271 {
1272  return ShowInterface(parent, IsBatchProcessing());
1273 }
bool ShowInterface(wxWindow *parent, bool forceModal=false) override
Definition: Effect.cpp:514
virtual bool IsBatchProcessing()
Definition: Effect.cpp:1137
bool Effect::RealtimeAddProcessor ( unsigned  numChannels,
float  sampleRate 
)
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectPhaser, and EffectWahwah.

Definition at line 417 of file Effect.cpp.

References mClient, and EffectClientInterface::RealtimeAddProcessor().

Referenced by EffectManager::RealtimeAddEffect(), and RealtimeAddProcessor().

418 {
419  if (mClient)
420  {
421  return mClient->RealtimeAddProcessor(numChannels, sampleRate);
422  }
423 
424  return true;
425 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual bool RealtimeAddProcessor(unsigned numChannels, float sampleRate)=0
bool Effect::RealtimeAddProcessor ( int  group,
unsigned  chans,
float  rate 
)

Definition at line 2282 of file Effect.cpp.

References mCurrentProcessor, mGroupProcessor, mNumAudioIn, mNumAudioOut, and RealtimeAddProcessor().

2283 {
2284  auto ichans = chans;
2285  auto ochans = chans;
2286  auto gchans = chans;
2287 
2288  // Reset processor index
2289  if (group == 0)
2290  {
2291  mCurrentProcessor = 0;
2292  mGroupProcessor.clear();
2293  }
2294 
2295  // Remember the processor starting index
2297 
2298  // Call the client until we run out of input or output channels
2299  while (ichans > 0 && ochans > 0)
2300  {
2301  // If we don't have enough input channels to accomodate the client's
2302  // requirements, then we replicate the input channels until the
2303  // client's needs are met.
2304  if (ichans < mNumAudioIn)
2305  {
2306  // All input channels have been consumed
2307  ichans = 0;
2308  }
2309  // Otherwise fullfil the client's needs with as many input channels as possible.
2310  // After calling the client with this set, we will loop back up to process more
2311  // of the input/output channels.
2312  else if (ichans >= mNumAudioIn)
2313  {
2314  gchans = mNumAudioIn;
2315  ichans -= gchans;
2316  }
2317 
2318  // If we don't have enough output channels to accomodate the client's
2319  // requirements, then we provide all of the output channels and fulfill
2320  // the client's needs with dummy buffers. These will just get tossed.
2321  if (ochans < mNumAudioOut)
2322  {
2323  // All output channels have been consumed
2324  ochans = 0;
2325  }
2326  // Otherwise fullfil the client's needs with as many output channels as possible.
2327  // After calling the client with this set, we will loop back up to process more
2328  // of the input/output channels.
2329  else if (ochans >= mNumAudioOut)
2330  {
2331  ochans -= mNumAudioOut;
2332  }
2333 
2334  // Add a NEW processor
2335  RealtimeAddProcessor(gchans, rate);
2336 
2337  // Bump to next processor
2339  }
2340 
2341  return true;
2342 }
std::vector< int > mGroupProcessor
Definition: Effect.h:535
size_t mNumAudioIn
Definition: Effect.h:528
size_t mNumAudioOut
Definition: Effect.h:529
bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override
Definition: Effect.cpp:417
int mCurrentProcessor
Definition: Effect.h:536
bool Effect::RealtimeFinalize ( )
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectPhaser, and EffectWahwah.

Definition at line 427 of file Effect.cpp.

References mClient, and EffectClientInterface::RealtimeFinalize().

Referenced by EffectManager::RealtimeRemoveEffect().

428 {
429  if (mClient)
430  {
431  return mClient->RealtimeFinalize();
432  }
433 
434  return false;
435 }
virtual bool RealtimeFinalize()=0
EffectClientInterface * mClient
Definition: Effect.h:527
bool Effect::RealtimeInitialize ( )
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectPhaser, and EffectWahwah.

Definition at line 404 of file Effect.cpp.

References mBlockSize, mClient, EffectClientInterface::RealtimeInitialize(), and EffectClientInterface::SetBlockSize().

Referenced by EffectManager::RealtimeAddEffect().

405 {
406  if (mClient)
407  {
409  return mClient->RealtimeInitialize();
410  }
411 
412  mBlockSize = 512;
413 
414  return false;
415 }
virtual size_t SetBlockSize(size_t maxBlockSize)=0
EffectClientInterface * mClient
Definition: Effect.h:527
size_t mBlockSize
Definition: Effect.h:532
virtual bool RealtimeInitialize()=0
size_t Effect::RealtimeProcess ( int  group,
float **  inbuf,
float **  outbuf,
size_t  numSamples 
)
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectPhaser, and EffectWahwah.

Definition at line 491 of file Effect.cpp.

References mClient, and EffectClientInterface::RealtimeProcess().

Referenced by RealtimeProcess().

495 {
496  if (mClient)
497  {
498  return mClient->RealtimeProcess(group, inbuf, outbuf, numSamples);
499  }
500 
501  return 0;
502 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual size_t RealtimeProcess(int group, float **inBuf, float **outBuf, size_t numSamples)=0
size_t Effect::RealtimeProcess ( int  group,
unsigned  chans,
float **  inbuf,
float **  outbuf,
size_t  numSamples 
)

Definition at line 2347 of file Effect.cpp.

References mBlockSize, mGroupProcessor, min(), mNumAudioIn, mNumAudioOut, and RealtimeProcess().

2352 {
2353  //
2354  // The caller passes the number of channels to process and specifies
2355  // the number of input and output buffers. There will always be the
2356  // same number of output buffers as there are input buffers.
2357  //
2358  // Effects always require a certain number of input and output buffers,
2359  // so if the number of channels we're curently processing are different
2360  // than what the effect expects, then we use a few methods of satisfying
2361  // the effects requirements.
2362  float **clientIn = (float **) alloca(mNumAudioIn * sizeof(float *));
2363  float **clientOut = (float **) alloca(mNumAudioOut * sizeof(float *));
2364  float *dummybuf = (float *) alloca(numSamples * sizeof(float));
2365  decltype(numSamples) len = 0;
2366  auto ichans = chans;
2367  auto ochans = chans;
2368  auto gchans = chans;
2369  unsigned indx = 0;
2370  unsigned ondx = 0;
2371 
2372  int processor = mGroupProcessor[group];
2373 
2374  // Call the client until we run out of input or output channels
2375  while (ichans > 0 && ochans > 0)
2376  {
2377  // If we don't have enough input channels to accomodate the client's
2378  // requirements, then we replicate the input channels until the
2379  // client's needs are met.
2380  if (ichans < mNumAudioIn)
2381  {
2382  for (size_t i = 0; i < mNumAudioIn; i++)
2383  {
2384  if (indx == ichans)
2385  {
2386  indx = 0;
2387  }
2388  clientIn[i] = inbuf[indx++];
2389  }
2390 
2391  // All input channels have been consumed
2392  ichans = 0;
2393  }
2394  // Otherwise fullfil the client's needs with as many input channels as possible.
2395  // After calling the client with this set, we will loop back up to process more
2396  // of the input/output channels.
2397  else if (ichans >= mNumAudioIn)
2398  {
2399  gchans = 0;
2400  for (size_t i = 0; i < mNumAudioIn; i++, ichans--, gchans++)
2401  {
2402  clientIn[i] = inbuf[indx++];
2403  }
2404  }
2405 
2406  // If we don't have enough output channels to accomodate the client's
2407  // requirements, then we provide all of the output channels and fulfill
2408  // the client's needs with dummy buffers. These will just get tossed.
2409  if (ochans < mNumAudioOut)
2410  {
2411  for (size_t i = 0; i < mNumAudioOut; i++)
2412  {
2413  if (i < ochans)
2414  {
2415  clientOut[i] = outbuf[i];
2416  }
2417  else
2418  {
2419  clientOut[i] = dummybuf;
2420  }
2421  }
2422 
2423  // All output channels have been consumed
2424  ochans = 0;
2425  }
2426  // Otherwise fullfil the client's needs with as many output channels as possible.
2427  // After calling the client with this set, we will loop back up to process more
2428  // of the input/output channels.
2429  else if (ochans >= mNumAudioOut)
2430  {
2431  for (size_t i = 0; i < mNumAudioOut; i++, ochans--)
2432  {
2433  clientOut[i] = outbuf[ondx++];
2434  }
2435  }
2436 
2437  // Finally call the plugin to process the block
2438  len = 0;
2439  for (decltype(numSamples) block = 0; block < numSamples; block += mBlockSize)
2440  {
2441  auto cnt = std::min(numSamples - block, mBlockSize);
2442  len += RealtimeProcess(processor, clientIn, clientOut, cnt);
2443 
2444  for (size_t i = 0 ; i < mNumAudioIn; i++)
2445  {
2446  clientIn[i] += cnt;
2447  }
2448 
2449  for (size_t i = 0 ; i < mNumAudioOut; i++)
2450  {
2451  clientOut[i] += cnt;
2452  }
2453  }
2454 
2455  // Bump to next processor
2456  processor++;
2457  }
2458 
2459  return len;
2460 }
std::vector< int > mGroupProcessor
Definition: Effect.h:535
size_t RealtimeProcess(int group, float **inbuf, float **outbuf, size_t numSamples) override
Definition: Effect.cpp:491
size_t mNumAudioIn
Definition: Effect.h:528
size_t mNumAudioOut
Definition: Effect.h:529
size_t mBlockSize
Definition: Effect.h:532
int min(int a, int b)
bool Effect::RealtimeProcessEnd ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 504 of file Effect.cpp.

References mClient, and EffectClientInterface::RealtimeProcessEnd().

505 {
506  if (mClient)
507  {
508  return mClient->RealtimeProcessEnd();
509  }
510 
511  return true;
512 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual bool RealtimeProcessEnd()=0
bool Effect::RealtimeProcessStart ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 481 of file Effect.cpp.

References mClient, and EffectClientInterface::RealtimeProcessStart().

482 {
483  if (mClient)
484  {
485  return mClient->RealtimeProcessStart();
486  }
487 
488  return true;
489 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual bool RealtimeProcessStart()=0
bool Effect::RealtimeResume ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 459 of file Effect.cpp.

References mClient, mRealtimeSuspendCount, mRealtimeSuspendLock, and EffectClientInterface::RealtimeResume().

Referenced by EffectUIHost::Resume().

460 {
461  if (mClient)
462  {
463  if (mClient->RealtimeResume())
464  {
465  mRealtimeSuspendLock.Enter();
467  mRealtimeSuspendLock.Leave();
468  return true;
469  }
470 
471  return false;
472  }
473 
474  mRealtimeSuspendLock.Enter();
476  mRealtimeSuspendLock.Leave();
477 
478  return true;
479 }
EffectClientInterface * mClient
Definition: Effect.h:527
wxCriticalSection mRealtimeSuspendLock
Definition: Effect.h:538
int mRealtimeSuspendCount
Definition: Effect.h:539
virtual bool RealtimeResume()=0
bool Effect::RealtimeSuspend ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 437 of file Effect.cpp.

References mClient, mRealtimeSuspendCount, mRealtimeSuspendLock, and EffectClientInterface::RealtimeSuspend().

Referenced by EffectUIHost::OnEnable().

438 {
439  if (mClient)
440  {
441  if (mClient->RealtimeSuspend())
442  {
443  mRealtimeSuspendLock.Enter();
445  mRealtimeSuspendLock.Leave();
446  return true;
447  }
448 
449  return false;
450  }
451 
452  mRealtimeSuspendLock.Enter();
454  mRealtimeSuspendLock.Leave();
455 
456  return true;
457 }
EffectClientInterface * mClient
Definition: Effect.h:527
wxCriticalSection mRealtimeSuspendLock
Definition: Effect.h:538
virtual bool RealtimeSuspend()=0
int mRealtimeSuspendCount
Definition: Effect.h:539
bool Effect::RemovePrivateConfig ( const wxString &  group,
const wxString &  key 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 952 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::RemovePrivateConfig().

953 {
954  return PluginManager::Get().RemovePrivateConfig(GetID(), group, key);
955 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool RemovePrivateConfig(const PluginID &ID, const wxString &group, const wxString &key) override
static PluginManager & Get()
bool Effect::RemovePrivateConfigSubgroup ( const wxString &  group)
overridevirtual

Implements ConfigClientInterface.

Definition at line 947 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::RemovePrivateConfigSubgroup().

Referenced by EffectUIHost::OnDeletePreset().

948 {
950 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool RemovePrivateConfigSubgroup(const PluginID &ID, const wxString &group) override
static PluginManager & Get()
bool Effect::RemoveSharedConfig ( const wxString &  group,
const wxString &  key 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 882 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::RemoveSharedConfig().

883 {
884  return PluginManager::Get().RemoveSharedConfig(GetID(), group, key);
885 }
bool RemoveSharedConfig(const PluginID &ID, const wxString &group, const wxString &key) override
virtual PluginID GetID()
Definition: Effect.cpp:959
static PluginManager & Get()
bool Effect::RemoveSharedConfigSubgroup ( const wxString &  group)
overridevirtual

Implements ConfigClientInterface.

Definition at line 877 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::RemoveSharedConfigSubgroup().

878 {
880 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool RemoveSharedConfigSubgroup(const PluginID &ID, const wxString &group) override
static PluginManager & Get()
void Effect::ReplaceProcessedTracks ( const bool  bGoodResult)
protected

Definition at line 2162 of file Effect.cpp.

References TrackList::Add(), ODManager::Instance, ODManager::IsInstanceCreated(), mIMap, mOMap, mOutputTracks, mOutputTracksType, mTracks, Track::None, TrackList::Remove(), TrackList::Replace(), and ODManager::ReplaceWaveTrack().

Referenced by DoEffect(), Preview(), EffectTwoPassSimpleMono::Process(), EffectSimpleMono::Process(), EffectRepair::Process(), EffectReverse::Process(), EffectStereoToMono::Process(), EffectPaulstretch::Process(), EffectNoiseReduction::Process(), EffectRepeat::Process(), EffectNormalize::Process(), Generator::Process(), EffectClickRemoval::Process(), EffectAutoDuck::Process(), EffectChangeSpeed::Process(), EffectTruncSilence::Process(), NyquistEffect::Process(), EffectEqualization::Process(), and Process().

2163 {
2164  if (!bGoodResult) {
2165  // Free resources, unless already freed.
2166 
2167  // Processing failed or was cancelled so throw away the processed tracks.
2168  if ( mOutputTracks )
2169  mOutputTracks->Clear();
2170 
2171  // Reset map
2172  mIMap.clear();
2173  mOMap.clear();
2174 
2176 
2177  //TODO:undo the non-gui ODTask transfer
2178  return;
2179  }
2180 
2181  // Assume resources need to be freed.
2182  wxASSERT(mOutputTracks); // Make sure we at least did the CopyInputTracks().
2183 
2184  auto iterOut = mOutputTracks->ListOfTracks::begin(),
2185  iterEnd = mOutputTracks->ListOfTracks::end();
2186 
2187  size_t cnt = mOMap.size();
2188  size_t i = 0;
2189 
2190  for (; iterOut != iterEnd; ++i) {
2191  ListOfTracks::value_type o = std::move(*iterOut);
2192  // If tracks were removed from mOutputTracks, then there will be
2193  // tracks in the map that must be removed from mTracks.
2194  while (i < cnt && mOMap[i] != o.get()) {
2195  const auto t = mIMap[i];
2196  if (t) {
2197  mTracks->Remove(t);
2198  }
2199  i++;
2200  }
2201 
2202  // This should never happen
2203  wxASSERT(i < cnt);
2204 
2205  // Remove the track from the output list...don't DELETE it
2206  iterOut = mOutputTracks->erase(iterOut);
2207 
2208  const auto t = mIMap[i];
2209  if (t == NULL)
2210  {
2211  // This track is a NEW addition to output tracks; add it to mTracks
2212  mTracks->Add(std::move(o));
2213  }
2214  else
2215  {
2216  // Replace mTracks entry with the NEW track
2217  WaveTrack *newTrack = static_cast<WaveTrack*>(o.get());
2218  mTracks->Replace(t, std::move(o));
2219 
2220  // Swap the wavecache track the ondemand task uses, since now the NEW
2221  // one will be kept in the project
2224  newTrack);
2225  }
2226  }
2227  }
2228 
2229  // If tracks were removed from mOutputTracks, then there may be tracks
2230  // left at the end of the map that must be removed from mTracks.
2231  while (i < cnt) {
2232  const auto t = mIMap[i];
2233  if (t) {
2234  mTracks->Remove(t);
2235  }
2236  i++;
2237  }
2238 
2239  // Reset map
2240  mIMap.clear();
2241  mOMap.clear();
2242 
2243  // Make sure we processed everything
2244  wxASSERT(mOutputTracks->empty());
2245 
2246  // The output list is no longer needed
2247  mOutputTracks.reset();
2249 }
static bool IsInstanceCreated()
returns whether or not the singleton instance was created yet
Definition: ODManager.cpp:205
static ODManager *(* Instance)()
Definition: ODManager.h:49
TrackList * mTracks
Definition: Effect.h:505
int mOutputTracksType
Definition: Effect.h:478
void ReplaceWaveTrack(WaveTrack *oldTrack, WaveTrack *newTrack)
replace the wavetrack whose wavecache the gui watches for updates
Definition: ODManager.cpp:384
Track * Add(std::unique_ptr< TrackKind > &&t)
Add a Track, giving it a fresh id.
Definition: Track.cpp:906
std::vector< Track * > mOMap
Definition: Effect.h:521
ListOfTracks::value_type Replace(Track *t, ListOfTracks::value_type &&with)
Definition: Track.cpp:963
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
std::vector< Track * > mIMap
Definition: Effect.h:520
TrackNodePointer Remove(Track *t)
Definition: Track.cpp:985
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:459
bool Effect::SaveUserPreset ( const wxString &  name)
overridevirtual

Implements EffectClientInterface.

Definition at line 600 of file Effect.cpp.

References GetAutomationParameters(), mClient, EffectClientInterface::SaveUserPreset(), and SetPrivateConfig().

Referenced by NyquistEffect::Init(), EffectUIHost::OnApply(), EffectUIHost::OnSaveAs(), SetBatchProcessing(), EffectNoise::Startup(), EffectNormalize::Startup(), EffectAutoDuck::Startup(), EffectClickRemoval::Startup(), EffectCompressor::Startup(), EffectChangeSpeed::Startup(), EffectDtmf::Startup(), EffectTruncSilence::Startup(), EffectScienFilter::Startup(), EffectReverb::Startup(), EffectEqualization::Startup(), and Startup().

601 {
602  if (mClient)
603  {
604  return mClient->SaveUserPreset(name);
605  }
606 
607  wxString parms;
608  if (!GetAutomationParameters(parms))
609  {
610  return false;
611  }
612 
613  return SetPrivateConfig(name, wxT("Parameters"), parms);
614 }
EffectClientInterface * mClient
Definition: Effect.h:527
bool SetPrivateConfig(const wxString &group, const wxString &key, const wxString &value) override
Definition: Effect.cpp:922
virtual bool SaveUserPreset(const wxString &name)=0
bool GetAutomationParameters(CommandParameters &parms) override
Definition: Effect.cpp:564
const wxChar * name
Definition: Distortion.cpp:94
bool Effect::SetAutomationParameters ( CommandParameters parms)
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectEqualization, NyquistEffect, EffectPhaser, EffectWahwah, EffectReverb, EffectScienFilter, EffectTruncSilence, EffectToneGen, EffectNoise, EffectNormalize, EffectFindClipping, EffectRepeat, and EffectPaulstretch.

Definition at line 574 of file Effect.cpp.

References mClient, and EffectClientInterface::SetAutomationParameters().

Referenced by LoadUserPreset(), SetAutomationParameters(), and EffectManager::SetEffectParameters().

575 {
576  if (mClient)
577  {
578  return mClient->SetAutomationParameters(parms);
579  }
580 
581  return true;
582 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual bool SetAutomationParameters(CommandParameters &parms)=0
bool Effect::SetAutomationParameters ( const wxString &  parms)
virtual

Definition at line 1025 of file Effect.cpp.

References _(), ShuttleSetAutomation::bOK, ParamsInterface::DefineParams(), GetCurrentSettingsGroup(), GetFactoryDefaultsGroup(), GetFactoryPresets(), IdentInterface::GetTranslatedName(), GetUserPresetsGroup(), kCurrentSettingsIdent, kFactoryDefaultsIdent, kFactoryPresetIdent, kUserPresetIdent, LoadFactoryPreset(), LoadUserPreset(), MessageBox(), mUIDialog, SetAutomationParameters(), ShuttleSetAutomation::SetForValidating(), ShuttleSetAutomation::SetForWriting(), and TransferDataToWindow().

1026 {
1027  wxString preset = parms;
1028  bool success = false;
1029  if (preset.StartsWith(kUserPresetIdent))
1030  {
1031  preset.Replace(kUserPresetIdent, wxEmptyString, false);
1032  success = LoadUserPreset(GetUserPresetsGroup(preset));
1033  }
1034  else if (preset.StartsWith(kFactoryPresetIdent))
1035  {
1036  preset.Replace(kFactoryPresetIdent, wxEmptyString, false);
1037  wxArrayString presets = GetFactoryPresets();
1038  success = LoadFactoryPreset(presets.Index(preset));
1039  }
1040  else if (preset.StartsWith(kCurrentSettingsIdent))
1041  {
1042  preset.Replace(kCurrentSettingsIdent, wxEmptyString, false);
1044  }
1045  else if (preset.StartsWith(kFactoryDefaultsIdent))
1046  {
1047  preset.Replace(kFactoryDefaultsIdent, wxEmptyString, false);
1049  }
1050  else
1051  {
1052  CommandParameters eap(parms);
1054  S.SetForValidating( &eap );
1055  // DefineParams returns false if not defined for this effect.
1056  if( !DefineParams( S ) )
1057  // the old method...
1058  success = SetAutomationParameters(eap);
1059  else if( !S.bOK )
1060  success = false;
1061  else{
1062  success = true;
1063  S.SetForWriting( &eap );
1064  DefineParams( S );
1065  }
1066  }
1067 
1068  if (!success)
1069  {
1071  wxString::Format(
1072  _("%s: Could not load settings below. Default settings will be used.\n\n%s"),
1074  preset
1075  )
1076  );
1077 
1078  return false;
1079  }
1080 
1081  if (!mUIDialog)
1082  {
1083  return true;
1084  }
1085 
1086  return TransferDataToWindow();
1087 }
wxString GetUserPresetsGroup(const wxString &name) override
Definition: Effect.cpp:790
void SetForWriting(CommandParameters *pEap)
Definition: Shuttle.h:114
int MessageBox(const wxString &message, long style=DefaultMessageBoxStyle, const wxString &titleStr=wxString{})
Definition: Effect.cpp:2646
wxString GetCurrentSettingsGroup() override
Definition: Effect.cpp:801
bool SetAutomationParameters(CommandParameters &parms) override
Definition: Effect.cpp:574
virtual bool TransferDataToWindow()
Definition: Effect.cpp:1876
bool LoadUserPreset(const wxString &name) override
Definition: Effect.cpp:584
wxArrayString GetFactoryPresets() override
Definition: Effect.cpp:616
static const wxString kUserPresetIdent
Definition: Effect.h:541
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
bool LoadFactoryPreset(int id) override
Definition: Effect.cpp:626
const wxString & GetTranslatedName()
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxDialog * mUIDialog
Definition: Effect.h:471
virtual bool DefineParams(ShuttleParams &WXUNUSED(S))
Shuttle that sets parameters to a value (from a string)
Definition: Shuttle.h:105
static const wxString kFactoryPresetIdent
Definition: Effect.h:542
static const wxString kCurrentSettingsIdent
Definition: Effect.h:543
void SetForValidating(CommandParameters *pEap)
Definition: Shuttle.h:113
wxString GetFactoryDefaultsGroup() override
Definition: Effect.cpp:806
static const wxString kFactoryDefaultsIdent
Definition: Effect.h:544
void Effect::SetBatchProcessing ( bool  start)
virtual

Definition at line 1142 of file Effect.cpp.

References GetSavedStateGroup(), LoadUserPreset(), mIsBatch, and SaveUserPreset().

Referenced by EffectManager::SetBatchProcessing().

1143 {
1144  mIsBatch = start;
1145 
1146  if (start)
1147  {
1149  }
1150  else
1151  {
1153  }
1154 }
bool SaveUserPreset(const wxString &name) override
Definition: Effect.cpp:600
bool LoadUserPreset(const wxString &name) override
Definition: Effect.cpp:584
bool mIsBatch
Definition: Effect.h:507
virtual wxString GetSavedStateGroup()
Definition: Effect.cpp:811
size_t Effect::SetBlockSize ( size_t  maxBlockSize)
overridevirtual

Implements EffectClientInterface.

Definition at line 332 of file Effect.cpp.

References mBlockSize, mClient, and EffectClientInterface::SetBlockSize().

Referenced by ProcessPass(), EffectBassTreble::RealtimeInitialize(), EffectWahwah::RealtimeInitialize(), EffectPhaser::RealtimeInitialize(), and EffectDistortion::RealtimeInitialize().

333 {
334  if (mClient)
335  {
336  return mClient->SetBlockSize(maxBlockSize);
337  }
338 
339  mBlockSize = maxBlockSize;
340 
341  return mBlockSize;
342 }
virtual size_t SetBlockSize(size_t maxBlockSize)=0
EffectClientInterface * mClient
Definition: Effect.h:527
size_t mBlockSize
Definition: Effect.h:532
void Effect::SetDuration ( double  duration)
overridevirtual

Implements EffectHostInterface.

Definition at line 742 of file Effect.cpp.

References EffectTypeGenerate, GetCurrentSettingsGroup(), GetType(), mDuration, mIsSelection, and SetPrivateConfig().

Referenced by EffectDtmf::OnDuration(), EffectDtmf::Recalculate(), EffectSilence::TransferDataFromWindow(), EffectNoise::TransferDataFromWindow(), EffectToneGen::TransferDataFromWindow(), and EffectDtmf::TransferDataFromWindow().

743 {
744  if (seconds < 0.0)
745  {
746  seconds = 0.0;
747  }
748 
749  if (GetType() == EffectTypeGenerate)
750  {
751  SetPrivateConfig(GetCurrentSettingsGroup(), wxT("LastUsedDuration"), seconds);
752  }
753 
754  mDuration = seconds;
755 
756  mIsSelection = false;
757 
758  return;
759 }
wxString GetCurrentSettingsGroup() override
Definition: Effect.cpp:801
bool SetPrivateConfig(const wxString &group, const wxString &key, const wxString &value) override
Definition: Effect.cpp:922
bool mIsSelection
Definition: Effect.h:512
EffectType GetType() override
Definition: Effect.cpp:148
double mDuration
Definition: Effect.h:513
bool Effect::SetHost ( EffectHostInterface host)
overridevirtual

Implements EffectClientInterface.

Definition at line 272 of file Effect.cpp.

References mClient, and EffectClientInterface::SetHost().

Referenced by Startup().

273 {
274  if (mClient)
275  {
276  return mClient->SetHost(host);
277  }
278 
279  return true;
280 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual bool SetHost(EffectHostInterface *host)=0
void Effect::SetHostUI ( EffectUIHostInterface host)
overridevirtual

Implements EffectUIClientInterface.

Definition at line 648 of file Effect.cpp.

649 {
650 }
void Effect::SetLinearEffectFlag ( bool  linearEffectFlag)
protected

Definition at line 1961 of file Effect.cpp.

References mIsLinearEffect.

Referenced by EffectEcho::EffectEcho(), EffectNoise::EffectNoise(), EffectSilence::EffectSilence(), and NyquistEffect::Parse().

1962 {
1963  mIsLinearEffect = linearEffectFlag;
1964 }
bool mIsLinearEffect
Definition: Effect.h:508
void Effect::SetPresetParameters ( const wxArrayString *  Names,
const wxArrayString *  Values 
)
inline

Definition at line 240 of file Effect.h.

Referenced by DoEffect().

240  {
241  if( Names ) mPresetNames = *Names;
242  if( Values ) mPresetValues = *Values;
243  }
wxArrayString mPresetNames
Definition: Effect.h:466
wxArrayString mPresetValues
Definition: Effect.h:467
void Effect::SetPreviewFullSelectionFlag ( bool  previewDurationFlag)
protected

Definition at line 1966 of file Effect.cpp.

References mPreviewFullSelection.

Referenced by NyquistEffect::Parse().

1967 {
1968  mPreviewFullSelection = previewDurationFlag;
1969 }
bool mPreviewFullSelection
Definition: Effect.h:510
bool Effect::SetPrivateConfig ( const wxString &  group,
const wxString &  key,
const wxString &  value 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 922 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::SetPrivateConfig().

Referenced by EffectChangeSpeed::OnChoice_Vinyl(), SaveUserPreset(), SetDuration(), EffectChangeSpeed::Startup(), EffectEqualization::Startup(), Startup(), EffectChangeSpeed::TransferDataFromWindow(), and EffectEqualization::ValidateUI().

923 {
924  return PluginManager::Get().SetPrivateConfig(GetID(), group, key, value);
925 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool SetPrivateConfig(const PluginID &ID, const wxString &group, const wxString &key, const wxString &value) override
static PluginManager & Get()
bool Effect::SetPrivateConfig ( const wxString &  group,
const wxString &  key,
const int &  value 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 927 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::SetPrivateConfig().

928 {
929  return PluginManager::Get().SetPrivateConfig(GetID(), group, key, value);
930 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool SetPrivateConfig(const PluginID &ID, const wxString &group, const wxString &key, const wxString &value) override
static PluginManager & Get()
bool Effect::SetPrivateConfig ( const wxString &  group,
const wxString &  key,
const bool &  value 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 932 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::SetPrivateConfig().

933 {
934  return PluginManager::Get().SetPrivateConfig(GetID(), group, key, value);
935 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool SetPrivateConfig(const PluginID &ID, const wxString &group, const wxString &key, const wxString &value) override
static PluginManager & Get()
bool Effect::SetPrivateConfig ( const wxString &  group,
const wxString &  key,
const float &  value 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 937 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::SetPrivateConfig().

938 {
939  return PluginManager::Get().SetPrivateConfig(GetID(), group, key, value);
940 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool SetPrivateConfig(const PluginID &ID, const wxString &group, const wxString &key, const wxString &value) override
static PluginManager & Get()
bool Effect::SetPrivateConfig ( const wxString &  group,
const wxString &  key,
const double &  value 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 942 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::SetPrivateConfig().

943 {
944  return PluginManager::Get().SetPrivateConfig(GetID(), group, key, value);
945 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool SetPrivateConfig(const PluginID &ID, const wxString &group, const wxString &key, const wxString &value) override
static PluginManager & Get()
void Effect::SetSampleRate ( double  rate)
overridevirtual

Implements EffectClientInterface.

Definition at line 322 of file Effect.cpp.

References mClient, mSampleRate, and EffectClientInterface::SetSampleRate().

Referenced by ProcessPass().

323 {
324  if (mClient)
325  {
326  mClient->SetSampleRate(rate);
327  }
328 
329  mSampleRate = rate;
330 }
EffectClientInterface * mClient
Definition: Effect.h:527
double mSampleRate
Definition: Effect.h:455
virtual void SetSampleRate(double rate)=0
bool Effect::SetSharedConfig ( const wxString &  group,
const wxString &  key,
const wxString &  value 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 852 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::SetSharedConfig().

853 {
854  return PluginManager::Get().SetSharedConfig(GetID(), group, key, value);
855 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool SetSharedConfig(const PluginID &ID, const wxString &group, const wxString &key, const wxString &value) override
static PluginManager & Get()
bool Effect::SetSharedConfig ( const wxString &  group,
const wxString &  key,
const int &  value 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 857 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::SetSharedConfig().

858 {
859  return PluginManager::Get().SetSharedConfig(GetID(), group, key, value);
860 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool SetSharedConfig(const PluginID &ID, const wxString &group, const wxString &key, const wxString &value) override
static PluginManager & Get()
bool Effect::SetSharedConfig ( const wxString &  group,
const wxString &  key,
const bool &  value 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 862 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::SetSharedConfig().

863 {
864  return PluginManager::Get().SetSharedConfig(GetID(), group, key, value);
865 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool SetSharedConfig(const PluginID &ID, const wxString &group, const wxString &key, const wxString &value) override
static PluginManager & Get()
bool Effect::SetSharedConfig ( const wxString &  group,
const wxString &  key,
const float &  value 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 867 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::SetSharedConfig().

868 {
869  return PluginManager::Get().SetSharedConfig(GetID(), group, key, value);
870 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool SetSharedConfig(const PluginID &ID, const wxString &group, const wxString &key, const wxString &value) override
static PluginManager & Get()
bool Effect::SetSharedConfig ( const wxString &  group,
const wxString &  key,
const double &  value 
)
overridevirtual

Implements ConfigClientInterface.

Definition at line 872 of file Effect.cpp.

References PluginManager::Get(), GetID(), and PluginManager::SetSharedConfig().

873 {
874  return PluginManager::Get().SetSharedConfig(GetID(), group, key, value);
875 }
virtual PluginID GetID()
Definition: Effect.cpp:959
bool SetSharedConfig(const PluginID &ID, const wxString &group, const wxString &key, const wxString &value) override
static PluginManager & Get()
bool Effect::ShowInterface ( wxWindow *  parent,
bool  forceModal = false 
)
overridevirtual

Implements EffectClientInterface.

Reimplemented in NyquistEffect.

Definition at line 514 of file Effect.cpp.

References CreateUI(), IsInteractive(), ScreenshotCommand::MayCapture(), mClient, mUIDialog, EffectClientInterface::ShowInterface(), SupportsRealtime(), and valueRestorer().

Referenced by PromptUser(), and NyquistEffect::ShowInterface().

515 {
516  if (!IsInteractive())
517  {
518  return true;
519  }
520 
521  if (mUIDialog)
522  {
523  if ( mUIDialog->Close(true) )
524  mUIDialog = nullptr;
525  return false;
526  }
527 
528  if (mClient)
529  {
530  return mClient->ShowInterface(parent, forceModal);
531  }
532 
533  // mUIDialog is null
534  auto cleanup = valueRestorer( mUIDialog );
535 
536  mUIDialog = CreateUI(parent, this);
537  if (!mUIDialog)
538  {
539  return false;
540  }
541 
542 
543  mUIDialog->Layout();
544  mUIDialog->Fit();
545  mUIDialog->SetMinSize(mUIDialog->GetSize());
546 
548  return false;
549 
550  if( SupportsRealtime() && !forceModal )
551  {
552  mUIDialog->Show();
553  cleanup.release();
554 
555  // Return false to bypass effect processing
556  return false;
557  }
558 
559  bool res = mUIDialog->ShowModal() != 0;
560 
561  return res;
562 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual bool ShowInterface(wxWindow *parent, bool forceModal=false)=0
bool IsInteractive() override
Definition: Effect.cpp:220
ValueRestorer< T > valueRestorer(T &var)
Definition: MemoryX.h:494
wxDialog * mUIDialog
Definition: Effect.h:471
wxDialog * CreateUI(wxWindow *parent, EffectUIClientInterface *client) override
Definition: Effect.cpp:776
bool SupportsRealtime() override
Definition: Effect.cpp:250
static bool MayCapture(wxDialog *pDlg)
void Effect::ShowOptions ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 711 of file Effect.cpp.

712 {
713 }
bool Effect::Startup ( EffectClientInterface client)
virtual

Definition at line 969 of file Effect.cpp.

References GetAudioInCount(), GetAudioOutCount(), GetCurrentSettingsGroup(), GetFactoryDefaultsGroup(), GetPrivateConfig(), LoadUserPreset(), mClient, mNumAudioIn, mNumAudioOut, SaveUserPreset(), SetHost(), SetPrivateConfig(), and Startup().

970 {
971  // Let destructor know we need to be shutdown
972  mClient = client;
973 
974  // Set host so client startup can use our services
975  if (!SetHost(this))
976  {
977  // Bail if the client startup fails
978  mClient = NULL;
979  return false;
980  }
981 
984 
985  bool haveDefaults;
986  GetPrivateConfig(GetFactoryDefaultsGroup(), wxT("Initialized"), haveDefaults, false);
987  if (!haveDefaults)
988  {
990  SetPrivateConfig(GetFactoryDefaultsGroup(), wxT("Initialized"), true);
991  }
993 
994  return Startup();
995 }
unsigned GetAudioInCount() override
Definition: Effect.cpp:282
bool SaveUserPreset(const wxString &name) override
Definition: Effect.cpp:600
bool GetPrivateConfig(const wxString &group, const wxString &key, wxString &value, const wxString &defval=wxEmptyString) override
Definition: Effect.cpp:897
wxString GetCurrentSettingsGroup() override
Definition: Effect.cpp:801
EffectClientInterface * mClient
Definition: Effect.h:527
bool SetPrivateConfig(const wxString &group, const wxString &key, const wxString &value) override
Definition: Effect.cpp:922
bool LoadUserPreset(const wxString &name) override
Definition: Effect.cpp:584
size_t mNumAudioIn
Definition: Effect.h:528
size_t mNumAudioOut
Definition: Effect.h:529
bool SetHost(EffectHostInterface *host) override
Definition: Effect.cpp:272
unsigned GetAudioOutCount() override
Definition: Effect.cpp:292
wxString GetFactoryDefaultsGroup() override
Definition: Effect.cpp:806
virtual bool Startup()
Definition: Effect.cpp:997
bool Effect::Startup ( )
virtual
bool Effect::SupportsAutomation ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 260 of file Effect.cpp.

References mClient, and EffectDefinitionInterface::SupportsAutomation().

261 {
262  if (mClient)
263  {
264  return mClient->SupportsAutomation();
265  }
266 
267  return true;
268 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual bool SupportsAutomation()=0
bool Effect::SupportsRealtime ( )
overridevirtual

Implements EffectDefinitionInterface.

Reimplemented in EffectPhaser, and EffectWahwah.

Definition at line 250 of file Effect.cpp.

References mClient, and EffectDefinitionInterface::SupportsRealtime().

Referenced by EffectManager::DoEffect(), EnablePreview(), EffectUIHost::Initialize(), and ShowInterface().

251 {
252  if (mClient)
253  {
254  return mClient->SupportsRealtime();
255  }
256 
257  return false;
258 }
EffectClientInterface * mClient
Definition: Effect.h:527
virtual bool SupportsRealtime()=0
bool Effect::TotalProgress ( double  frac)
protected

Definition at line 1977 of file Effect.cpp.

References mProgress, Success, and ProgressDialog::Update().

Referenced by EffectTruncSilence::Analyze(), EffectAutoDuck::ApplyDuckFade(), NyquistEffect::GetCallback(), EffectAutoDuck::Process(), EffectTwoPassSimpleMono::ProcessOne(), and NyquistEffect::PutCallback().

1978 {
1979  auto updateResult = (mProgress ?
1980  mProgress->Update(frac) :
1982  return (updateResult != ProgressResult::Success);
1983 }
ProgressDialog * mProgress
Definition: Effect.h:452
ProgressResult Update(int value, const wxString &message=wxEmptyString)
bool Effect::TrackGroupProgress ( int  whichGroup,
double  frac,
const wxString &  msg = wxEmptyString 
)
protected

Definition at line 1993 of file Effect.cpp.

References mNumGroups, mProgress, Success, and ProgressDialog::Update().

Referenced by NyquistEffect::ProcessOne(), and ProcessTrack().

1994 {
1995  auto updateResult = (mProgress ?
1996  mProgress->Update(whichGroup + frac, (double) mNumGroups, msg) :
1998  return (updateResult != ProgressResult::Success);
1999 }
ProgressDialog * mProgress
Definition: Effect.h:452
ProgressResult Update(int value, const wxString &message=wxEmptyString)
int mNumGroups
Definition: Effect.h:524
bool Effect::TrackProgress ( int  whichTrack,
double  frac,
const wxString &  msg = wxEmptyString 
)
protected
bool Effect::TransferDataFromWindow ( )
protectedvirtual
bool Effect::TransferDataToWindow ( )
protectedvirtual
bool Effect::ValidateUI ( )
overridevirtual

Implements EffectUIClientInterface.

Reimplemented in EffectEqualization.

Definition at line 672 of file Effect.cpp.

References mUIParent.

673 {
674  return mUIParent->Validate();
675 }
wxWindow * mUIParent
Definition: Effect.h:472

Friends And Related Function Documentation

friend class EffectManager
friend

Definition at line 546 of file Effect.h.

friend class EffectPresetsDialog
friend

Definition at line 549 of file Effect.h.

friend class EffectRack
friend

Definition at line 547 of file Effect.h.

friend class EffectUIHost
friend

Definition at line 548 of file Effect.h.

Member Data Documentation

const wxString Effect::kCurrentSettingsIdent = wxT("<Current Settings>")
staticprivate
const wxString Effect::kFactoryDefaultsIdent = wxT("<Factory Defaults>")
staticprivate
const wxString Effect::kFactoryPresetIdent = wxT("Factory Preset:")
staticprivate
const wxString Effect::kUserPresetIdent = wxT("User Preset:")
staticprivate
size_t Effect::mBlockSize
private
size_t Effect::mBufferSize
private

Definition at line 531 of file Effect.h.

Referenced by Effect(), ProcessPass(), and ProcessTrack().

EffectClientInterface* Effect::mClient
private
int Effect::mCurrentProcessor
private

Definition at line 536 of file Effect.h.

Referenced by RealtimeAddProcessor().

double Effect::mDuration
private
NumericFormatId Effect::mDurationFormat
private

Definition at line 514 of file Effect.h.

Referenced by DoEffect(), and GetDurationFormat().

double Effect::mF0
protected
double Effect::mF1
protected
TrackFactory* Effect::mFactory
protected
std::vector<int> Effect::mGroupProcessor
private

Definition at line 535 of file Effect.h.

Referenced by RealtimeAddProcessor(), and RealtimeProcess().

std::vector<Track*> Effect::mIMap
private

Definition at line 520 of file Effect.h.

Referenced by AddToOutputTracks(), CopyInputTracks(), and ReplaceProcessedTracks().

bool Effect::mIsBatch
private

Definition at line 507 of file Effect.h.

Referenced by Effect(), IsBatchProcessing(), and SetBatchProcessing().

bool Effect::mIsLinearEffect
private

Definition at line 508 of file Effect.h.

Referenced by Effect(), Preview(), and SetLinearEffectFlag().

bool Effect::mIsPreview
private

Definition at line 516 of file Effect.h.

Referenced by Effect(), Preview(), and ProcessTrack().

bool Effect::mIsSelection
private

Definition at line 512 of file Effect.h.

Referenced by SetDuration().

size_t Effect::mNumAudioIn
private

Definition at line 528 of file Effect.h.

Referenced by Effect(), Process(), ProcessPass(), RealtimeAddProcessor(), RealtimeProcess(), and Startup().

size_t Effect::mNumAudioOut
private
unsigned Effect::mNumChannels
private

Definition at line 533 of file Effect.h.

Referenced by Effect(), ProcessPass(), and ProcessTrack().

int Effect::mNumGroups
private

Definition at line 524 of file Effect.h.

Referenced by CountWaveTracks(), Effect(), and TrackGroupProgress().

int Effect::mNumTracks
private

Definition at line 523 of file Effect.h.

Referenced by CountWaveTracks(), Effect(), Preview(), and TrackProgress().

std::vector<Track*> Effect::mOMap
private

Definition at line 521 of file Effect.h.

Referenced by AddToOutputTracks(), CopyInputTracks(), and ReplaceProcessedTracks().

std::shared_ptr<TrackList> Effect::mOutputTracks
protected
int Effect::mOutputTracksType
protected

Definition at line 478 of file Effect.h.

Referenced by CopyInputTracks(), Effect(), and ReplaceProcessedTracks().

int Effect::mPass
protected

Definition at line 468 of file Effect.h.

Referenced by GetPass(), and Process().

wxArrayString Effect::mPresetNames
protected

Definition at line 466 of file Effect.h.

Referenced by NyquistEffect::Parse().

wxArrayString Effect::mPresetValues
protected

Definition at line 467 of file Effect.h.

bool Effect::mPreviewFullSelection
private

Definition at line 510 of file Effect.h.

Referenced by Effect(), Preview(), and SetPreviewFullSelectionFlag().

bool Effect::mPreviewWithNotSelected
private

Definition at line 509 of file Effect.h.

Referenced by Effect(), IncludeNotSelectedPreviewTracks(), and Preview().

ProgressDialog* Effect::mProgress
protected
double Effect::mProjectRate
protected
SelectedRegion* Effect::mpSelectedRegion {}
protected

Definition at line 456 of file Effect.h.

Referenced by Delegate(), and DoEffect().

int Effect::mRealtimeSuspendCount
private

Definition at line 539 of file Effect.h.

Referenced by Effect(), IsRealtimeActive(), RealtimeResume(), and RealtimeSuspend().

wxCriticalSection Effect::mRealtimeSuspendLock
private

Definition at line 538 of file Effect.h.

Referenced by Effect(), RealtimeResume(), and RealtimeSuspend().

sampleCount Effect::mSampleCnt
protected

Definition at line 475 of file Effect.h.

Referenced by EffectFade::ProcessBlock(), EffectToneGen::ProcessBlock(), and ProcessPass().

double Effect::mSampleRate
protected
double Effect::mT0
protected
double Effect::mT1
protected
TrackList* Effect::mTracks
private
bool Effect::mUIDebug
private

Definition at line 518 of file Effect.h.

Referenced by Effect(), EnableDebug(), and EffectUIHost::Initialize().

wxDialog* Effect::mUIDialog
protected
wxWindow* Effect::mUIParent
protected

Definition at line 472 of file Effect.h.

Referenced by CloseUI(), Effect(), EnableApply(), EnablePreview(), MessageBox(), EffectBassTreble::OnBassSlider(), EffectBassTreble::OnBassText(), EffectTruncSilence::OnControlChange(), EffectToneGen::OnControlUpdate(), EffectScienFilter::OnCutoff(), EffectWahwah::OnDepthSlider(), EffectPhaser::OnDepthSlider(), EffectWahwah::OnDepthText(), EffectPhaser::OnDepthText(), EffectPhaser::OnDryWetSlider(), EffectPhaser::OnDryWetText(), EffectPhaser::OnFeedbackSlider(), EffectPhaser::OnFeedbackText(), NyquistEffect::OnFileButton(), EffectWahwah::OnFreqOffSlider(), EffectWahwah::OnFreqOffText(), EffectWahwah::OnFreqSlider(), EffectPhaser::OnFreqSlider(), EffectWahwah::OnFreqText(), EffectPhaser::OnFreqText(), EffectWahwah::OnGainSlider(), EffectPhaser::OnGainSlider(), EffectBassTreble::OnGainSlider(), EffectBassTreble::OnGainText(), EffectWahwah::OnGainText(), EffectPhaser::OnGainText(), NyquistEffect::OnLoad(), EffectEqualization::OnManage(), EditCurvesDialog::OnOK(), EffectWahwah::OnPhaseSlider(), EffectPhaser::OnPhaseSlider(), EffectWahwah::OnPhaseText(), EffectPhaser::OnPhaseText(), EffectWahwah::OnResonanceSlider(), EffectWahwah::OnResonanceText(), EffectScienFilter::OnRipple(), NyquistEffect::OnSave(), EffectScienFilter::OnSize(), EffectEqualization::OnSize(), NyquistEffect::OnSlider(), EffectPhaser::OnStagesSlider(), EffectPhaser::OnStagesText(), EffectScienFilter::OnStopbandRipple(), EffectPaulstretch::OnText(), NyquistEffect::OnText(), NyquistEffect::OnTime(), EffectBassTreble::OnTrebleSlider(), EffectBassTreble::OnTrebleText(), EffectEqualization::PopulateOrExchange(), EffectEqualization::PopulateUI(), PopulateUI(), NyquistEffect::Process(), NyquistEffect::TransferDataFromEffectWindow(), EffectPaulstretch::TransferDataFromWindow(), EffectRepeat::TransferDataFromWindow(), EffectFindClipping::TransferDataFromWindow(), EffectNoise::TransferDataFromWindow(), EffectToneGen::TransferDataFromWindow(), EffectNormalize::TransferDataFromWindow(), EffectEcho::TransferDataFromWindow(), EffectCompressor::TransferDataFromWindow(), EffectDtmf::TransferDataFromWindow(), EffectClickRemoval::TransferDataFromWindow(), EffectChangeSpeed::TransferDataFromWindow(), EffectAutoDuck::TransferDataFromWindow(), EffectAmplify::TransferDataFromWindow(), EffectScienFilter::TransferDataFromWindow(), EffectReverb::TransferDataFromWindow(), EffectTruncSilence::TransferDataFromWindow(), EffectBassTreble::TransferDataFromWindow(), EffectWahwah::TransferDataFromWindow(), EffectPhaser::TransferDataFromWindow(), EffectDistortion::TransferDataFromWindow(), NyquistEffect::TransferDataFromWindow(), NyquistEffect::TransferDataToEffectWindow(), EffectPaulstretch::TransferDataToWindow(), EffectFindClipping::TransferDataToWindow(), EffectNoise::TransferDataToWindow(), EffectNormalize::TransferDataToWindow(), EffectEcho::TransferDataToWindow(), EffectToneGen::TransferDataToWindow(), EffectClickRemoval::TransferDataToWindow(), EffectAutoDuck::TransferDataToWindow(), EffectDtmf::TransferDataToWindow(), EffectChangeSpeed::TransferDataToWindow(), EffectScienFilter::TransferDataToWindow(), EffectTruncSilence::TransferDataToWindow(), EffectBassTreble::TransferDataToWindow(), EffectWahwah::TransferDataToWindow(), EffectPhaser::TransferDataToWindow(), EffectDistortion::TransferDataToWindow(), NyquistEffect::TransferDataToWindow(), EffectEqualization::TransferDataToWindow(), EffectScienFilter::TransferGraphLimitsFromWindow(), EffectEqualization::UpdateDraw(), EffectEqualization::UpdateGraphic(), EffectNormalize::UpdateUI(), and ValidateUI().

int Effect::mUIResultID
protected

The documentation for this class was generated from the following files: