Audacity  2.2.2
Effect.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  Effect.h
6 
7  Dominic Mazzoni
8  Vaughan Johnson
9 
10 **********************************************************************/
11 
12 #ifndef __AUDACITY_EFFECT__
13 #define __AUDACITY_EFFECT__
14 
15 #include "../Audacity.h"
16 #include "../MemoryX.h"
17 #include <set>
18 
19 #include "../MemoryX.h"
20 #include <wx/bmpbuttn.h>
21 #include <wx/defs.h>
22 #include <wx/intl.h>
23 #include <wx/string.h>
24 #include <wx/tglbtn.h>
25 #include <wx/event.h> // for idle event.
26 
27 class wxCheckBox;
28 class wxChoice;
29 class wxListBox;
30 class wxWindow;
31 
34 
35 #include "../Experimental.h"
36 #include "../SampleFormat.h"
37 #include "../SelectedRegion.h"
38 #include "../Shuttle.h"
39 #include "../Internat.h"
40 #include "../widgets/ProgressDialog.h"
41 
42 #include "../Track.h"
43 
44 class ShuttleGui;
45 class AudacityCommand;
46 
47 #define BUILTIN_EFFECT_PREFIX wxT("Built-in Effect: ")
48 
49 class AudacityProject;
50 class LabelTrack;
51 class SelectedRegion;
52 class EffectUIHost;
53 class Track;
54 class TrackList;
55 class TrackFactory;
56 class WaveTrack;
57 
58 // TODO: Apr-06-2015
59 // TODO: Much more cleanup of old methods and variables is needed, but
60 // TODO: can't be done until after all effects are using the NEW API.
61 
62 class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler,
63  public EffectClientInterface,
65  public EffectHostInterface
66 {
67  //
68  // public methods
69  //
70  // Used by the outside program to determine properties of an effect and
71  // apply the effect to one or more tracks.
72  //
73  public:
74  // The constructor is called once by each subclass at the beginning of the program.
75  // Avoid allocating memory or doing time-consuming processing here.
76  Effect();
77  virtual ~Effect();
78 
79  // IdentInterface implementation
80 
81  wxString GetPath() override;
82 
84 
86  wxString GetVersion() override;
87  wxString GetDescription() override;
88 
89  // EffectDefinitionInterface implementation
90 
91  EffectType GetType() override;
93  bool IsInteractive() override;
94  bool IsDefault() override;
95  bool IsLegacy() override;
96  bool SupportsRealtime() override;
97  bool SupportsAutomation() override;
98 
99  // EffectClientInterface implementation
100 
101  bool SetHost(EffectHostInterface *host) override;
102 
103  unsigned GetAudioInCount() override;
104  unsigned GetAudioOutCount() override;
105 
106  int GetMidiInCount() override;
107  int GetMidiOutCount() override;
108 
109  sampleCount GetLatency() override;
110  size_t GetTailSize() override;
111 
112  void SetSampleRate(double rate) override;
113  size_t SetBlockSize(size_t maxBlockSize) override;
114 
115  bool IsReady() override;
116  bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override;
117  bool ProcessFinalize() override;
118  size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override;
119 
120  bool RealtimeInitialize() override;
121  bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override;
122  bool RealtimeFinalize() override;
123  bool RealtimeSuspend() override;
124  bool RealtimeResume() override;
125  bool RealtimeProcessStart() override;
126  size_t RealtimeProcess(int group,
127  float **inbuf,
128  float **outbuf,
129  size_t numSamples) override;
130  bool RealtimeProcessEnd() override;
131 
132  bool ShowInterface(wxWindow *parent, bool forceModal = false) override;
133 
134  bool GetAutomationParameters(CommandParameters & parms) override;
135  bool SetAutomationParameters(CommandParameters & parms) override;
136 
137  bool LoadUserPreset(const wxString & name) override;
138  bool SaveUserPreset(const wxString & name) override;
139 
140  wxArrayString GetFactoryPresets() override;
141  bool LoadFactoryPreset(int id) override;
142  bool LoadFactoryDefaults() override;
143 
144  // EffectUIClientInterface implementation
145 
146  void SetHostUI(EffectUIHostInterface *host) override;
147  bool PopulateUI(wxWindow *parent) override;
148  bool IsGraphicalUI() override;
149  bool ValidateUI() override;
150  bool HideUI() override;
151  bool CloseUI() override;
152 
153  bool CanExportPresets() override;
154  void ExportPresets() override;
155  void ImportPresets() override;
156 
157  bool HasOptions() override;
158  void ShowOptions() override;
159 
160  // EffectHostInterface implementation
161 
162  double GetDefaultDuration() override;
163  double GetDuration() override;
165  virtual NumericFormatId GetSelectionFormat() /* not override? */; // time format in Selection toolbar
166  void SetDuration(double duration) override;
167 
168  bool Apply() override;
169  void Preview() override;
170 
171  wxDialog *CreateUI(wxWindow *parent, EffectUIClientInterface *client) override;
172 
173  wxString GetUserPresetsGroup(const wxString & name) override;
174  wxString GetCurrentSettingsGroup() override;
175  wxString GetFactoryDefaultsGroup() override;
176  virtual wxString GetSavedStateGroup() /* not override? */;
177 
178  // ConfigClientInterface implementation
179 
180  bool HasSharedConfigGroup(const wxString & group) override;
181  bool GetSharedConfigSubgroups(const wxString & group, wxArrayString & subgroups) override;
182 
183  bool GetSharedConfig(const wxString & group, const wxString & key, wxString & value, const wxString & defval = wxEmptyString) override;
184  bool GetSharedConfig(const wxString & group, const wxString & key, int & value, int defval = 0) override;
185  bool GetSharedConfig(const wxString & group, const wxString & key, bool & value, bool defval = false) override;
186  bool GetSharedConfig(const wxString & group, const wxString & key, float & value, float defval = 0.0) override;
187  bool GetSharedConfig(const wxString & group, const wxString & key, double & value, double defval = 0.0) override;
188 
189  bool SetSharedConfig(const wxString & group, const wxString & key, const wxString & value) override;
190  bool SetSharedConfig(const wxString & group, const wxString & key, const int & value) override;
191  bool SetSharedConfig(const wxString & group, const wxString & key, const bool & value) override;
192  bool SetSharedConfig(const wxString & group, const wxString & key, const float & value) override;
193  bool SetSharedConfig(const wxString & group, const wxString & key, const double & value) override;
194 
195  bool RemoveSharedConfigSubgroup(const wxString & group) override;
196  bool RemoveSharedConfig(const wxString & group, const wxString & key) override;
197 
198  bool HasPrivateConfigGroup(const wxString & group) override;
199  bool GetPrivateConfigSubgroups(const wxString & group, wxArrayString & subgroups) override;
200 
201  bool GetPrivateConfig(const wxString & group, const wxString & key, wxString & value, const wxString & defval = wxEmptyString) override;
202  bool GetPrivateConfig(const wxString & group, const wxString & key, int & value, int defval = 0) override;
203  bool GetPrivateConfig(const wxString & group, const wxString & key, bool & value, bool defval = false) override;
204  bool GetPrivateConfig(const wxString & group, const wxString & key, float & value, float defval = 0.0) override;
205  bool GetPrivateConfig(const wxString & group, const wxString & key, double & value, double defval = 0.0) override;
206 
207  bool SetPrivateConfig(const wxString & group, const wxString & key, const wxString & value) override;
208  bool SetPrivateConfig(const wxString & group, const wxString & key, const int & value) override;
209  bool SetPrivateConfig(const wxString & group, const wxString & key, const bool & value) override;
210  bool SetPrivateConfig(const wxString & group, const wxString & key, const float & value) override;
211  bool SetPrivateConfig(const wxString & group, const wxString & key, const double & value) override;
212 
213  bool RemovePrivateConfigSubgroup(const wxString & group) override;
214  bool RemovePrivateConfig(const wxString & group, const wxString & key) override;
215 
216  // Effect implementation
217 
218  // NEW virtuals
219  virtual PluginID GetID();
220 
221  virtual bool Startup(EffectClientInterface *client);
222  virtual bool Startup();
223 
224  virtual bool GetAutomationParameters(wxString & parms);
225  virtual bool SetAutomationParameters(const wxString & parms);
226 
227  virtual wxArrayString GetUserPresets();
228  virtual bool HasCurrentSettings();
229  virtual bool HasFactoryDefaults();
230  virtual wxString GetPreset(wxWindow * parent, const wxString & parms);
231 
232  // Name of page in the Audacity alpha manual
233  virtual wxString ManualPage();
234  // Fully qualified local help file name
235  virtual wxString HelpPage();
236 
237  virtual bool IsBatchProcessing();
238  virtual void SetBatchProcessing(bool start);
239 
240  /* not virtual */ void SetPresetParameters( const wxArrayString * Names, const wxArrayString * Values ) {
241  if( Names ) mPresetNames = *Names;
242  if( Values ) mPresetValues = *Values;
243  }
244 
245  // Returns true on success. Will only operate on tracks that
246  // have the "selected" flag set to true, which is consistent with
247  // Audacity's standard UI.
248  /* not virtual */ bool DoEffect(wxWindow *parent, double projectRate, TrackList *list,
249  TrackFactory *factory, SelectedRegion *selectedRegion,
250  bool shouldPrompt = true);
251 
252  bool Delegate( Effect &delegate, wxWindow *parent, bool shouldPrompt);
253 
254  // Realtime Effect Processing
255  /* not virtual */ bool RealtimeAddProcessor(int group, unsigned chans, float rate);
256  /* not virtual */ size_t RealtimeProcess(int group,
257  unsigned chans,
258  float **inbuf,
259  float **outbuf,
260  size_t numSamples);
261  /* not virtual */ bool IsRealtimeActive();
262 
263  virtual bool IsHidden();
264 
265  // Nonvirtual
266  // Display a message box, using effect's (translated) name as the prefix
267  // for the title.
268  enum : long { DefaultMessageBoxStyle = wxOK | wxCENTRE };
269  int MessageBox(const wxString& message,
270  long style = DefaultMessageBoxStyle,
271  const wxString& titleStr = wxString{});
272 
273 //
274 // protected virtual methods
275 //
276 // Each subclass of Effect overrides one or more of these methods to
277 // do its processing.
278 //
279 protected:
280 
281  // Called once each time an effect is called. Perform any initialization;
282  // make sure that the effect can be performed on the selected tracks and
283  // return false otherwise
284  virtual bool Init();
285 
286  // If necessary, open a dialog to get parameters from the user.
287  // This method will not always be called (for example if a user
288  // repeats an effect) but if it is called, it will be called
289  // after Init.
290  virtual bool PromptUser(wxWindow *parent);
291 
292  // Check whether effect should be skipped
293  // Typically this is only useful in automation, for example
294  // detecting that zero noise reduction is to be done,
295  // or that normalisation is being done without Dc bias shift
296  // or amplitude modification
297  virtual bool CheckWhetherSkipEffect() { return false; }
298 
299  // Actually do the effect here.
300  virtual bool Process();
301  virtual bool ProcessPass();
302  virtual bool InitPass1();
303  virtual bool InitPass2();
304  virtual int GetPass();
305 
306  // clean up any temporary memory, needed only per invocation of the
307  // effect, after either successful or failed or exception-aborted processing.
308  // Invoked inside a "finally" block so it must be no-throw.
309  virtual void End();
310 
311  // Most effects just use the previewLength, but time-stretching/compressing
312  // effects need to use a different input length, so override this method.
313  virtual double CalcPreviewInputLength(double previewLength);
314 
315  // The Effect class fully implements the Preview method for you.
316  // Only override it if you need to do preprocessing or cleanup.
317  virtual void Preview(bool dryOnly);
318 
319  virtual void PopulateOrExchange(ShuttleGui & S);
320  virtual bool TransferDataToWindow() /* not override */;
321  virtual bool TransferDataFromWindow() /* not override */;
322  virtual bool EnableApply(bool enable = true);
323  virtual bool EnablePreview(bool enable = true);
324  virtual void EnableDebug(bool enable = true);
325 
326  // No more virtuals!
327 
328  // The Progress methods all return true if the user has cancelled;
329  // you should exit immediately if this happens (cleaning up memory
330  // is okay, but don't try to undo).
331 
332  // Pass a fraction between 0.0 and 1.0
333  bool TotalProgress(double frac);
334 
335  // Pass a fraction between 0.0 and 1.0, for the current track
336  // (when doing one track at a time)
337  bool TrackProgress(int whichTrack, double frac, const wxString & = wxEmptyString);
338 
339  // Pass a fraction between 0.0 and 1.0, for the current track group
340  // (when doing stereo groups at a time)
341  bool TrackGroupProgress(int whichGroup, double frac, const wxString & = wxEmptyString);
342 
343  int GetNumWaveTracks() { return mNumTracks; }
344 
345  int GetNumWaveGroups() { return mNumGroups; }
346 
347  // Calculates the start time and selection length in samples
348  void GetSamples(
349  const WaveTrack *track, sampleCount *start, sampleCount *len);
350 
351  // Previewing linear effect can be optimised by pre-mixing. However this
352  // should not be used for non-linear effects such as dynamic processors
353  // To allow pre-mixing before Preview, set linearEffectFlag to true.
354  void SetLinearEffectFlag(bool linearEffectFlag);
355 
356  // Most effects only need to preview a short selection. However some
357  // (such as fade effects) need to know the full selection length.
358  void SetPreviewFullSelectionFlag(bool previewDurationFlag);
359 
360  // Use this if the effect needs to know if it is previewing
361  bool IsPreviewing() { return mIsPreview; }
362 
363  // Most effects only require selected tracks to be copied for Preview.
364  // If IncludeNotSelectedPreviewTracks(true), then non-linear effects have
365  // preview copies of all wave tracks.
366  void IncludeNotSelectedPreviewTracks(bool includeNotSelected);
367 
368  // Use these two methods to copy the input tracks to mOutputTracks, if
369  // doing the processing on them, and replacing the originals only on success (and not cancel).
370  void CopyInputTracks(); // trackType = Track::Wave
371  void CopyInputTracks(int trackType);
372 
373  // For the use of analyzers, which don't need to make output wave tracks,
374  // but may need to add label tracks.
376  friend Effect;
377  AddedAnalysisTrack(Effect *pEffect, const wxString &name);
379 
380  public:
381 
383 
384  // So you can have a vector of them
386 
387  LabelTrack *get() const { return mpTrack; }
388 
389  // Call this to indicate successful completion of the analyzer.
390  void Commit();
391 
392  // Destructor undoes the addition of the analysis track if not committed.
394 
395  private:
396  Effect *mpEffect{};
397  LabelTrack *mpTrack{};
398  };
399 
400  // Set name to given value if that is not empty, else use default name
401  std::shared_ptr<AddedAnalysisTrack> AddAnalysisTrack(const wxString &name = wxString());
402 
403  // For the use of analyzers, which don't need to make output wave tracks,
404  // but may need to modify label tracks.
406  friend Effect;
408  (Effect *pEffect, const LabelTrack *pOrigTrack, const wxString &name);
410 
411  public:
412 
414 
415  // So you can have a vector of them
416  ModifiedAnalysisTrack(ModifiedAnalysisTrack &&that);
417 
418  LabelTrack *get() const { return mpTrack; }
419 
420  // Call this to indicate successful completion of the analyzer.
421  void Commit();
422 
423  // Destructor undoes the modification of the analysis track if not committed.
425 
426  private:
427  Effect *mpEffect{};
428  LabelTrack *mpTrack{};
429  std::shared_ptr<Track> mpOrigTrack{};
430  };
431 
432  // Set name to given value if that is not empty, else use default name
433  ModifiedAnalysisTrack ModifyAnalysisTrack
434  (const LabelTrack *pOrigTrack, const wxString &name = wxString());
435 
436  // If bGoodResult, replace mWaveTracks tracks in mTracks with successfully processed
437  // mOutputTracks copies, get rid of old mWaveTracks, and set mWaveTracks to mOutputTracks.
438  // Else clear and DELETE mOutputTracks copies.
439  void ReplaceProcessedTracks(const bool bGoodResult);
440 
441  // Use this to append a NEW output track.
442  Track *AddToOutputTracks(std::unique_ptr<Track> &&t);
443 
444 //
445 // protected data
446 //
447 // The Effect base class will set these variables, some or all of which
448 // may be needed by any particular subclass of Effect.
449 //
450 protected:
451 
452  ProgressDialog *mProgress; // Temporary pointer, NOT deleted in destructor.
453  double mProjectRate; // Sample rate of the project - NEW tracks should
454  // be created with this rate...
455  double mSampleRate;
456  SelectedRegion *mpSelectedRegion{};
458  TrackList *inputTracks() const { return mTracks; }
459  std::shared_ptr<TrackList> mOutputTracks; // used only if CopyInputTracks() is called.
460  double mT0;
461  double mT1;
462 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
463  double mF0;
464  double mF1;
465 #endif
466  wxArrayString mPresetNames;
467  wxArrayString mPresetValues;
468  int mPass;
469 
470  // UI
471  wxDialog *mUIDialog;
472  wxWindow *mUIParent;
474 
476 
477  // type of the tracks on mOutputTracks
479 
480  // Used only by the base Effect class
481  //
482  private:
483  void CommonInit();
484  void CountWaveTracks();
485 
486  // Driver for client effects
487  bool ProcessTrack(int count,
488  ChannelNames map,
489  WaveTrack *left,
490  WaveTrack *right,
491  sampleCount leftStart,
492  sampleCount rightStart,
493  sampleCount len,
494  FloatBuffers &inBuffer,
495  FloatBuffers &outBuffer,
496  ArrayOf< float * > &inBufPos,
497  ArrayOf< float *> &outBufPos);
498 
499  //
500  // private data
501  //
502  // Used only by the base Effect class
503  //
504 private:
505  TrackList *mTracks; // the complete list of all tracks
506 
507  bool mIsBatch;
511 
513  double mDuration;
515 
517 
518  bool mUIDebug;
519 
520  std::vector<Track*> mIMap;
521  std::vector<Track*> mOMap;
522 
523  int mNumTracks; //v This is really mNumWaveTracks, per CountWaveTracks() and GetNumWaveTracks().
525 
526  // For client driver
528  size_t mNumAudioIn;
529  size_t mNumAudioOut;
530 
531  size_t mBufferSize;
532  size_t mBlockSize;
533  unsigned mNumChannels;
534 
535  std::vector<int> mGroupProcessor;
537 
538  wxCriticalSection mRealtimeSuspendLock;
540 
541  const static wxString kUserPresetIdent;
542  const static wxString kFactoryPresetIdent;
543  const static wxString kCurrentSettingsIdent;
544  const static wxString kFactoryDefaultsIdent;
545 
546  friend class EffectManager;// so it can call PromptUser in support of batch commands.
547  friend class EffectRack;
548  friend class EffectUIHost;
549  friend class EffectPresetsDialog;
550 };
551 
552 
553 // FIXME:
554 // FIXME: Remove this once all effects are using the NEW dialog
555 // FIXME:
556 
557 #define ID_EFFECT_PREVIEW ePreviewID
558 
559 // Base dialog for regular effect
560 class AUDACITY_DLL_API EffectDialog /* not final */ : public wxDialogWrapper
561 {
562 public:
563  // constructors and destructors
564  EffectDialog(wxWindow * parent,
565  const wxString & title,
566  int type = 0,
567  int flags = wxDEFAULT_DIALOG_STYLE,
568  int additionalButtons = 0);
569 
570  void Init();
571 
572  bool TransferDataToWindow() override;
573  bool TransferDataFromWindow() override;
574  bool Validate() override;
575 
576  // NEW virtuals:
577  virtual void PopulateOrExchange(ShuttleGui & S);
578  virtual void OnPreview(wxCommandEvent & evt);
579  virtual void OnOk(wxCommandEvent & evt);
580 
581 private:
582  int mType;
584 
585  DECLARE_EVENT_TABLE()
586  wxDECLARE_NO_COPY_CLASS(EffectDialog);
587 };
588 
589 //
590 class EffectUIHost final : public wxDialogWrapper,
591  public EffectUIHostInterface
592 {
593 public:
594  // constructors and destructors
595  EffectUIHost(wxWindow *parent,
596  Effect *effect,
597  EffectUIClientInterface *client);
598  EffectUIHost(wxWindow *parent,
599  AudacityCommand *command,
600  EffectUIClientInterface *client);
601  virtual ~EffectUIHost();
602 
603  bool TransferDataToWindow() override;
604  bool TransferDataFromWindow() override;
605 
606  int ShowModal() override;
607 
608  bool Initialize();
609 
610 private:
611  void OnInitDialog(wxInitDialogEvent & evt);
612  void OnErase(wxEraseEvent & evt);
613  void OnPaint(wxPaintEvent & evt);
614  void OnClose(wxCloseEvent & evt);
615  void OnApply(wxCommandEvent & evt);
616  void DoCancel();
617  void OnCancel(wxCommandEvent & evt);
618  void OnHelp(wxCommandEvent & evt);
619  void OnDebug(wxCommandEvent & evt);
620  void OnMenu(wxCommandEvent & evt);
621  void OnEnable(wxCommandEvent & evt);
622  void OnPlay(wxCommandEvent & evt);
623  void OnRewind(wxCommandEvent & evt);
624  void OnFFwd(wxCommandEvent & evt);
625  void OnPlayback(wxCommandEvent & evt);
626  void OnCapture(wxCommandEvent & evt);
627  void OnUserPreset(wxCommandEvent & evt);
628  void OnFactoryPreset(wxCommandEvent & evt);
629  void OnDeletePreset(wxCommandEvent & evt);
630  void OnSaveAs(wxCommandEvent & evt);
631  void OnImport(wxCommandEvent & evt);
632  void OnExport(wxCommandEvent & evt);
633  void OnOptions(wxCommandEvent & evt);
634  void OnDefaults(wxCommandEvent & evt);
635 
636  void UpdateControls();
637  wxBitmap CreateBitmap(const char * const xpm[], bool up, bool pusher);
638  void LoadUserPresets();
639 
640  void InitializeRealtime();
641  void CleanupRealtime();
642  void Resume();
643 
644 private:
646  wxWindow *mParent;
650 
651  wxArrayString mUserPresets;
654  bool mIsGUI;
655  bool mIsBatch;
656 
657  wxButton *mApplyBtn;
658  wxButton *mCloseBtn;
659  wxButton *mMenuBtn;
660  wxButton *mPlayBtn;
661  wxButton *mRewindBtn;
662  wxButton *mFFwdBtn;
663  wxCheckBox *mEnableCb;
664 
665  wxButton *mEnableToggleBtn;
666  wxButton *mPlayToggleBtn;
667 
668  wxBitmap mPlayBM;
669  wxBitmap mPlayDisabledBM;
670  wxBitmap mStopBM;
671  wxBitmap mStopDisabledBM;
672 
673  bool mEnabled;
674 
676  bool mPlaying;
678 
680  double mPlayPos;
681 
682  bool mDismissed{};
683  bool mNeedsResume{};
684 
685  DECLARE_EVENT_TABLE()
686 };
687 
689 {
690 public:
691  EffectPresetsDialog(wxWindow *parent, Effect *effect);
692  virtual ~EffectPresetsDialog();
693 
694  wxString GetSelected() const;
695  void SetSelected(const wxString & parms);
696 
697 private:
698  void SetPrefix(const wxString & type, const wxString & prefix);
699  void UpdateUI();
700 
701  void OnType(wxCommandEvent & evt);
702  void OnOk(wxCommandEvent & evt);
703  void OnCancel(wxCommandEvent & evt);
704 
705 private:
706  wxChoice *mType;
707  wxListBox *mPresets;
708 
709  wxArrayString mFactoryPresets;
710  wxArrayString mUserPresets;
711  wxString mSelection;
712 
713  DECLARE_EVENT_TABLE()
714 };
715 
716 // Utility functions
717 
718 inline float TrapFloat(float x, float min, float max)
719 {
720  if (x <= min)
721  return min;
722 
723  if (x >= max)
724  return max;
725 
726  return x;
727 }
728 
729 inline double TrapDouble(double x, double min, double max)
730 {
731  if (x <= min)
732  return min;
733 
734  if (x >= max)
735  return max;
736 
737  return x;
738 }
739 
740 inline long TrapLong(long x, long min, long max)
741 {
742  if (x <= min)
743  return min;
744 
745  if (x >= max)
746  return max;
747 
748  return x;
749 }
750 
751 // Helper macros for defining, reading and verifying effect parameters
752 
753 #define Param(name, type, key, def, min, max, scale) \
754  static const wxChar * KEY_ ## name = (key); \
755  static const type DEF_ ## name = (def); \
756  static const type MIN_ ## name = (min); \
757  static const type MAX_ ## name = (max); \
758  static const type SCL_ ## name = (scale);
759 
760 #define PBasic(name, type, key, def) \
761  static const wxChar * KEY_ ## name = (key); \
762  static const type DEF_ ## name = (def);
763 
764 #define PRange(name, type, key, def, min, max) \
765  PBasic(name, type, key, def); \
766  static const type MIN_ ## name = (min); \
767  static const type MAX_ ## name = (max);
768 
769 #define PScale(name, type, key, def, min, max, scale) \
770  PRange(name, type, key, def, min, max); \
771  static const type SCL_ ## name = (scale);
772 
773 #define ReadParam(type, name) \
774  type name = DEF_ ## name; \
775  if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name, MIN_ ## name, MAX_ ## name)) \
776  return false;
777 
778 #define ReadBasic(type, name) \
779  type name; \
780  wxUnusedVar(MIN_ ##name); \
781  wxUnusedVar(MAX_ ##name); \
782  wxUnusedVar(SCL_ ##name); \
783  if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name)) \
784  return false;
785 
786 #define ReadAndVerifyEnum(name, list, listSize) \
787  int name; \
788  if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name, list, listSize)) \
789  return false;
790 
791 #define ReadAndVerifyEnumWithObsoletes(name, list, listSize, obsoleteList, nObsolete) \
792  int name; \
793  if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name, \
794  list, listSize, obsoleteList, nObsolete)) \
795  return false;
796 
797 #define ReadAndVerifyInt(name) ReadParam(int, name)
798 #define ReadAndVerifyDouble(name) ReadParam(double, name)
799 #define ReadAndVerifyFloat(name) ReadParam(float, name)
800 #define ReadAndVerifyBool(name) ReadBasic(bool, name)
801 #define ReadAndVerifyString(name) ReadBasic(wxString, name)
802 
803 #endif
void OnExport(const wxString &Format)
wxArrayString mUserPresets
Definition: Effect.h:651
double mT1
Definition: Effect.h:461
A list of TrackListNode items.
Definition: Track.h:619
AudacityCommand * mCommand
Definition: Effect.h:648
virtual bool GetPrivateConfigSubgroups(const wxString &group, wxArrayString &subgroups)=0
virtual bool IsGraphicalUI()=0
virtual bool PopulateUI(wxWindow *parent)=0
EffectUIClientInterface is an abstract base class to populate a UI and validate UI values...
#define PROHIBITED
Definition: Audacity.h:224
std::vector< int > mGroupProcessor
Definition: Effect.h:535
virtual size_t SetBlockSize(size_t maxBlockSize)=0
int mAdditionalButtons
Definition: Effect.h:583
virtual void Preview()=0
virtual int GetMidiOutCount()=0
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
virtual IdentInterfaceSymbol GetFamilyId()=0
ProgressDialog Class.
ProgressDialog * mProgress
Definition: Effect.h:452
bool IsPreviewing()
Definition: Effect.h:361
TrackList * mTracks
Definition: Effect.h:505
int mPass
Definition: Effect.h:468
wxButton * mPlayToggleBtn
Definition: Effect.h:666
virtual bool HasOptions()=0
wxButton * mCloseBtn
Definition: Effect.h:658
double mPlayPos
Definition: Effect.h:680
virtual bool RealtimeFinalize()=0
int mOutputTracksType
Definition: Effect.h:478
EffectUIClientInterface * mClient
Definition: Effect.h:649
bool mPreviewFullSelection
Definition: Effect.h:510
virtual bool CanExportPresets()=0
wxBitmap mPlayDisabledBM
Definition: Effect.h:669
bool mIsPreview
Definition: Effect.h:516
bool mPlaying
Definition: Effect.h:676
virtual void ShowOptions()=0
EffectClientInterface * mClient
Definition: Effect.h:527
wxWindow * mParent
Definition: Effect.h:646
virtual unsigned GetAudioInCount()=0
wxButton * mRewindBtn
Definition: Effect.h:661
void SetPresetParameters(const wxArrayString *Names, const wxArrayString *Values)
Definition: Effect.h:240
virtual bool RemoveSharedConfigSubgroup(const wxString &group)=0
int mType
Definition: Effect.h:582
SelectedRegion mRegion
Definition: Effect.h:679
virtual wxString GetFactoryDefaultsGroup()=0
virtual bool ShowInterface(wxWindow *parent, bool forceModal=false)=0
wxString PluginID
Definition: Types.h:209
virtual bool SupportsRealtime()=0
virtual bool RealtimeProcessEnd()=0
Base class for many of the effects in Audacity.
Definition: Effect.h:62
wxListBox * mPresets
Definition: Effect.h:707
virtual void ExportPresets()=0
wxButton * mApplyBtn
Definition: Effect.h:657
virtual bool RemovePrivateConfigSubgroup(const wxString &group)=0
New (Jun-2006) base class for effects dialogs. Likely to get greater use in future.
Definition: Effect.h:560
AudacityProject * mProject
Definition: Effect.h:645
bool mSupportsRealtime
Definition: Effect.h:653
virtual wxString GetCurrentSettingsGroup()=0
virtual bool RealtimeProcessStart()=0
virtual size_t GetTailSize()=0
virtual IdentInterfaceSymbol GetSymbol()=0
size_t mBufferSize
Definition: Effect.h:531
double mSampleRate
Definition: Effect.h:455
virtual bool HasPrivateConfigGroup(const wxString &group)=0
bool mIsSelection
Definition: Effect.h:512
wxArrayString mPresetNames
Definition: Effect.h:466
TrackList * inputTracks() const
Definition: Effect.h:458
size_t mNumAudioIn
Definition: Effect.h:528
virtual bool HideUI()=0
wxCriticalSection mRealtimeSuspendLock
Definition: Effect.h:538
Used to create a WaveTrack, or a LabelTrack.. Implementation of the functions of this class are dispe...
Definition: Track.h:863
double mF0
Definition: Effect.h:463
bool mIsBatch
Definition: Effect.h:655
virtual bool SetSharedConfig(const wxString &group, const wxString &key, const wxString &value)=0
size_t mNumAudioOut
Definition: Effect.h:529
wxBitmap mStopBM
Definition: Effect.h:670
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:113
wxArrayString mFactoryPresets
Definition: Effect.h:709
virtual wxString GetDescription()=0
virtual void ImportPresets()=0
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
virtual wxString GetVersion()=0
virtual bool GetSharedConfigSubgroups(const wxString &group, wxArrayString &subgroups)=0
virtual bool RealtimeAddProcessor(unsigned numChannels, float sampleRate)=0
std::vector< Track * > mOMap
Definition: Effect.h:521
virtual bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL)=0
virtual bool SaveUserPreset(const wxString &name)=0
void OnClose(const CommandContext &context)
Defines a selected portion of a project.
virtual sampleCount GetLatency()=0
wxButton * mMenuBtn
Definition: Effect.h:659
virtual bool GetAutomationParameters(CommandParameters &parms)=0
virtual double GetDuration()=0
void OnImport(const CommandContext &context)
static const wxString kUserPresetIdent
Definition: Effect.h:541
size_t mBlockSize
Definition: Effect.h:532
virtual bool IsReady()=0
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
int mNumTracks
Definition: Effect.h:523
virtual bool GetSharedConfig(const wxString &group, const wxString &key, wxString &value, const wxString &defval)=0
virtual bool RealtimeSuspend()=0
virtual wxArrayString GetFactoryPresets()=0
virtual bool RealtimeInitialize()=0
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
void OnSaveAs(const CommandContext &context)
virtual bool GetPrivateConfig(const wxString &group, const wxString &key, wxString &value, const wxString &defval)=0
virtual double GetDefaultDuration()=0
wxChoice * mType
Definition: Effect.h:706
virtual bool LoadFactoryDefaults()=0
bool mIsLinearEffect
Definition: Effect.h:508
wxString mSelection
Definition: Effect.h:711
int mRealtimeSuspendCount
Definition: Effect.h:539
std::vector< Track * > mIMap
Definition: Effect.h:520
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:45
bool mCapturing
Definition: Effect.h:677
int min(int a, int b)
bool DoEffect(const PluginID &ID, const CommandContext &context, int flags)
bool mPreviewWithNotSelected
Definition: Effect.h:509
virtual bool IsDefault()=0
IdentInterfaceSymbol pairs a persistent string identifier used internally with an optional...
Base class for command in Audacity.
enum ChannelName * ChannelNames
virtual bool SupportsAutomation()=0
long TrapLong(long x, long min, long max)
Definition: Effect.h:740
virtual bool RemovePrivateConfig(const wxString &group, const wxString &key)=0
virtual bool RemoveSharedConfig(const wxString &group, const wxString &key)=0
wxWindow * mUIParent
Definition: Effect.h:472
virtual bool ValidateUI()=0
virtual int GetMidiInCount()=0
double TrapDouble(double x, double min, double max)
Definition: Effect.h:729
double mProjectRate
Definition: Effect.h:453
unsigned mNumChannels
Definition: Effect.h:533
TrackFactory * mFactory
Definition: Effect.h:457
virtual EffectType GetType()=0
EffectHostInterface is a decorator of a EffectUIClientInterface. It adds virtual (abstract) functions...
virtual bool SetHost(EffectHostInterface *host)=0
EffectType
wxDialog * mUIDialog
Definition: Effect.h:471
bool mUIDebug
Definition: Effect.h:518
int mCurrentProcessor
Definition: Effect.h:536
bool mInitialized
Definition: Effect.h:652
const wxChar * name
Definition: Distortion.cpp:94
wxButton * mFFwdBtn
Definition: Effect.h:662
virtual IdentInterfaceSymbol GetVendor()=0
int GetNumWaveTracks()
Definition: Effect.h:343
wxButton * mEnableToggleBtn
Definition: Effect.h:665
bool mDisableTransport
Definition: Effect.h:675
wxArrayString mUserPresets
Definition: Effect.h:710
virtual bool RealtimeResume()=0
Memory.h template class for making an array of float, bool, etc.
Definition: MemoryX.h:86
float TrapFloat(float x, float min, float max)
Definition: Effect.h:718
virtual wxDialog * CreateUI(wxWindow *parent, EffectUIClientInterface *client)=0
static const wxString kFactoryPresetIdent
Definition: Effect.h:542
int GetNumWaveGroups()
Definition: Effect.h:345
EffectClientInterface provides the ident interface to Effect, and is what makes Effect into a plug-in...
wxButton * mPlayBtn
Definition: Effect.h:660
NumericFormatId mDurationFormat
Definition: Effect.h:514
bool mIsGUI
Definition: Effect.h:654
static const wxString kCurrentSettingsIdent
Definition: Effect.h:543
wxBitmap mPlayBM
Definition: Effect.h:668
double mDuration
Definition: Effect.h:513
virtual bool SetPrivateConfig(const wxString &group, const wxString &key, const wxString &value)=0
virtual void SetSampleRate(double rate)=0
virtual bool LoadFactoryPreset(int id)=0
sampleCount mSampleCnt
Definition: Effect.h:475
virtual unsigned GetAudioOutCount()=0
wxArrayString mPresetValues
Definition: Effect.h:467
virtual bool IsInteractive()=0
double mF1
Definition: Effect.h:464
bool mIsBatch
Definition: Effect.h:507
Effect * mEffect
Definition: Effect.h:647
virtual void SetDuration(double seconds)=0
virtual wxString GetPath()=0
wxBitmap mStopDisabledBM
Definition: Effect.h:671
virtual size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen)=0
virtual wxString GetUserPresetsGroup(const wxString &name)=0
virtual bool SetAutomationParameters(CommandParameters &parms)=0
bool mEnabled
Definition: Effect.h:673
int mUIResultID
Definition: Effect.h:473
virtual bool Apply()=0
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:459
virtual bool LoadUserPreset(const wxString &name)=0
virtual bool CheckWhetherSkipEffect()
Definition: Effect.h:297
wxCheckBox * mEnableCb
Definition: Effect.h:663
virtual void SetHostUI(EffectUIHostInterface *host)=0
virtual bool HasSharedConfigGroup(const wxString &group)=0
virtual bool IsLegacy()=0
double mT0
Definition: Effect.h:460
virtual NumericFormatId GetDurationFormat()=0
EffectUIHostInterface has nothing in it. It is provided so that an Effect can call SetHostUI passing ...
int mNumGroups
Definition: Effect.h:524
static const wxString kFactoryDefaultsIdent
Definition: Effect.h:544
virtual bool CloseUI()=0
virtual size_t RealtimeProcess(int group, float **inBuf, float **outBuf, size_t numSamples)=0
virtual bool ProcessFinalize()=0