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 101 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.

102 {
103  mClient = NULL;
104 
105  mTracks = NULL;
107  mT0 = 0.0;
108  mT1 = 0.0;
109  mDuration = 0.0;
110  mIsPreview = false;
111  mIsLinearEffect = false;
112  mPreviewWithNotSelected = false;
113  mPreviewFullSelection = false;
114  mNumTracks = 0;
115  mNumGroups = 0;
116  mProgress = NULL;
117 
118  mRealtimeSuspendLock.Enter();
119  mRealtimeSuspendCount = 1; // Effects are initially suspended
120  mRealtimeSuspendLock.Leave();
121 
122  mUIParent = NULL;
123  mUIDialog = NULL;
124 
125  mNumAudioIn = 0;
126  mNumAudioOut = 0;
127 
128  mBufferSize = 0;
129  mBlockSize = 0;
130  mNumChannels = 0;
131 
132  mUIDebug = false;
133 
135  mProjectRate = p ? p->GetRate() : 44100;
136 
137  mIsBatch = false;
138 }
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 140 of file Effect.cpp.

References mUIDialog.

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

Member Function Documentation

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

Definition at line 2106 of file Effect.cpp.

References name, and safenew.

Referenced by EffectFindClipping::Process().

2107 {
2108  return std::shared_ptr<AddedAnalysisTrack>
2109  { safenew AddedAnalysisTrack{ this, name } };
2110 }
#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 2069 of file Effect.cpp.

References mIMap, mOMap, and mOutputTracks.

Referenced by NyquistEffect::ProcessOne().

2070 {
2071  mIMap.push_back(NULL);
2072  mOMap.push_back(t.get());
2073  return mOutputTracks->Add(std::move(t));
2074 }
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 763 of file Effect.cpp.

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

Referenced by EffectUIHost::OnApply().

764 {
765  CommandContext context( *GetActiveProject() );
766  // This is absolute hackage...but easy and I can't think of another way just now.
767  //
768  // It should callback to the EffectManager to kick off the processing
769  return GetActiveProject()->DoEffect(GetID(), context,
771 }
static const int kConfigured
Definition: Project.h:487
bool DoEffect(const PluginID &ID, const CommandContext &context, int flags)
Definition: Menus.cpp:4508
virtual PluginID GetID()
Definition: Effect.cpp:961
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 2281 of file Effect.cpp.

Referenced by Preview(), and ProcessTrack().

2282 {
2283  return previewLength;
2284 }
bool Effect::CanExportPresets ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 695 of file Effect.cpp.

696 {
697  return false;
698 }
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 684 of file Effect.cpp.

References mUIDialog, and mUIParent.

Referenced by EffectEqualization::CloseUI().

685 {
686  if (mUIParent)
687  mUIParent->RemoveEventHandler(this);
688 
689  mUIParent = NULL;
690  mUIDialog = NULL;
691 
692  return true;
693 }
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 2043 of file Effect.cpp.

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

2044 {
2045  // Reset map
2046  mIMap.clear();
2047  mOMap.clear();
2048 
2050  mOutputTracksType = trackType;
2051 
2052  //iterate over tracks of type trackType (All types if Track::All)
2053  TrackListOfKindIterator aIt(trackType, mTracks);
2054  t2bHash added;
2055 
2056  for (Track *aTrack = aIt.First(); aTrack; aTrack = aIt.Next())
2057  {
2058  // Include selected tracks, plus sync-lock selected tracks for Track::All.
2059  if (aTrack->GetSelected() ||
2060  (trackType == Track::All && aTrack->IsSyncLockSelected()))
2061  {
2062  Track *o = mOutputTracks->Add(aTrack->Duplicate());
2063  mIMap.push_back(aTrack);
2064  mOMap.push_back(o);
2065  }
2066  }
2067 }
std::unordered_map< void *, bool > t2bHash
Definition: Effect.cpp:99
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:101
std::vector< Track * > mIMap
Definition: Effect.h:520
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:459
void Effect::CountWaveTracks ( )
private

Definition at line 2258 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().

2259 {
2260  mNumTracks = 0;
2261  mNumGroups = 0;
2262 
2264  Track *t = iter.First();
2265 
2266  while(t) {
2267  if (!t->GetSelected()) {
2268  t = iter.Next();
2269  continue;
2270  }
2271 
2272  if (t->GetKind() == Track::Wave) {
2273  mNumTracks++;
2274  if (!t->GetLinked())
2275  mNumGroups++;
2276  }
2277  t = iter.Next();
2278  }
2279 }
TrackList * mTracks
Definition: Effect.h:505
bool GetSelected() const
Definition: Track.h:275
bool GetLinked() const
Definition: Track.h:278
virtual int GetKind() const
Definition: Track.h:329
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:101
int mNumGroups
Definition: Effect.h:524
wxDialog * Effect::CreateUI ( wxWindow *  parent,
EffectUIClientInterface client 
)
overridevirtual

Implements EffectHostInterface.

Definition at line 778 of file Effect.cpp.

References safenew.

Referenced by ShowInterface().

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

Definition at line 1259 of file Effect.cpp.

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

Referenced by NyquistEffect::ShowInterface().

1260 {
1261  return delegate.DoEffect( parent, mProjectRate, mTracks, mFactory,
1262  mpSelectedRegion, shouldPrompt );
1263 }
TrackList * mTracks
Definition: Effect.h:505
bool DoEffect(wxWindow *parent, double projectRate, TrackList *list, TrackFactory *factory, SelectedRegion *selectedRegion, bool shouldPrompt=true)
Definition: Effect.cpp:1158
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 1158 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().

1164 {
1165  wxASSERT(selectedRegion->duration() >= 0.0);
1166 
1167  mOutputTracks.reset();
1168 
1169  mpSelectedRegion = selectedRegion;
1170  mFactory = factory;
1171  mProjectRate = projectRate;
1172  mTracks = list;
1173 
1174  bool isSelection = false;
1175 
1176  mDuration = 0.0;
1177 
1178  if (GetType() == EffectTypeGenerate)
1179  {
1180  GetPrivateConfig(GetCurrentSettingsGroup(), wxT("LastUsedDuration"), mDuration, GetDefaultDuration());
1181  }
1182 
1183  mT0 = selectedRegion->t0();
1184  mT1 = selectedRegion->t1();
1185  if (mT1 > mT0)
1186  {
1187  // there is a selection: let's fit in there...
1188  // MJS: note that this is just for the TTC and is independent of the track rate
1189  // but we do need to make sure we have the right number of samples at the project rate
1190  double quantMT0 = QUANTIZED_TIME(mT0, mProjectRate);
1191  double quantMT1 = QUANTIZED_TIME(mT1, mProjectRate);
1192  mDuration = quantMT1 - quantMT0;
1193  mT1 = mT0 + mDuration;
1194 
1195  isSelection = true;
1196  }
1197 
1198  mDurationFormat = isSelection
1200  : NumericConverter::DefaultSelectionFormat();
1201 
1202 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
1203  mF0 = selectedRegion->f0();
1204  mF1 = selectedRegion->f1();
1205  wxArrayString Names;
1207  Names.Add(wxT("control-f0"));
1209  Names.Add(wxT("control-f1"));
1210  SetPresetParameters( &Names, NULL );
1211 
1212 #endif
1213  CountWaveTracks();
1214 
1215  // Note: Init may read parameters from preferences
1216  if (!Init())
1217  {
1218  return false;
1219  }
1220 
1221  // Prompting will be bypassed when applying an effect that has already
1222  // been configured, e.g. repeating the last effect on a different selection.
1223  // Prompting may call Effect::Preview
1224  if (shouldPrompt && IsInteractive() && !PromptUser(parent))
1225  {
1226  return false;
1227  }
1228 
1229  auto cleanup = finally( [&] {
1230  End();
1231 
1232  // In case of failed effect, be sure to free memory.
1233  ReplaceProcessedTracks( false );
1234  } );
1235 
1236  bool returnVal = true;
1237  bool skipFlag = CheckWhetherSkipEffect();
1238  if (skipFlag == false)
1239  {
1240  auto name = GetTranslatedName();
1241  ProgressDialog progress{
1242  name,
1243  wxString::Format(_("Applying %s..."), name),
1245  };
1246  auto vr = valueRestorer( mProgress, &progress );
1247 
1248  returnVal = Process();
1249  }
1250 
1251  if (returnVal)
1252  {
1253  selectedRegion->setTimes(mT0, mT1);
1254  }
1255 
1256  return returnVal;
1257 }
double mT1
Definition: Effect.h:461
void CountWaveTracks()
Definition: Effect.cpp:2258
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:899
wxString GetCurrentSettingsGroup() override
Definition: Effect.cpp:803
virtual bool Init()
Definition: Effect.cpp:1266
#define QUANTIZED_TIME(time, rate)
Definition: Audacity.h:214
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2169
void SetPresetParameters(const wxArrayString *Names, const wxArrayString *Values)
Definition: Effect.h:240
virtual bool Process()
Definition: Effect.cpp:1292
double t1() const
static NumericFormatId TimeAndSampleFormat()
double mF0
Definition: Effect.h:463
double f0() const
EffectType GetType() override
Definition: Effect.cpp:150
NumericConverter provides the advanced formatting control used in the selection bar of Audacity...
virtual void End()
Definition: Effect.cpp:1869
double GetDefaultDuration() override
Definition: Effect.cpp:719
bool IsInteractive() override
Definition: Effect.cpp:222
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:896
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:1272
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 1888 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().

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

Definition at line 1958 of file Effect.cpp.

References mUIDebug.

Referenced by NyquistEffect::PopulateOrExchange().

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

Definition at line 1919 of file Effect.cpp.

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

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

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

Reimplemented in EffectAutoDuck, and EffectStereoToMono.

Definition at line 1869 of file Effect.cpp.

Referenced by DoEffect(), and Preview().

1870 {
1871 }
void Effect::ExportPresets ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 700 of file Effect.cpp.

701 {
702 }
unsigned Effect::GetAudioInCount ( )
overridevirtual

Implements EffectClientInterface.

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

Definition at line 284 of file Effect.cpp.

References EffectClientInterface::GetAudioInCount(), and mClient.

Referenced by Process(), and Startup().

285 {
286  if (mClient)
287  {
288  return mClient->GetAudioInCount();
289  }
290 
291  return 0;
292 }
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 294 of file Effect.cpp.

References EffectClientInterface::GetAudioOutCount(), and mClient.

Referenced by Process(), and Startup().

295 {
296  if (mClient)
297  {
298  return mClient->GetAudioOutCount();
299  }
300 
301  return 0;
302 }
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 566 of file Effect.cpp.

References EffectClientInterface::GetAutomationParameters(), and mClient.

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

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

Definition at line 1004 of file Effect.cpp.

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

1005 {
1006  CommandParameters eap;
1007 
1009  {
1010  return false;
1011  }
1012 
1014  S.mpEap = &eap;
1015  if( DefineParams( S ) ){
1016  ;// got eap value using DefineParams.
1017  }
1018  // Won't be needed in future
1019  else if (!GetAutomationParameters(eap))
1020  {
1021  return false;
1022  }
1023 
1024  return eap.GetParameters(parms);
1025 }
virtual bool TransferDataFromWindow()
Definition: Effect.cpp:1883
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:566
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 719 of file Effect.cpp.

Referenced by DoEffect().

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

Implements EffectHostInterface.

Definition at line 734 of file Effect.cpp.

References mDurationFormat.

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

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

Implements EffectHostInterface.

Definition at line 808 of file Effect.cpp.

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

809 {
810  return wxT("FactoryDefaults");
811 }
wxArrayString Effect::GetFactoryPresets ( )
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectReverb.

Definition at line 618 of file Effect.cpp.

References EffectClientInterface::GetFactoryPresets(), and mClient.

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

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

Implements EffectDefinitionInterface.

Reimplemented in NyquistEffect.

Definition at line 210 of file Effect.cpp.

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

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

211 {
212  if (mClient)
213  {
214  return mClient->GetFamilyId();
215  }
216 
217  // Unusually, the internal and visible strings differ for the built-in
218  // effect family.
219  return { wxT("Audacity"), XO("Built-in") };
220 }
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 346 of file Effect.cpp.

References EffectClientInterface::GetLatency(), and mClient.

Referenced by ProcessTrack().

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

Implements EffectClientInterface.

Definition at line 304 of file Effect.cpp.

References EffectClientInterface::GetMidiInCount(), and mClient.

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

Implements EffectClientInterface.

Definition at line 314 of file Effect.cpp.

References EffectClientInterface::GetMidiOutCount(), and mClient.

315 {
316  if (mClient)
317  {
318  return mClient->GetMidiOutCount();
319  }
320 
321  return 0;
322 }
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 1277 of file Effect.cpp.

References mPass.

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

Implements IdentInterface.

Reimplemented in NyquistEffect.

Definition at line 160 of file Effect.cpp.

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

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

Definition at line 1112 of file Effect.cpp.

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

Referenced by EffectManager::GetPreset().

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

Implements ConfigClientInterface.

Definition at line 899 of file Effect.cpp.

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

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

900 {
901  return PluginManager::Get().GetPrivateConfig(GetID(), group, key, value, defval);
902 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 904 of file Effect.cpp.

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

905 {
906  return PluginManager::Get().GetPrivateConfig(GetID(), group, key, value, defval);
907 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 909 of file Effect.cpp.

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

910 {
911  return PluginManager::Get().GetPrivateConfig(GetID(), group, key, value, defval);
912 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 914 of file Effect.cpp.

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

915 {
916  return PluginManager::Get().GetPrivateConfig(GetID(), group, key, value, defval);
917 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 919 of file Effect.cpp.

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

920 {
921  return PluginManager::Get().GetPrivateConfig(GetID(), group, key, value, defval);
922 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 894 of file Effect.cpp.

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

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

895 {
896  return PluginManager::Get().GetPrivateConfigSubgroups(GetID(), group, subgroups);
897 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 2003 of file Effect.cpp.

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

Referenced by ProcessPass().

2005 {
2006  double trackStart = track->GetStartTime();
2007  double trackEnd = track->GetEndTime();
2008  double t0 = mT0 < trackStart ? trackStart : mT0;
2009  double t1 = mT1 > trackEnd ? trackEnd : mT1;
2010 
2011 #if 0
2012  if (GetType() & INSERT_EFFECT) {
2013  t1 = t0 + mDuration;
2014  if (mT0 == mT1) {
2015  // Not really part of the calculation, but convenient to put here
2016  track->InsertSilence(t0, t1);
2017  }
2018  }
2019 #endif
2020 
2021  if (t1 > t0) {
2022  *start = track->TimeToLongSamples(t0);
2023  auto end = track->TimeToLongSamples(t1);
2024  *len = end - *start;
2025  }
2026  else {
2027  *start = 0;
2028  *len = 0;
2029  }
2030 }
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:150
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 813 of file Effect.cpp.

Referenced by SetBatchProcessing().

814 {
815  return wxT("SavedState");
816 }
NumericFormatId Effect::GetSelectionFormat ( )
virtual

Definition at line 739 of file Effect.cpp.

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

Referenced by EffectRepeat::DisplayNewTime().

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

Implements ConfigClientInterface.

Definition at line 829 of file Effect.cpp.

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

830 {
831  return PluginManager::Get().GetSharedConfig(GetID(), group, key, value, defval);
832 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 834 of file Effect.cpp.

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

835 {
836  return PluginManager::Get().GetSharedConfig(GetID(), group, key, value, defval);
837 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 839 of file Effect.cpp.

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

840 {
841  return PluginManager::Get().GetSharedConfig(GetID(), group, key, value, defval);
842 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 844 of file Effect.cpp.

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

845 {
846  return PluginManager::Get().GetSharedConfig(GetID(), group, key, value, defval);
847 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 849 of file Effect.cpp.

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

850 {
851  return PluginManager::Get().GetSharedConfig(GetID(), group, key, value, defval);
852 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 824 of file Effect.cpp.

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

825 {
826  return PluginManager::Get().GetSharedConfigSubgroups(GetID(), group, subgroups);
827 }
bool GetSharedConfigSubgroups(const PluginID &ID, const wxString &group, wxArrayString &subgroups) override
virtual PluginID GetID()
Definition: Effect.cpp:961
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 170 of file Effect.cpp.

References IdentInterface::GetSymbol(), and mClient.

Referenced by GetPath().

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

Implements EffectClientInterface.

Definition at line 356 of file Effect.cpp.

References EffectClientInterface::GetTailSize(), and mClient.

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

Definition at line 1091 of file Effect.cpp.

References GetPrivateConfigSubgroups(), and GetUserPresetsGroup().

Referenced by EffectManager::HasPresets().

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

Implements EffectHostInterface.

Definition at line 792 of file Effect.cpp.

References name.

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

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

Implements IdentInterface.

Reimplemented in NyquistEffect.

Definition at line 180 of file Effect.cpp.

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

Referenced by EffectUIHost::OnMenu().

181 {
182  if (mClient)
183  {
184  return mClient->GetVendor();
185  }
186 
187  return XO("Audacity");
188 }
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 190 of file Effect.cpp.

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

Referenced by EffectUIHost::OnMenu().

191 {
192  if (mClient)
193  {
194  return mClient->GetVersion();
195  }
196 
198 }
#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 1102 of file Effect.cpp.

References GetCurrentSettingsGroup(), and HasPrivateConfigGroup().

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

1103 {
1105 }
wxString GetCurrentSettingsGroup() override
Definition: Effect.cpp:803
bool HasPrivateConfigGroup(const wxString &group) override
Definition: Effect.cpp:889
bool Effect::HasFactoryDefaults ( )
virtual

Definition at line 1107 of file Effect.cpp.

References GetFactoryDefaultsGroup(), and HasPrivateConfigGroup().

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

1108 {
1110 }
bool HasPrivateConfigGroup(const wxString &group) override
Definition: Effect.cpp:889
wxString GetFactoryDefaultsGroup() override
Definition: Effect.cpp:808
bool Effect::HasOptions ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 708 of file Effect.cpp.

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

Implements ConfigClientInterface.

Definition at line 889 of file Effect.cpp.

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

Referenced by HasCurrentSettings(), and HasFactoryDefaults().

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

Implements ConfigClientInterface.

Definition at line 819 of file Effect.cpp.

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

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

Reimplemented in NyquistEffect.

Definition at line 1134 of file Effect.cpp.

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

1135 {
1136  return wxEmptyString;
1137 }
bool Effect::HideUI ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 679 of file Effect.cpp.

680 {
681  return true;
682 }
void Effect::ImportPresets ( )
overridevirtual

Implements EffectUIClientInterface.

Definition at line 704 of file Effect.cpp.

705 {
706 }
void Effect::IncludeNotSelectedPreviewTracks ( bool  includeNotSelected)
protected

Definition at line 1974 of file Effect.cpp.

References mPreviewWithNotSelected.

1975 {
1976  mPreviewWithNotSelected = includeNotSelected;
1977 }
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 1266 of file Effect.cpp.

Referenced by DoEffect(), and Preview().

1267 {
1268  return true;
1269 }
bool Effect::InitPass1 ( )
protectedvirtual

Reimplemented in EffectCompressor, and EffectTwoPassSimpleMono.

Definition at line 1282 of file Effect.cpp.

Referenced by Process().

1283 {
1284  return true;
1285 }
bool Effect::InitPass2 ( )
protectedvirtual

Reimplemented in EffectCompressor, and EffectTwoPassSimpleMono.

Definition at line 1287 of file Effect.cpp.

Referenced by Process().

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

Implements EffectDefinitionInterface.

Reimplemented in NyquistEffect.

Definition at line 232 of file Effect.cpp.

References EffectDefinitionInterface::IsDefault(), and mClient.

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

Implements EffectUIClientInterface.

Definition at line 669 of file Effect.cpp.

670 {
671  return false;
672 }
bool Effect::IsHidden ( )
virtual

Reimplemented in EffectStereoToMono.

Definition at line 2474 of file Effect.cpp.

Referenced by EffectManager::IsHidden().

2475 {
2476  return false;
2477 }
bool Effect::IsInteractive ( )
overridevirtual

Implements EffectDefinitionInterface.

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

Definition at line 222 of file Effect.cpp.

References EffectDefinitionInterface::IsInteractive(), and mClient.

Referenced by DoEffect(), and ShowInterface().

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

Implements EffectDefinitionInterface.

Definition at line 242 of file Effect.cpp.

References mClient.

243 {
244  if (mClient)
245  {
246  return false;
247  }
248 
249  return true;
250 }
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 366 of file Effect.cpp.

References EffectClientInterface::IsReady(), and mClient.

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

Definition at line 2469 of file Effect.cpp.

References mRealtimeSuspendCount.

2470 {
2471  return mRealtimeSuspendCount == 0;
2472 }
int mRealtimeSuspendCount
Definition: Effect.h:539
bool Effect::LoadFactoryDefaults ( )
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectEqualization.

Definition at line 638 of file Effect.cpp.

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

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

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

Implements EffectClientInterface.

Reimplemented in EffectReverb.

Definition at line 628 of file Effect.cpp.

References EffectClientInterface::LoadFactoryPreset(), and mClient.

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

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

Implements EffectClientInterface.

Definition at line 586 of file Effect.cpp.

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

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

587 {
588  if (mClient)
589  {
590  return mClient->LoadUserPreset(name);
591  }
592 
593  wxString parms;
594  if (!GetPrivateConfig(name, wxT("Parameters"), parms))
595  {
596  return false;
597  }
598 
599  return SetAutomationParameters(parms);
600 }
bool GetPrivateConfig(const wxString &group, const wxString &key, wxString &value, const wxString &defval=wxEmptyString) override
Definition: Effect.cpp:899
bool SetAutomationParameters(CommandParameters &parms) override
Definition: Effect.cpp:576
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 2664 of file Effect.cpp.

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

Referenced by EffectAutoDuck::Init(), EffectScienFilter::Init(), NyquistEffect::Init(), EffectEqualization::Init(), EffectEqualization::LoadCurves(), NyquistEffect::OnLoad(), NyquistEffect::OnSave(), 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(), and EffectEqualization::ValidateUI().

2665 {
2666  wxString title;
2667  if (titleStr.empty())
2668  title = GetTranslatedName();
2669  else
2670  title = wxString::Format(_("%s: %s"), GetTranslatedName(), titleStr);
2671  return AudacityMessageBox(message, title, style, mUIParent);
2672 }
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 2162 of file Effect.cpp.

Referenced by EffectFindClipping::Process().

2163 {
2164  return{ this, pOrigTrack, name };
2165 }
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 654 of file Effect.cpp.

References eIsCreating, mUIParent, and PopulateOrExchange().

655 {
656  mUIParent = parent;
657  mUIParent->PushEventHandler(this);
658 
659 // LoadUserPreset(GetCurrentSettingsGroup());
660 
663 
664  mUIParent->SetMinSize(mUIParent->GetSizer()->GetMinSize());
665 
666  return true;
667 }
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:1873
void Effect::Preview ( )
overridevirtual

Implements EffectHostInterface.

Definition at line 773 of file Effect.cpp.

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

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

Reimplemented in EffectAmplify.

Definition at line 2479 of file Effect.cpp.

References _(), TrackList::Add(), CalcPreviewInputLength(), WaveTrack::Copy(), CountWaveTracks(), TrackList::Create(), EffectTypeGenerate, End(), TrackListCondIterator::First(), floatSample, gAudioIO, 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.

2480 {
2481  if (mNumTracks == 0) { // nothing to preview
2482  return;
2483  }
2484 
2485  if (gAudioIO->IsBusy()) {
2486  return;
2487  }
2488 
2489  wxWindow *FocusDialog = wxWindow::FindFocus();
2490 
2491  double previewDuration;
2492  bool isNyquist = GetFamilyId() == NYQUISTEFFECTS_FAMILY;
2493  bool isGenerator = GetType() == EffectTypeGenerate;
2494 
2495  // Mix a few seconds of audio from all of the tracks
2496  double previewLen;
2497  gPrefs->Read(wxT("/AudioIO/EffectsPreviewLen"), &previewLen, 6.0);
2498 
2499  const double rate = mProjectRate;
2500 
2501  if (isNyquist && isGenerator) {
2502  previewDuration = CalcPreviewInputLength(previewLen);
2503  }
2504  else {
2505  previewDuration = wxMin(mDuration, CalcPreviewInputLength(previewLen));
2506  }
2507 
2508  double t1 = mT0 + previewDuration;
2509 
2510  if ((t1 > mT1) && !(isNyquist && isGenerator)) {
2511  t1 = mT1;
2512  }
2513 
2514  if (t1 <= mT0)
2515  return;
2516 
2517  bool success = true;
2518  auto vr0 = valueRestorer( mT0 );
2519  auto vr1 = valueRestorer( mT1 );
2520  // Most effects should stop at t1.
2521  if (!mPreviewFullSelection)
2522  mT1 = t1;
2523 
2524  // Save the original track list
2525  TrackList *saveTracks = mTracks;
2526 
2527  auto cleanup = finally( [&] {
2528  mTracks = saveTracks;
2529 
2530  // Effect is already inited; we will call Process, End, and then Init
2531  // again, so the state is exactly the way it was before Preview
2532  // was called.
2533  if (!dryOnly) {
2534  End();
2535  GuardedCall( [&]{ Init(); } );
2536  }
2537 
2538  if (FocusDialog) {
2539  FocusDialog->SetFocus();
2540  }
2541 
2542  // In case of failed effect, be sure to free memory.
2543  ReplaceProcessedTracks( false );
2544  } );
2545 
2546  // Build NEW tracklist from rendering tracks
2547  auto uTracks = TrackList::Create();
2548  mTracks = uTracks.get();
2549 
2550  // Linear Effect preview optimised by pre-mixing to one track.
2551  // Generators need to generate per track.
2552  if (mIsLinearEffect && !isGenerator) {
2553  WaveTrack::Holder mixLeft, mixRight;
2554  MixAndRender(saveTracks, mFactory, rate, floatSample, mT0, t1, mixLeft, mixRight);
2555  if (!mixLeft)
2556  return;
2557 
2558  mixLeft->Offset(-mixLeft->GetStartTime());
2559  mixLeft->SetSelected(true);
2560  mixLeft->SetDisplay(WaveTrack::NoDisplay);
2561  mTracks->Add(std::move(mixLeft));
2562  if (mixRight) {
2563  mixRight->Offset(-mixRight->GetStartTime());
2564  mixRight->SetSelected(true);
2565  mTracks->Add(std::move(mixRight));
2566  }
2567  }
2568  else {
2569  TrackListOfKindIterator iter(Track::Wave, saveTracks);
2570  WaveTrack *src = (WaveTrack *) iter.First();
2571  while (src)
2572  {
2573  if (src->GetSelected() || mPreviewWithNotSelected) {
2574  auto dest = src->Copy(mT0, t1);
2575  dest->SetSelected(src->GetSelected());
2576  static_cast<WaveTrack*>(dest.get())->SetDisplay(WaveTrack::NoDisplay);
2577  mTracks->Add(std::move(dest));
2578  }
2579  src = (WaveTrack *) iter.Next();
2580  }
2581  }
2582 
2583  // NEW tracks start at time zero.
2584  // Adjust mT0 and mT1 to be the times to process, and to
2585  // play back in these tracks
2586  mT1 -= mT0;
2587  mT0 = 0.0;
2588 
2589 
2590  // Update track/group counts
2591  CountWaveTracks();
2592 
2593  // Apply effect
2594  if (!dryOnly) {
2595  ProgressDialog progress{
2597  _("Preparing preview"),
2599  }; // Have only "Stop" button.
2600  auto vr = valueRestorer( mProgress, &progress );
2601 
2602  auto vr2 = valueRestorer( mIsPreview, true );
2603 
2604  success = Process();
2605  }
2606 
2607  if (success)
2608  {
2609  WaveTrackConstArray playbackTracks;
2610  WaveTrackArray recordingTracks;
2611 
2613  WaveTrack *src = (WaveTrack *) iter.First();
2614  while (src) {
2615  playbackTracks.push_back(Track::Pointer<WaveTrack>(src));
2616  src = (WaveTrack *) iter.Next();
2617  }
2618  // Some effects (Paulstretch) may need to generate more
2619  // than previewLen, so take the min.
2620  t1 = std::min(mT0 + previewLen, mT1);
2621 
2622 #ifdef EXPERIMENTAL_MIDI_OUT
2623  NoteTrackArray empty;
2624 #endif
2625  // Start audio playing
2626  AudioIOStartStreamOptions options { rate };
2627  int token =
2628  gAudioIO->StartStream(playbackTracks, recordingTracks,
2629 #ifdef EXPERIMENTAL_MIDI_OUT
2630  empty,
2631 #endif
2632  mT0, t1, options);
2633 
2634  if (token) {
2635  auto previewing = ProgressResult::Success;
2636  // The progress dialog must be deleted before stopping the stream
2637  // to allow events to flow to the app during StopStream processing.
2638  // The progress dialog blocks these events.
2639  {
2640  ProgressDialog progress
2641  (GetTranslatedName(), _("Previewing"), pdlgHideCancelButton);
2642 
2643  while (gAudioIO->IsStreamActive(token) && previewing == ProgressResult::Success) {
2644  ::wxMilliSleep(100);
2645  previewing = progress.Update(gAudioIO->GetStreamTime() - mT0, t1 - mT0);
2646  }
2647  }
2648 
2649  gAudioIO->StopStream();
2650 
2651  while (gAudioIO->IsBusy()) {
2652  ::wxMilliSleep(100);
2653  }
2654  }
2655  else {
2656  ShowErrorDialog(FocusDialog, _("Error"),
2657  _("Error opening sound device.\nTry changing the audio host, playback device and the project sample rate."),
2658  wxT("Error_opening_sound_device"));
2659  }
2660  }
2661 }
IdentInterfaceSymbol GetFamilyId() override
Definition: Effect.cpp:210
double mT1
Definition: Effect.h:461
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
A list of TrackListNode items.
Definition: Track.h:618
void StopStream()
Stop recording, playback or input monitoring.
Definition: AudioIO.cpp:2524
void CountWaveTracks()
Definition: Effect.cpp:2258
ProgressDialog Class.
ProgressDialog * mProgress
Definition: Effect.h:452
double GetStreamTime()
During playback, the (unwarped) track time most recently played.
Definition: AudioIO.cpp:2977
TrackList * mTracks
Definition: Effect.h:505
bool GetSelected() const
Definition: Track.h:275
bool IsStreamActive()
Returns true if the audio i/o is running at all, but not during cleanup.
Definition: AudioIO.cpp:2907
bool mPreviewFullSelection
Definition: Effect.h:510
virtual bool Init()
Definition: Effect.cpp:1266
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:2169
void Offset(double t)
Definition: Track.h:288
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: WaveTrack.cpp:605
virtual bool Process()
Definition: Effect.cpp:1292
bool IsBusy()
Returns true if audio i/o is busy starting, stopping, playing, or recording.
Definition: AudioIO.cpp:2899
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:150
std::unique_ptr< WaveTrack > Holder
Definition: WaveTrack.h:90
std::vector< std::shared_ptr< WaveTrack > > WaveTrackArray
Definition: AudioIO.h:65
struct holding stream options, including a pointer to the TimeTrack and AudioIOListener and whether t...
Definition: AudioIO.h:114
std::vector< std::shared_ptr< const WaveTrack > > WaveTrackConstArray
Definition: AudioIO.h:66
virtual void End()
Definition: Effect.cpp:1869
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:2281
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
std::vector< std::shared_ptr< NoteTrack > > NoteTrackArray
Definition: Track.h:53
int StartStream(const WaveTrackConstArray &playbackTracks, const WaveTrackArray &captureTracks, double t0, double t1, const AudioIOStartStreamOptions &options)
Start recording or playing back audio.
Definition: AudioIO.cpp:1864
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:896
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 1292 of file Effect.cpp.

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

Referenced by DoEffect(), and Preview().

1293 {
1295  bool bGoodResult = true;
1296 
1297  // It's possible that the number of channels the effect expects changed based on
1298  // the parameters (the Audacity Reverb effect does when the stereo width is 0).
1301 
1302  mPass = 1;
1303  if (InitPass1())
1304  {
1305  bGoodResult = ProcessPass();
1306  mPass = 2;
1307  if (bGoodResult && InitPass2())
1308  {
1309  bGoodResult = ProcessPass();
1310  }
1311  }
1312 
1313  ReplaceProcessedTracks(bGoodResult);
1314 
1315  return bGoodResult;
1316 }
unsigned GetAudioInCount() override
Definition: Effect.cpp:284
int mPass
Definition: Effect.h:468
void CopyInputTracks()
Definition: Effect.cpp:2038
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2169
virtual bool ProcessPass()
Definition: Effect.cpp:1318
size_t mNumAudioIn
Definition: Effect.h:528
size_t mNumAudioOut
Definition: Effect.h:529
virtual bool InitPass2()
Definition: Effect.cpp:1287
virtual bool InitPass1()
Definition: Effect.cpp:1282
unsigned GetAudioOutCount() override
Definition: Effect.cpp:294
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 396 of file Effect.cpp.

References mClient, and EffectClientInterface::ProcessBlock().

Referenced by ProcessTrack().

397 {
398  if (mClient)
399  {
400  return mClient->ProcessBlock(inBlock, outBlock, blockLen);
401  }
402 
403  return 0;
404 }
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 386 of file Effect.cpp.

References mClient, and EffectClientInterface::ProcessFinalize().

Referenced by ProcessTrack().

387 {
388  if (mClient)
389  {
390  return mClient->ProcessFinalize();
391  }
392 
393  return true;
394 }
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 376 of file Effect.cpp.

References mClient, and EffectClientInterface::ProcessInitialize().

Referenced by ProcessTrack().

377 {
378  if (mClient)
379  {
380  return mClient->ProcessInitialize(totalLen, chanMap);
381  }
382 
383  return true;
384 }
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 1318 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().

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

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

Reimplemented in EffectNoiseReduction.

Definition at line 1272 of file Effect.cpp.

References IsBatchProcessing(), and ShowInterface().

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

1273 {
1274  return ShowInterface(parent, IsBatchProcessing());
1275 }
bool ShowInterface(wxWindow *parent, bool forceModal=false) override
Definition: Effect.cpp:516
virtual bool IsBatchProcessing()
Definition: Effect.cpp:1139
bool Effect::RealtimeAddProcessor ( unsigned  numChannels,
float  sampleRate 
)
overridevirtual

Implements EffectClientInterface.

Reimplemented in EffectPhaser, and EffectWahwah.

Definition at line 419 of file Effect.cpp.

References mClient, and EffectClientInterface::RealtimeAddProcessor().

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

420 {
421  if (mClient)
422  {
423  return mClient->RealtimeAddProcessor(numChannels, sampleRate);
424  }
425 
426  return true;
427 }
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 2289 of file Effect.cpp.

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

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

Implements EffectClientInterface.

Reimplemented in EffectPhaser, and EffectWahwah.

Definition at line 429 of file Effect.cpp.

References mClient, and EffectClientInterface::RealtimeFinalize().

Referenced by EffectManager::RealtimeRemoveEffect().

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

Implements EffectClientInterface.

Reimplemented in EffectPhaser, and EffectWahwah.

Definition at line 406 of file Effect.cpp.

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

Referenced by EffectManager::RealtimeAddEffect().

407 {
408  if (mClient)
409  {
411  return mClient->RealtimeInitialize();
412  }
413 
414  mBlockSize = 512;
415 
416  return false;
417 }
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 493 of file Effect.cpp.

References mClient, and EffectClientInterface::RealtimeProcess().

Referenced by RealtimeProcess().

497 {
498  if (mClient)
499  {
500  return mClient->RealtimeProcess(group, inbuf, outbuf, numSamples);
501  }
502 
503  return 0;
504 }
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 2354 of file Effect.cpp.

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

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

References mClient, and EffectClientInterface::RealtimeProcessEnd().

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

Implements EffectClientInterface.

Definition at line 483 of file Effect.cpp.

References mClient, and EffectClientInterface::RealtimeProcessStart().

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

Implements EffectClientInterface.

Definition at line 461 of file Effect.cpp.

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

Referenced by EffectUIHost::Resume().

462 {
463  if (mClient)
464  {
465  if (mClient->RealtimeResume())
466  {
467  mRealtimeSuspendLock.Enter();
469  mRealtimeSuspendLock.Leave();
470  return true;
471  }
472 
473  return false;
474  }
475 
476  mRealtimeSuspendLock.Enter();
478  mRealtimeSuspendLock.Leave();
479 
480  return true;
481 }
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 439 of file Effect.cpp.

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

Referenced by EffectUIHost::OnEnable().

440 {
441  if (mClient)
442  {
443  if (mClient->RealtimeSuspend())
444  {
445  mRealtimeSuspendLock.Enter();
447  mRealtimeSuspendLock.Leave();
448  return true;
449  }
450 
451  return false;
452  }
453 
454  mRealtimeSuspendLock.Enter();
456  mRealtimeSuspendLock.Leave();
457 
458  return true;
459 }
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 954 of file Effect.cpp.

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

955 {
956  return PluginManager::Get().RemovePrivateConfig(GetID(), group, key);
957 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 949 of file Effect.cpp.

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

Referenced by EffectUIHost::OnDeletePreset().

950 {
952 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 884 of file Effect.cpp.

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

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

Implements ConfigClientInterface.

Definition at line 879 of file Effect.cpp.

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

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

Definition at line 2169 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().

2170 {
2171  if (!bGoodResult) {
2172  // Free resources, unless already freed.
2173 
2174  // Processing failed or was cancelled so throw away the processed tracks.
2175  if ( mOutputTracks )
2176  mOutputTracks->Clear();
2177 
2178  // Reset map
2179  mIMap.clear();
2180  mOMap.clear();
2181 
2183 
2184  //TODO:undo the non-gui ODTask transfer
2185  return;
2186  }
2187 
2188  // Assume resources need to be freed.
2189  wxASSERT(mOutputTracks); // Make sure we at least did the CopyInputTracks().
2190 
2191  auto iterOut = mOutputTracks->ListOfTracks::begin(),
2192  iterEnd = mOutputTracks->ListOfTracks::end();
2193 
2194  size_t cnt = mOMap.size();
2195  size_t i = 0;
2196 
2197  for (; iterOut != iterEnd; ++i) {
2198  ListOfTracks::value_type o = std::move(*iterOut);
2199  // If tracks were removed from mOutputTracks, then there will be
2200  // tracks in the map that must be removed from mTracks.
2201  while (i < cnt && mOMap[i] != o.get()) {
2202  const auto t = mIMap[i];
2203  if (t) {
2204  mTracks->Remove(t);
2205  }
2206  i++;
2207  }
2208 
2209  // This should never happen
2210  wxASSERT(i < cnt);
2211 
2212  // Remove the track from the output list...don't DELETE it
2213  iterOut = mOutputTracks->erase(iterOut);
2214 
2215  const auto t = mIMap[i];
2216  if (t == NULL)
2217  {
2218  // This track is a NEW addition to output tracks; add it to mTracks
2219  mTracks->Add(std::move(o));
2220  }
2221  else
2222  {
2223  // Replace mTracks entry with the NEW track
2224  WaveTrack *newTrack = static_cast<WaveTrack*>(o.get());
2225  mTracks->Replace(t, std::move(o));
2226 
2227  // Swap the wavecache track the ondemand task uses, since now the NEW
2228  // one will be kept in the project
2231  newTrack);
2232  }
2233  }
2234  }
2235 
2236  // If tracks were removed from mOutputTracks, then there may be tracks
2237  // left at the end of the map that must be removed from mTracks.
2238  while (i < cnt) {
2239  const auto t = mIMap[i];
2240  if (t) {
2241  mTracks->Remove(t);
2242  }
2243  i++;
2244  }
2245 
2246  // Reset map
2247  mIMap.clear();
2248  mOMap.clear();
2249 
2250  // Make sure we processed everything
2251  wxASSERT(mOutputTracks->empty());
2252 
2253  // The output list is no longer needed
2254  mOutputTracks.reset();
2256 }
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 602 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().

603 {
604  if (mClient)
605  {
606  return mClient->SaveUserPreset(name);
607  }
608 
609  wxString parms;
610  if (!GetAutomationParameters(parms))
611  {
612  return false;
613  }
614 
615  return SetPrivateConfig(name, wxT("Parameters"), parms);
616 }
EffectClientInterface * mClient
Definition: Effect.h:527
bool SetPrivateConfig(const wxString &group, const wxString &key, const wxString &value) override
Definition: Effect.cpp:924
virtual bool SaveUserPreset(const wxString &name)=0
bool GetAutomationParameters(CommandParameters &parms) override
Definition: Effect.cpp:566
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 576 of file Effect.cpp.

References mClient, and EffectClientInterface::SetAutomationParameters().

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

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

Definition at line 1027 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().

1028 {
1029  wxString preset = parms;
1030  bool success = false;
1031  if (preset.StartsWith(kUserPresetIdent))
1032  {
1033  preset.Replace(kUserPresetIdent, wxEmptyString, false);
1034  success = LoadUserPreset(GetUserPresetsGroup(preset));
1035  }
1036  else if (preset.StartsWith(kFactoryPresetIdent))
1037  {
1038  preset.Replace(kFactoryPresetIdent, wxEmptyString, false);
1039  wxArrayString presets = GetFactoryPresets();
1040  success = LoadFactoryPreset(presets.Index(preset));
1041  }
1042  else if (preset.StartsWith(kCurrentSettingsIdent))
1043  {
1044  preset.Replace(kCurrentSettingsIdent, wxEmptyString, false);
1046  }
1047  else if (preset.StartsWith(kFactoryDefaultsIdent))
1048  {
1049  preset.Replace(kFactoryDefaultsIdent, wxEmptyString, false);
1051  }
1052  else
1053  {
1054  CommandParameters eap(parms);
1056  S.SetForValidating( &eap );
1057  // DefineParams returns false if not defined for this effect.
1058  if( !DefineParams( S ) )
1059  // the old method...
1060  success = SetAutomationParameters(eap);
1061  else if( !S.bOK )
1062  success = false;
1063  else{
1064  success = true;
1065  S.SetForWriting( &eap );
1066  DefineParams( S );
1067  }
1068  }
1069 
1070  if (!success)
1071  {
1073  wxString::Format(
1074  _("%s: Could not load settings below. Default settings will be used.\n\n%s"),
1076  preset
1077  )
1078  );
1079 
1080  return false;
1081  }
1082 
1083  if (!mUIDialog)
1084  {
1085  return true;
1086  }
1087 
1088  return TransferDataToWindow();
1089 }
wxString GetUserPresetsGroup(const wxString &name) override
Definition: Effect.cpp:792
void SetForWriting(CommandParameters *pEap)
Definition: Shuttle.h:114
int MessageBox(const wxString &message, long style=DefaultMessageBoxStyle, const wxString &titleStr=wxString{})
Definition: Effect.cpp:2664
wxString GetCurrentSettingsGroup() override
Definition: Effect.cpp:803
bool SetAutomationParameters(CommandParameters &parms) override
Definition: Effect.cpp:576
virtual bool TransferDataToWindow()
Definition: Effect.cpp:1878
bool LoadUserPreset(const wxString &name) override
Definition: Effect.cpp:586
wxArrayString GetFactoryPresets() override
Definition: Effect.cpp:618
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:628
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:808
static const wxString kFactoryDefaultsIdent
Definition: Effect.h:544
void Effect::SetBatchProcessing ( bool  start)
virtual

Definition at line 1144 of file Effect.cpp.

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

Referenced by EffectManager::SetBatchProcessing().

1145 {
1146  mIsBatch = start;
1147 
1148  if (start)
1149  {
1151  }
1152  else
1153  {
1155  }
1156 }
bool SaveUserPreset(const wxString &name) override
Definition: Effect.cpp:602
bool LoadUserPreset(const wxString &name) override
Definition: Effect.cpp:586
bool mIsBatch
Definition: Effect.h:507
virtual wxString GetSavedStateGroup()
Definition: Effect.cpp:813
size_t Effect::SetBlockSize ( size_t  maxBlockSize)
overridevirtual

Implements EffectClientInterface.

Definition at line 334 of file Effect.cpp.

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

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

335 {
336  if (mClient)
337  {
338  return mClient->SetBlockSize(maxBlockSize);
339  }
340 
341  mBlockSize = maxBlockSize;
342 
343  return mBlockSize;
344 }
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 744 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().

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

Implements EffectClientInterface.

Definition at line 274 of file Effect.cpp.

References mClient, and EffectClientInterface::SetHost().

Referenced by Startup().

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

Implements EffectUIClientInterface.

Definition at line 650 of file Effect.cpp.

651 {
652 }
void Effect::SetLinearEffectFlag ( bool  linearEffectFlag)
protected

Definition at line 1963 of file Effect.cpp.

References mIsLinearEffect.

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

1964 {
1965  mIsLinearEffect = linearEffectFlag;
1966 }
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 1968 of file Effect.cpp.

References mPreviewFullSelection.

Referenced by NyquistEffect::Parse().

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

Implements ConfigClientInterface.

Definition at line 924 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().

925 {
926  return PluginManager::Get().SetPrivateConfig(GetID(), group, key, value);
927 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 929 of file Effect.cpp.

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

930 {
931  return PluginManager::Get().SetPrivateConfig(GetID(), group, key, value);
932 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 934 of file Effect.cpp.

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

935 {
936  return PluginManager::Get().SetPrivateConfig(GetID(), group, key, value);
937 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 939 of file Effect.cpp.

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

940 {
941  return PluginManager::Get().SetPrivateConfig(GetID(), group, key, value);
942 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 944 of file Effect.cpp.

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

945 {
946  return PluginManager::Get().SetPrivateConfig(GetID(), group, key, value);
947 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 324 of file Effect.cpp.

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

Referenced by ProcessPass().

325 {
326  if (mClient)
327  {
328  mClient->SetSampleRate(rate);
329  }
330 
331  mSampleRate = rate;
332 }
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 854 of file Effect.cpp.

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

855 {
856  return PluginManager::Get().SetSharedConfig(GetID(), group, key, value);
857 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 859 of file Effect.cpp.

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

860 {
861  return PluginManager::Get().SetSharedConfig(GetID(), group, key, value);
862 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 864 of file Effect.cpp.

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

865 {
866  return PluginManager::Get().SetSharedConfig(GetID(), group, key, value);
867 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 869 of file Effect.cpp.

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

870 {
871  return PluginManager::Get().SetSharedConfig(GetID(), group, key, value);
872 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 874 of file Effect.cpp.

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

875 {
876  return PluginManager::Get().SetSharedConfig(GetID(), group, key, value);
877 }
virtual PluginID GetID()
Definition: Effect.cpp:961
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 516 of file Effect.cpp.

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

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

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

Implements EffectUIClientInterface.

Definition at line 713 of file Effect.cpp.

714 {
715 }
bool Effect::Startup ( EffectClientInterface client)
virtual

Definition at line 971 of file Effect.cpp.

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

972 {
973  // Let destructor know we need to be shutdown
974  mClient = client;
975 
976  // Set host so client startup can use our services
977  if (!SetHost(this))
978  {
979  // Bail if the client startup fails
980  mClient = NULL;
981  return false;
982  }
983 
986 
987  bool haveDefaults;
988  GetPrivateConfig(GetFactoryDefaultsGroup(), wxT("Initialized"), haveDefaults, false);
989  if (!haveDefaults)
990  {
992  SetPrivateConfig(GetFactoryDefaultsGroup(), wxT("Initialized"), true);
993  }
995 
996  return Startup();
997 }
unsigned GetAudioInCount() override
Definition: Effect.cpp:284
bool SaveUserPreset(const wxString &name) override
Definition: Effect.cpp:602
bool GetPrivateConfig(const wxString &group, const wxString &key, wxString &value, const wxString &defval=wxEmptyString) override
Definition: Effect.cpp:899
wxString GetCurrentSettingsGroup() override
Definition: Effect.cpp:803
EffectClientInterface * mClient
Definition: Effect.h:527
bool SetPrivateConfig(const wxString &group, const wxString &key, const wxString &value) override
Definition: Effect.cpp:924
bool LoadUserPreset(const wxString &name) override
Definition: Effect.cpp:586
size_t mNumAudioIn
Definition: Effect.h:528
size_t mNumAudioOut
Definition: Effect.h:529
bool SetHost(EffectHostInterface *host) override
Definition: Effect.cpp:274
unsigned GetAudioOutCount() override
Definition: Effect.cpp:294
wxString GetFactoryDefaultsGroup() override
Definition: Effect.cpp:808
virtual bool Startup()
Definition: Effect.cpp:999
bool Effect::Startup ( )
virtual

Reimplemented in EffectEqualization, EffectReverb, EffectScienFilter, EffectTruncSilence, EffectChangeSpeed, EffectCompressor, EffectDtmf, EffectClickRemoval, EffectAutoDuck, EffectNoise, and EffectNormalize.

Definition at line 999 of file Effect.cpp.

Referenced by Startup().

1000 {
1001  return true;
1002 }
bool Effect::SupportsAutomation ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 262 of file Effect.cpp.

References mClient, and EffectDefinitionInterface::SupportsAutomation().

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

Implements EffectDefinitionInterface.

Reimplemented in EffectPhaser, and EffectWahwah.

Definition at line 252 of file Effect.cpp.

References mClient, and EffectDefinitionInterface::SupportsRealtime().

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

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

Definition at line 1979 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().

1980 {
1981  auto updateResult = (mProgress ?
1982  mProgress->Update(frac) :
1984  return (updateResult != ProgressResult::Success);
1985 }
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 1995 of file Effect.cpp.

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

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

1996 {
1997  auto updateResult = (mProgress ?
1998  mProgress->Update(whichGroup + frac, (double) mNumGroups, msg) :
2000  return (updateResult != ProgressResult::Success);
2001 }
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 674 of file Effect.cpp.

References mUIParent.

675 {
676  return mUIParent->Validate();
677 }
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(), 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(), EffectBassTreble::OnTrebleSlider(), EffectBassTreble::OnTrebleText(), EffectEqualization::PopulateOrExchange(), EffectEqualization::PopulateUI(), PopulateUI(), NyquistEffect::Process(), EffectPaulstretch::TransferDataFromWindow(), EffectRepeat::TransferDataFromWindow(), EffectFindClipping::TransferDataFromWindow(), EffectNoise::TransferDataFromWindow(), EffectNormalize::TransferDataFromWindow(), EffectToneGen::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(), EffectEcho::TransferDataToWindow(), EffectNormalize::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: