Audacity  2.2.0
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/dynarray.h>
23 #include <wx/intl.h>
24 #include <wx/string.h>
25 #include <wx/tglbtn.h>
26 #include <wx/event.h> // for idle event.
27 
28 class wxCheckBox;
29 class wxChoice;
30 class wxListBox;
31 class wxWindow;
32 
33 #include "audacity/ConfigInterface.h"
34 #include "audacity/EffectInterface.h"
35 
36 #include "../Experimental.h"
37 #include "../SampleFormat.h"
38 #include "../SelectedRegion.h"
39 #include "../Shuttle.h"
40 #include "../Internat.h"
41 #include "../widgets/ProgressDialog.h"
42 
43 #include "../Track.h"
44 
45 class ShuttleGui;
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,
64  public EffectUIClientInterface,
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  wxString GetSymbol() override;
83  wxString GetName() override;
84  wxString GetVendor() override;
85  wxString GetVersion() override;
86  wxString GetDescription() override;
87 
88  // EffectIdentInterface implementation
89 
90  EffectType GetType() override;
91  wxString GetFamily() override;
92  bool IsInteractive() override;
93  bool IsDefault() override;
94  bool IsLegacy() override;
95  bool SupportsRealtime() override;
96  bool SupportsAutomation() override;
97 
98  // EffectClientInterface implementation
99 
100  bool SetHost(EffectHostInterface *host) override;
101 
102  unsigned GetAudioInCount() override;
103  unsigned GetAudioOutCount() override;
104 
105  int GetMidiInCount() override;
106  int GetMidiOutCount() override;
107 
108  sampleCount GetLatency() override;
109  size_t GetTailSize() override;
110 
111  void SetSampleRate(double rate) override;
112  size_t SetBlockSize(size_t maxBlockSize) override;
113 
114  bool IsReady() override;
115  bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override;
116  bool ProcessFinalize() override;
117  size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override;
118 
119  bool RealtimeInitialize() override;
120  bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override;
121  bool RealtimeFinalize() override;
122  bool RealtimeSuspend() override;
123  bool RealtimeResume() override;
124  bool RealtimeProcessStart() override;
125  size_t RealtimeProcess(int group,
126  float **inbuf,
127  float **outbuf,
128  size_t numSamples) override;
129  bool RealtimeProcessEnd() override;
130 
131  bool ShowInterface(wxWindow *parent, bool forceModal = false) override;
132 
133  bool GetAutomationParameters(EffectAutomationParameters & parms) override;
134  bool SetAutomationParameters(EffectAutomationParameters & parms) override;
135 
136  bool LoadUserPreset(const wxString & name) override;
137  bool SaveUserPreset(const wxString & name) override;
138 
139  wxArrayString GetFactoryPresets() override;
140  bool LoadFactoryPreset(int id) override;
141  bool LoadFactoryDefaults() override;
142 
143  // EffectUIClientInterface implementation
144 
145  void SetHostUI(EffectUIHostInterface *host) override;
146  bool PopulateUI(wxWindow *parent) override;
147  bool IsGraphicalUI() override;
148  bool ValidateUI() override;
149  bool HideUI() override;
150  bool CloseUI() override;
151 
152  bool CanExportPresets() override;
153  void ExportPresets() override;
154  void ImportPresets() override;
155 
156  bool HasOptions() override;
157  void ShowOptions() override;
158 
159  // EffectHostInterface implementation
160 
161  double GetDefaultDuration() override;
162  double GetDuration() override;
163  wxString GetDurationFormat() override;
164  virtual wxString GetSelectionFormat() /* not override? */; // time format in Selection toolbar
165  void SetDuration(double duration) override;
166 
167  bool Apply() override;
168  void Preview() override;
169 
170  wxDialog *CreateUI(wxWindow *parent, EffectUIClientInterface *client) override;
171 
172  wxString GetUserPresetsGroup(const wxString & name) override;
173  wxString GetCurrentSettingsGroup() override;
174  wxString GetFactoryDefaultsGroup() override;
175  virtual wxString GetSavedStateGroup() /* not override? */;
176 
177  // ConfigClientInterface implementation
178 
179  bool HasSharedConfigGroup(const wxString & group) override;
180  bool GetSharedConfigSubgroups(const wxString & group, wxArrayString & subgroups) override;
181 
182  bool GetSharedConfig(const wxString & group, const wxString & key, wxString & value, const wxString & defval = wxEmptyString) override;
183  bool GetSharedConfig(const wxString & group, const wxString & key, int & value, int defval = 0) override;
184  bool GetSharedConfig(const wxString & group, const wxString & key, bool & value, bool defval = false) override;
185  bool GetSharedConfig(const wxString & group, const wxString & key, float & value, float defval = 0.0) override;
186  bool GetSharedConfig(const wxString & group, const wxString & key, double & value, double defval = 0.0) override;
187 
188  bool SetSharedConfig(const wxString & group, const wxString & key, const wxString & value) override;
189  bool SetSharedConfig(const wxString & group, const wxString & key, const int & value) override;
190  bool SetSharedConfig(const wxString & group, const wxString & key, const bool & value) override;
191  bool SetSharedConfig(const wxString & group, const wxString & key, const float & value) override;
192  bool SetSharedConfig(const wxString & group, const wxString & key, const double & value) override;
193 
194  bool RemoveSharedConfigSubgroup(const wxString & group) override;
195  bool RemoveSharedConfig(const wxString & group, const wxString & key) override;
196 
197  bool HasPrivateConfigGroup(const wxString & group) override;
198  bool GetPrivateConfigSubgroups(const wxString & group, wxArrayString & subgroups) override;
199 
200  bool GetPrivateConfig(const wxString & group, const wxString & key, wxString & value, const wxString & defval = wxEmptyString) override;
201  bool GetPrivateConfig(const wxString & group, const wxString & key, int & value, int defval = 0) override;
202  bool GetPrivateConfig(const wxString & group, const wxString & key, bool & value, bool defval = false) override;
203  bool GetPrivateConfig(const wxString & group, const wxString & key, float & value, float defval = 0.0) override;
204  bool GetPrivateConfig(const wxString & group, const wxString & key, double & value, double defval = 0.0) override;
205 
206  bool SetPrivateConfig(const wxString & group, const wxString & key, const wxString & value) override;
207  bool SetPrivateConfig(const wxString & group, const wxString & key, const int & value) override;
208  bool SetPrivateConfig(const wxString & group, const wxString & key, const bool & value) override;
209  bool SetPrivateConfig(const wxString & group, const wxString & key, const float & value) override;
210  bool SetPrivateConfig(const wxString & group, const wxString & key, const double & value) override;
211 
212  bool RemovePrivateConfigSubgroup(const wxString & group) override;
213  bool RemovePrivateConfig(const wxString & group, const wxString & key) override;
214 
215  // Effect implementation
216 
217  // NEW virtuals
218  virtual PluginID GetID();
219 
220  virtual bool Startup(EffectClientInterface *client);
221  virtual bool Startup();
222 
223  virtual bool GetAutomationParameters(wxString & parms);
224  virtual bool SetAutomationParameters(const wxString & parms);
225 
226  virtual wxArrayString GetUserPresets();
227  virtual bool HasCurrentSettings();
228  virtual bool HasFactoryDefaults();
229  virtual wxString GetPreset(wxWindow * parent, const wxString & parms);
230 
231  // Name of page in the Audacity alpha manual
232  virtual wxString ManualPage();
233  // Fully qualified local help file name
234  virtual wxString HelpPage();
235 
236  virtual bool IsBatchProcessing();
237  virtual void SetBatchProcessing(bool start);
238 
239  /* not virtual */ void SetPresetParameters( const wxArrayString * Names, const wxArrayString * Values ) {
240  if( Names ) mPresetNames = *Names;
241  if( Values ) mPresetValues = *Values;
242  }
243 
244  // Returns true on success. Will only operate on tracks that
245  // have the "selected" flag set to true, which is consistent with
246  // Audacity's standard UI.
247  /* not virtual */ bool DoEffect(wxWindow *parent, double projectRate, TrackList *list,
248  TrackFactory *factory, SelectedRegion *selectedRegion,
249  bool shouldPrompt = true);
250 
251  bool Delegate( Effect &delegate,
252  wxWindow *parent, SelectedRegion *selectedRegion, 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();
321  virtual bool TransferDataFromWindow();
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;
457  TrackList *inputTracks() const { return mTracks; }
458  std::shared_ptr<TrackList> mOutputTracks; // used only if CopyInputTracks() is called.
459  double mT0;
460  double mT1;
461 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
462  double mF0;
463  double mF1;
464 #endif
465  wxArrayString mPresetNames;
466  wxArrayString mPresetValues;
467  int mPass;
468 
469  // UI
470  wxDialog *mUIDialog;
471  wxWindow *mUIParent;
473 
474  sampleCount mSampleCnt;
475 
476  // type of the tracks on mOutputTracks
478 
479  // Used only by the base Effect class
480  //
481  private:
482  void CommonInit();
483  void CountWaveTracks();
484 
485  // Driver for client effects
486  bool ProcessTrack(int count,
487  ChannelNames map,
488  WaveTrack *left,
489  WaveTrack *right,
490  sampleCount leftStart,
491  sampleCount rightStart,
492  sampleCount len,
493  FloatBuffers &inBuffer,
494  FloatBuffers &outBuffer,
495  ArrayOf< float * > &inBufPos,
496  ArrayOf< float *> &outBufPos);
497 
498  //
499  // private data
500  //
501  // Used only by the base Effect class
502  //
503 private:
504  TrackList *mTracks; // the complete list of all tracks
505 
506  bool mIsBatch;
510 
512  double mDuration;
513  wxString mDurationFormat;
514 
516 
517  bool mUIDebug;
518 
519  std::vector<Track*> mIMap;
520  std::vector<Track*> mOMap;
521 
522  int mNumTracks; //v This is really mNumWaveTracks, per CountWaveTracks() and GetNumWaveTracks().
524 
525  // For client driver
526  EffectClientInterface *mClient;
527  size_t mNumAudioIn;
528  size_t mNumAudioOut;
529 
530  size_t mBufferSize;
531  size_t mBlockSize;
532  unsigned mNumChannels;
533 
534  wxArrayInt mGroupProcessor;
536 
537  wxCriticalSection mRealtimeSuspendLock;
539 
540  const static wxString kUserPresetIdent;
541  const static wxString kFactoryPresetIdent;
542  const static wxString kCurrentSettingsIdent;
543  const static wxString kFactoryDefaultsIdent;
544 
545  friend class EffectManager;// so it can call PromptUser in support of batch commands.
546  friend class EffectRack;
547  friend class EffectUIHost;
548  friend class EffectPresetsDialog;
549 };
550 
551 
552 // FIXME:
553 // FIXME: Remove this once all effects are using the NEW dialog
554 // FIXME:
555 
556 #define ID_EFFECT_PREVIEW ePreviewID
557 
558 // Base dialog for regular effect
559 class AUDACITY_DLL_API EffectDialog /* not final */ : public wxDialogWrapper
560 {
561 public:
562  // constructors and destructors
563  EffectDialog(wxWindow * parent,
564  const wxString & title,
565  int type = 0,
566  int flags = wxDEFAULT_DIALOG_STYLE,
567  int additionalButtons = 0);
568 
569  void Init();
570 
571  bool TransferDataToWindow() override;
572  bool TransferDataFromWindow() override;
573  bool Validate() override;
574 
575  // NEW virtuals:
576  virtual void PopulateOrExchange(ShuttleGui & S);
577  virtual void OnPreview(wxCommandEvent & evt);
578  virtual void OnOk(wxCommandEvent & evt);
579 
580 private:
581  int mType;
583 
584  DECLARE_EVENT_TABLE()
585  wxDECLARE_NO_COPY_CLASS(EffectDialog);
586 };
587 
588 //
589 class EffectUIHost final : public wxDialogWrapper,
590  public EffectUIHostInterface
591 {
592 public:
593  // constructors and destructors
594  EffectUIHost(wxWindow *parent,
595  Effect *effect,
596  EffectUIClientInterface *client);
597  virtual ~EffectUIHost();
598 
599  bool TransferDataToWindow() override;
600  bool TransferDataFromWindow() override;
601 
602  int ShowModal() override;
603 
604  bool Initialize();
605 
606 private:
607  void OnInitDialog(wxInitDialogEvent & evt);
608  void OnErase(wxEraseEvent & evt);
609  void OnPaint(wxPaintEvent & evt);
610  void OnClose(wxCloseEvent & evt);
611  void OnApply(wxCommandEvent & evt);
612  void DoCancel();
613  void OnCancel(wxCommandEvent & evt);
614  void OnHelp(wxCommandEvent & evt);
615  void OnDebug(wxCommandEvent & evt);
616  void OnMenu(wxCommandEvent & evt);
617  void OnEnable(wxCommandEvent & evt);
618  void OnPlay(wxCommandEvent & evt);
619  void OnRewind(wxCommandEvent & evt);
620  void OnFFwd(wxCommandEvent & evt);
621  void OnPlayback(wxCommandEvent & evt);
622  void OnCapture(wxCommandEvent & evt);
623  void OnUserPreset(wxCommandEvent & evt);
624  void OnFactoryPreset(wxCommandEvent & evt);
625  void OnDeletePreset(wxCommandEvent & evt);
626  void OnSaveAs(wxCommandEvent & evt);
627  void OnImport(wxCommandEvent & evt);
628  void OnExport(wxCommandEvent & evt);
629  void OnOptions(wxCommandEvent & evt);
630  void OnDefaults(wxCommandEvent & evt);
631 
632  void UpdateControls();
633  wxBitmap CreateBitmap(const char *xpm[], bool up, bool pusher);
634  void LoadUserPresets();
635 
636  void InitializeRealtime();
637  void CleanupRealtime();
638  void Resume();
639 
640 private:
642  wxWindow *mParent;
644  EffectUIClientInterface *mClient;
645 
646  wxArrayString mUserPresets;
649  bool mIsGUI;
650  bool mIsBatch;
651 
652  wxButton *mApplyBtn;
653  wxButton *mCloseBtn;
654  wxButton *mMenuBtn;
655  wxButton *mPlayBtn;
656  wxButton *mRewindBtn;
657  wxButton *mFFwdBtn;
658  wxCheckBox *mEnableCb;
659 
660  wxButton *mEnableToggleBtn;
661  wxButton *mPlayToggleBtn;
662 
663  wxBitmap mPlayBM;
664  wxBitmap mPlayDisabledBM;
665  wxBitmap mStopBM;
666  wxBitmap mStopDisabledBM;
667 
668  bool mEnabled;
669 
671  bool mPlaying;
673 
675  double mPlayPos;
676 
677  bool mDismissed{};
678  bool mNeedsResume{};
679 
680  DECLARE_EVENT_TABLE()
681 };
682 
684 {
685 public:
686  EffectPresetsDialog(wxWindow *parent, Effect *effect);
687  virtual ~EffectPresetsDialog();
688 
689  wxString GetSelected() const;
690  void SetSelected(const wxString & parms);
691 
692 private:
693  void SetPrefix(const wxString & type, const wxString & prefix);
694  void UpdateUI();
695 
696  void OnType(wxCommandEvent & evt);
697  void OnOk(wxCommandEvent & evt);
698  void OnCancel(wxCommandEvent & evt);
699 
700 private:
701  wxChoice *mType;
702  wxListBox *mPresets;
703 
704  wxArrayString mFactoryPresets;
705  wxArrayString mUserPresets;
706  wxString mSelection;
707 
708  DECLARE_EVENT_TABLE()
709 };
710 
711 // Utility functions
712 
713 inline float TrapFloat(float x, float min, float max)
714 {
715  if (x <= min)
716  return min;
717 
718  if (x >= max)
719  return max;
720 
721  return x;
722 }
723 
724 inline double TrapDouble(double x, double min, double max)
725 {
726  if (x <= min)
727  return min;
728 
729  if (x >= max)
730  return max;
731 
732  return x;
733 }
734 
735 inline long TrapLong(long x, long min, long max)
736 {
737  if (x <= min)
738  return min;
739 
740  if (x >= max)
741  return max;
742 
743  return x;
744 }
745 
746 // Helper macros for defining, reading and verifying effect parameters
747 
748 #define Param(name, type, key, def, min, max, scale) \
749  static const wxChar * KEY_ ## name = (key); \
750  static const type DEF_ ## name = (def); \
751  static const type MIN_ ## name = (min); \
752  static const type MAX_ ## name = (max); \
753  static const type SCL_ ## name = (scale);
754 
755 #define PBasic(name, type, key, def) \
756  static const wxChar * KEY_ ## name = (key); \
757  static const type DEF_ ## name = (def);
758 
759 #define PRange(name, type, key, def, min, max) \
760  PBasic(name, type, key, def); \
761  static const type MIN_ ## name = (min); \
762  static const type MAX_ ## name = (max);
763 
764 #define PScale(name, type, key, def, min, max, scale) \
765  PRange(name, type, key, def, min, max); \
766  static const type SCL_ ## name = (scale);
767 
768 #define ReadParam(type, name) \
769  type name; \
770  if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name, MIN_ ## name, MAX_ ## name)) \
771  return false;
772 
773 #define ReadBasic(type, name) \
774  type name; \
775  wxUnusedVar(MIN_ ##name); \
776  wxUnusedVar(MAX_ ##name); \
777  wxUnusedVar(SCL_ ##name); \
778  if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name)) \
779  return false;
780 
781 #define ReadAndVerifyEnum(name, list) \
782  int name; \
783  if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name, list)) \
784  return false;
785 
786 #define ReadAndVerifyInt(name) ReadParam(int, name)
787 #define ReadAndVerifyDouble(name) ReadParam(double, name)
788 #define ReadAndVerifyFloat(name) ReadParam(float, name)
789 #define ReadAndVerifyBool(name) ReadBasic(bool, name)
790 #define ReadAndVerifyString(name) ReadBasic(wxString, name)
791 
792 #endif
wxArrayInt mGroupProcessor
Definition: Effect.h:534
void OnExport(const wxString &Format)
wxArrayString mUserPresets
Definition: Effect.h:646
double mT1
Definition: Effect.h:460
A list of TrackListNode items.
Definition: Track.h:532
Definition: Effect.h:683
friend Effect
Definition: Effect.h:376
#define PROHIBITED
Definition: Audacity.h:248
int mAdditionalButtons
Definition: Effect.h:582
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:369
ProgressDialog Class.
Definition: ProgressDialog.h:56
ProgressDialog * mProgress
Definition: Effect.h:452
bool IsPreviewing()
Definition: Effect.h:361
TrackList * mTracks
Definition: Effect.h:504
int mPass
Definition: Effect.h:467
wxButton * mPlayToggleBtn
Definition: Effect.h:661
wxButton * mCloseBtn
Definition: Effect.h:653
wxString PluginID
Definition: CommandFunctors.h:16
double mPlayPos
Definition: Effect.h:675
int mOutputTracksType
Definition: Effect.h:477
EffectUIClientInterface * mClient
Definition: Effect.h:644
bool mPreviewFullSelection
Definition: Effect.h:509
wxBitmap mPlayDisabledBM
Definition: Effect.h:664
bool mIsPreview
Definition: Effect.h:515
bool mPlaying
Definition: Effect.h:671
EffectClientInterface * mClient
Definition: Effect.h:526
wxWindow * mParent
Definition: Effect.h:642
wxButton * mRewindBtn
Definition: Effect.h:656
void SetPresetParameters(const wxArrayString *Names, const wxArrayString *Values)
Definition: Effect.h:239
int mType
Definition: Effect.h:581
SelectedRegion mRegion
Definition: Effect.h:674
wxString mDurationFormat
Definition: Effect.h:513
Base class for many of the effects in Audacity.
Definition: Effect.h:62
wxListBox * mPresets
Definition: Effect.h:702
Definition: Effect.h:405
wxButton * mApplyBtn
Definition: Effect.h:652
New (Jun-2006) base class for effects dialogs. Likely to get greater use in future.
Definition: Effect.h:559
AudacityProject * mProject
Definition: Effect.h:641
bool mSupportsRealtime
Definition: Effect.h:648
Definition: wxPanelWrapper.h:19
size_t mBufferSize
Definition: Effect.h:530
double mSampleRate
Definition: Effect.h:455
bool mIsSelection
Definition: Effect.h:511
wxArrayString mPresetNames
Definition: Effect.h:465
TrackList * inputTracks() const
Definition: Effect.h:457
size_t mNumAudioIn
Definition: Effect.h:527
wxCriticalSection mRealtimeSuspendLock
Definition: Effect.h:537
Used to create a WaveTrack, or a LabelTrack.. Implementation of the functions of this class are dispe...
Definition: Track.h:676
double mF0
Definition: Effect.h:462
bool mIsBatch
Definition: Effect.h:650
size_t mNumAudioOut
Definition: Effect.h:528
wxBitmap mStopBM
Definition: Effect.h:665
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:114
wxArrayString mFactoryPresets
Definition: Effect.h:704
Definition: Effect.h:589
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:161
std::vector< Track * > mOMap
Definition: Effect.h:520
Defines a selected portion of a project.
Definition: SelectedRegion.h:37
wxButton * mMenuBtn
Definition: Effect.h:654
friend Effect
Definition: Effect.h:406
static const wxString kUserPresetIdent
Definition: Effect.h:540
size_t mBlockSize
Definition: Effect.h:531
int mNumTracks
Definition: Effect.h:522
A Track that contains audio waveform data.
Definition: WaveTrack.h:76
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:85
wxChoice * mType
Definition: Effect.h:701
bool mIsLinearEffect
Definition: Effect.h:507
wxString mSelection
Definition: Effect.h:706
int mRealtimeSuspendCount
Definition: Effect.h:538
std::vector< Track * > mIMap
Definition: Effect.h:519
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:45
bool mCapturing
Definition: Effect.h:672
int min(int a, int b)
Definition: CompareAudioCommand.cpp:80
void OnImport()
bool mPreviewWithNotSelected
Definition: Effect.h:508
Definition: Effect.h:375
void OnSaveAs()
long TrapLong(long x, long min, long max)
Definition: Effect.h:735
wxWindow * mUIParent
Definition: Effect.h:471
double TrapDouble(double x, double min, double max)
Definition: Effect.h:724
void OnClose()
double mProjectRate
Definition: Effect.h:453
unsigned mNumChannels
Definition: Effect.h:532
TrackFactory * mFactory
Definition: Effect.h:456
wxDialog * mUIDialog
Definition: Effect.h:470
bool mUIDebug
Definition: Effect.h:517
int mCurrentProcessor
Definition: Effect.h:535
bool mInitialized
Definition: Effect.h:647
const wxChar * name
Definition: Distortion.cpp:94
wxButton * mFFwdBtn
Definition: Effect.h:657
int GetNumWaveTracks()
Definition: Effect.h:343
wxButton * mEnableToggleBtn
Definition: Effect.h:660
bool mDisableTransport
Definition: Effect.h:670
wxArrayString mUserPresets
Definition: Effect.h:705
Definition: MemoryX.h:439
float TrapFloat(float x, float min, float max)
Definition: Effect.h:713
static const wxString kFactoryPresetIdent
Definition: Effect.h:541
int GetNumWaveGroups()
Definition: Effect.h:345
wxButton * mPlayBtn
Definition: Effect.h:655
bool mIsGUI
Definition: Effect.h:649
static const wxString kCurrentSettingsIdent
Definition: Effect.h:542
wxBitmap mPlayBM
Definition: Effect.h:663
double mDuration
Definition: Effect.h:512
sampleCount mSampleCnt
Definition: Effect.h:474
wxArrayString mPresetValues
Definition: Effect.h:466
double mF1
Definition: Effect.h:463
bool mIsBatch
Definition: Effect.h:506
Effect * mEffect
Definition: Effect.h:643
wxBitmap mStopDisabledBM
Definition: Effect.h:666
bool mEnabled
Definition: Effect.h:668
int mUIResultID
Definition: Effect.h:472
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:458
virtual bool CheckWhetherSkipEffect()
Definition: Effect.h:297
wxCheckBox * mEnableCb
Definition: Effect.h:658
double mT0
Definition: Effect.h:459
int mNumGroups
Definition: Effect.h:523
static const wxString kFactoryDefaultsIdent
Definition: Effect.h:543