audacia/src/effects/Effect.h

637 lines
22 KiB
C
Raw Normal View History

/**********************************************************************
Audacity: A Digital Audio Editor
Effect.h
Dominic Mazzoni
Vaughan Johnson
**********************************************************************/
#ifndef __AUDACITY_EFFECT__
#define __AUDACITY_EFFECT__
#include <functional>
#include <set>
#include <wx/defs.h>
class wxButton;
class wxCheckBox;
class wxChoice;
class wxListBox;
class wxWindow;
#include "audacity/ConfigInterface.h"
#include "audacity/EffectInterface.h"
Resolves reported bugs and (most) recommendations All: Export/Import now disabled if the Effect (family) doesn't support it Options disabled if the Effect (family) doesn't support it Standarized on "Latency compensation" instead of "Buffer delay compensation" Correct loading/saving of factory default settings Fixed "Mannage" to be "Manage" Removed conditional code since we're keeping the transport buttons Play bases state on actual playback status Play no longer monkeys with selection Play will now start from where it left off IF: The user stops the playback via the Effect Stop button If the user wants to restart from the beginning of the selection then the user can click Rewind while stopped. Rewind will not go past start of selection (sorry Steve ;-)) If Rewind is clicked while not playing, playback will next start at beginning of selection. Fast Forward will stop at end of selection However, if FFwd is clicked while not playing, it will put playback at the end of selection and the next time the user clicks the Effect play button, playback will continue from the end of selection to the end of track. Deleting a preset now prompts user to confirm Button faces should now look a little better Bypass (should we rename that???) button now grays when disabled Audio Units: Corrected all user visible "AudioUnit" strings to be "Audio Unit" Removed unneeded "Buffer Size" in settings dialog Only uses latency if user said it was okay Ladspa: Added settings dialog to allow control of latency usage Removed unused "user selectable" buffer size Only use latency if user wants it Refresh controls when presets are loaded VST: Removed unused "Rescan at startup" setting Propogate parameter loads to slave effects
2014-12-04 06:10:27 +00:00
#include "../SelectedRegion.h"
#include "../Track.h"
#include "../widgets/wxPanelWrapper.h" // to inherit
2018-11-12 00:47:44 +00:00
class wxArrayString;
class ShuttleGui;
Automation: AudacityCommand This is a squash of 50 commits. This merges the capabilities of BatchCommands and Effects using a new AudacityCommand class. AudacityCommand provides one function to specify the parameters, and then we leverage that one function in automation, whether by chains, mod-script-pipe or (future) Nyquist. - Now have AudacityCommand which is using the same mechanism as Effect - Has configurable parameters - Has data-entry GUI (built using shuttle GUI) - Registers with PluginManager. - Menu commands now provided in chains, and to python batch. - Tested with Zoom Toggle. - ShuttleParams now can set, get, set defaults, validate and specify the parameters. - Bugfix: Don't overwrite values with defaults first time out. - Add DefineParams function for all built-in effects. - Extend CommandContext to carry output channels for results. We abuse EffectsManager. It handles both Effects and AudacityCommands now. In time an Effect should become a special case of AudacityCommand and we'll split and rename the EffectManager class. - Don't use 'default' as a parameter name. - Massive renaming for CommandDefinitionInterface - EffectIdentInterface becomes EffectDefinitionInterface - EffectAutomationParameters becomes CommandAutomationParameters - PluginType is now a bit field. This way we can search for related types at the same time. - Most old batch commands made into AudacityCommands. The ones that weren't are for a reason. They are used by mod-script-pipe to carry commands and responses across from a non-GUI thread to the GUI thread. - Major tidy up of ScreenshotCommand - Reworking of SelectCommand - GetPreferenceCommand and SetPreferenceCommand - GetTrackInfo and SetTrackInfo - GetInfoCommand - Help, Open, Save, Import and Export commands. - Removed obsolete commands ExecMenu, GetProjectInfo and SetProjectInfo which are now better handled by other commands. - JSONify "GetInfo: Commands" output, i.e. commas in the right places. - General work on better Doxygen. - Lyrics -> LyricsPanel - Meter -> MeterPanel - Updated Linux makefile. - Scripting commands added into Extra menu. - Distinct names for previously duplicated find-clipping parameters. - Fixed longstanding error with erroneous status field number which previously caused an ASSERT in debug. - Sensible formatting of numbers in Chains, 0.1 not 0.1000000000137
2018-01-14 18:51:41 +00:00
class AudacityCommand;
2015-06-09 19:00:54 +00:00
#define BUILTIN_EFFECT_PREFIX wxT("Built-in Effect: ")
2015-07-03 04:20:21 +00:00
class AudacityProject;
class LabelTrack;
class NotifyingSelectedRegion;
class ProgressDialog;
class SelectedRegion;
class EffectUIHost;
2015-07-03 04:20:21 +00:00
class Track;
class TrackList;
class WaveTrackFactory;
2015-07-03 04:20:21 +00:00
class WaveTrack;
/* i18n-hint: "Nyquist" is an embedded interpreted programming language in
Audacity, named in honor of the Swedish-American Harry Nyquist (or Nyqvist).
In the translations of this and other strings, you may transliterate the
name into another alphabet. */
#define NYQUISTEFFECTS_FAMILY ( EffectFamilySymbol{ XO("Nyquist") } )
#define NYQUIST_WORKER_ID wxT("Nyquist Worker")
// TODO: Apr-06-2015
// TODO: Much more cleanup of old methods and variables is needed, but
// TODO: can't be done until after all effects are using the NEW API.
class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler,
public EffectClientInterface,
public EffectUIClientInterface,
public EffectHostInterface
{
2014-06-03 20:30:19 +00:00
//
// public methods
//
// Used by the outside program to determine properties of an effect and
// apply the effect to one or more tracks.
2014-06-03 20:30:19 +00:00
//
public:
// The constructor is called once by each subclass at the beginning of the program.
// Avoid allocating memory or doing time-consuming processing here.
Effect();
virtual ~Effect();
// Type of a registered function that, if it returns true,
// causes ShowInterface to return early without making any dialog
using VetoDialogHook = bool (*) ( wxDialog* );
static VetoDialogHook SetVetoDialogHook( VetoDialogHook hook );
// ComponentInterface implementation
PluginPath GetPath() override;
ComponentInterfaceSymbol GetSymbol() override;
VendorSymbol GetVendor() override;
wxString GetVersion() override;
TranslatableString GetDescription() override;
Automation: AudacityCommand This is a squash of 50 commits. This merges the capabilities of BatchCommands and Effects using a new AudacityCommand class. AudacityCommand provides one function to specify the parameters, and then we leverage that one function in automation, whether by chains, mod-script-pipe or (future) Nyquist. - Now have AudacityCommand which is using the same mechanism as Effect - Has configurable parameters - Has data-entry GUI (built using shuttle GUI) - Registers with PluginManager. - Menu commands now provided in chains, and to python batch. - Tested with Zoom Toggle. - ShuttleParams now can set, get, set defaults, validate and specify the parameters. - Bugfix: Don't overwrite values with defaults first time out. - Add DefineParams function for all built-in effects. - Extend CommandContext to carry output channels for results. We abuse EffectsManager. It handles both Effects and AudacityCommands now. In time an Effect should become a special case of AudacityCommand and we'll split and rename the EffectManager class. - Don't use 'default' as a parameter name. - Massive renaming for CommandDefinitionInterface - EffectIdentInterface becomes EffectDefinitionInterface - EffectAutomationParameters becomes CommandAutomationParameters - PluginType is now a bit field. This way we can search for related types at the same time. - Most old batch commands made into AudacityCommands. The ones that weren't are for a reason. They are used by mod-script-pipe to carry commands and responses across from a non-GUI thread to the GUI thread. - Major tidy up of ScreenshotCommand - Reworking of SelectCommand - GetPreferenceCommand and SetPreferenceCommand - GetTrackInfo and SetTrackInfo - GetInfoCommand - Help, Open, Save, Import and Export commands. - Removed obsolete commands ExecMenu, GetProjectInfo and SetProjectInfo which are now better handled by other commands. - JSONify "GetInfo: Commands" output, i.e. commas in the right places. - General work on better Doxygen. - Lyrics -> LyricsPanel - Meter -> MeterPanel - Updated Linux makefile. - Scripting commands added into Extra menu. - Distinct names for previously duplicated find-clipping parameters. - Fixed longstanding error with erroneous status field number which previously caused an ASSERT in debug. - Sensible formatting of numbers in Chains, 0.1 not 0.1000000000137
2018-01-14 18:51:41 +00:00
// EffectDefinitionInterface implementation
EffectType GetType() override;
EffectFamilySymbol GetFamily() override;
bool IsInteractive() override;
bool IsDefault() override;
bool IsLegacy() override;
bool SupportsRealtime() override;
bool SupportsAutomation() override;
// EffectClientInterface implementation
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;
size_t GetBlockSize() const 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,
const EffectDialogFactory &factory, bool forceModal = false) override;
2018-02-21 14:24:25 +00:00
bool GetAutomationParameters(CommandParameters & parms) override;
bool SetAutomationParameters(CommandParameters & parms) override;
bool LoadUserPreset(const RegistryPath & name) override;
bool SaveUserPreset(const RegistryPath & name) override;
RegistryPaths GetFactoryPresets() override;
bool LoadFactoryPreset(int id) override;
bool LoadFactoryDefaults() override;
// EffectUIClientInterface implementation
void SetHostUI(EffectUIHostInterface *host) override;
bool PopulateUI(ShuttleGui &S) final;
bool IsGraphicalUI() override;
bool ValidateUI() override;
bool HideUI() override;
bool CloseUI() override;
bool CanExportPresets() override;
void ExportPresets() override;
void ImportPresets() override;
static CommandID GetSquashedName(wxString name);
bool HasOptions() override;
void ShowOptions() override;
// EffectHostInterface implementation
double GetDefaultDuration() override;
double GetDuration() override;
NumericFormatSymbol GetDurationFormat() override;
virtual NumericFormatSymbol GetSelectionFormat() /* not override? */; // time format in Selection toolbar
void SetDuration(double duration) override;
RegistryPath GetUserPresetsGroup(const RegistryPath & name) override;
RegistryPath GetCurrentSettingsGroup() override;
RegistryPath GetFactoryDefaultsGroup() override;
virtual wxString GetSavedStateGroup() /* not override? */;
// ConfigClientInterface implementation
bool HasSharedConfigGroup(const RegistryPath & group) override;
bool GetSharedConfigSubgroups(const RegistryPath & group, RegistryPaths &subgroups) override;
bool GetSharedConfig(const RegistryPath & group, const RegistryPath & key, wxString & value, const wxString & defval = {}) override;
bool GetSharedConfig(const RegistryPath & group, const RegistryPath & key, int & value, int defval = 0) override;
bool GetSharedConfig(const RegistryPath & group, const RegistryPath & key, bool & value, bool defval = false) override;
bool GetSharedConfig(const RegistryPath & group, const RegistryPath & key, float & value, float defval = 0.0) override;
bool GetSharedConfig(const RegistryPath & group, const RegistryPath & key, double & value, double defval = 0.0) override;
bool SetSharedConfig(const RegistryPath & group, const RegistryPath & key, const wxString & value) override;
bool SetSharedConfig(const RegistryPath & group, const RegistryPath & key, const int & value) override;
bool SetSharedConfig(const RegistryPath & group, const RegistryPath & key, const bool & value) override;
bool SetSharedConfig(const RegistryPath & group, const RegistryPath & key, const float & value) override;
bool SetSharedConfig(const RegistryPath & group, const RegistryPath & key, const double & value) override;
bool RemoveSharedConfigSubgroup(const RegistryPath & group) override;
bool RemoveSharedConfig(const RegistryPath & group, const RegistryPath & key) override;
bool HasPrivateConfigGroup(const RegistryPath & group) override;
bool GetPrivateConfigSubgroups(const RegistryPath & group, RegistryPaths &paths) override;
bool GetPrivateConfig(const RegistryPath & group, const RegistryPath & key, wxString & value, const wxString & defval = {}) override;
bool GetPrivateConfig(const RegistryPath & group, const RegistryPath & key, int & value, int defval = 0) override;
bool GetPrivateConfig(const RegistryPath & group, const RegistryPath & key, bool & value, bool defval = false) override;
bool GetPrivateConfig(const RegistryPath & group, const RegistryPath & key, float & value, float defval = 0.0) override;
bool GetPrivateConfig(const RegistryPath & group, const RegistryPath & key, double & value, double defval = 0.0) override;
bool SetPrivateConfig(const RegistryPath & group, const RegistryPath & key, const wxString & value) override;
bool SetPrivateConfig(const RegistryPath & group, const RegistryPath & key, const int & value) override;
bool SetPrivateConfig(const RegistryPath & group, const RegistryPath & key, const bool & value) override;
bool SetPrivateConfig(const RegistryPath & group, const RegistryPath & key, const float & value) override;
bool SetPrivateConfig(const RegistryPath & group, const RegistryPath & key, const double & value) override;
bool RemovePrivateConfigSubgroup(const RegistryPath & group) override;
bool RemovePrivateConfig(const RegistryPath & group, const RegistryPath & key) override;
// Effect implementation
// NEW virtuals
virtual PluginID GetID();
virtual bool Startup(EffectClientInterface *client);
virtual bool Startup();
virtual bool GetAutomationParameters(wxString & parms);
virtual bool SetAutomationParameters(const wxString & parms);
virtual RegistryPaths GetUserPresets();
virtual bool HasCurrentSettings();
virtual bool HasFactoryDefaults();
2017-05-19 17:20:05 +00:00
// Name of page in the Audacity alpha manual
virtual ManualPageID ManualPage();
2017-05-19 17:20:05 +00:00
// Fully qualified local help file name
virtual FilePath HelpPage();
2017-05-15 21:00:33 +00:00
virtual void SetUIFlags(unsigned flags);
virtual unsigned TestUIFlags(unsigned mask);
virtual bool IsBatchProcessing();
virtual void SetBatchProcessing(bool start);
/* not virtual */ void SetPresetParameters( const wxArrayString * Names, const wxArrayString * Values ) {
if( Names ) mPresetNames = *Names;
if( Values ) mPresetValues = *Values;
}
// Returns true on success. Will only operate on tracks that
// have the "selected" flag set to true, which is consistent with
// Audacity's standard UI.
// Create a user interface only if the supplied function is not null.
/* not virtual */ bool DoEffect( double projectRate, TrackList *list,
WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion,
// Prompt the user for input only if these arguments are both not null.
wxWindow *pParent = nullptr,
const EffectDialogFactory &dialogFactory = {} );
Round 3 of realtime changes. This gets meter type VST effects working again by extending the The master now maintains his own internal buffers and sums (mixes) all playing tracks into those buffers. The buffers are then fed into the VST effect that is presented to the user. This allows the effect to provide feedback to the user if it support it. Such effects may display meters or clipping indicators. Several issues with treading have also been corrected (hopefully ;-)). These showed up mostly on Linux, but could have happened on the others as well. The realtime support is no longer limited to 2 channels per logical track. Once support for more channels is added, this should be ready for it. The rack dialog can now be toggled via the edit toolbar button. It doesn't stay pressed because the closing of the dialog would have to be communicated back to the toolbar. As the rack is updated with new or removed effects or active state changed, all effects in the active list were shutdown and all effects in the updated list were initialized. This now shuts down only the effects no longer in the list and initializes only new ones. The rack now uses wxBitmapButton instead of Audacity's AButton. The AButton has a timing issue that prevents it from being deleted while processing the click event. I looked into it, but gave up and switched to the wxBitmapButton. Unfortunately, there's a problem with the wxBitmapButton as well...at least on my setup here. Either the bitmaps are being scaled or antialiased. Will have to get feedback on this. I finally figured out why some VSTs didn't seem to do anything in realtime, at least in my case anyway. I've installed a lot of demo VSTs and while they work in "batch/offline" mode, some of them will not work in realtime since vendors tend to remove automation as one of the demo limitations. More changes coming shortly...
2014-11-03 06:48:54 +00:00
bool Delegate( Effect &delegate,
wxWindow &parent, const EffectDialogFactory &factory );
2016-12-29 15:36:37 +00:00
virtual bool IsHidden();
// Nonvirtual
// Display a message box, using effect's (translated) name as the prefix
// for the title.
enum : long { DefaultMessageBoxStyle = wxOK | wxCENTRE };
int MessageBox(const TranslatableString& message,
long style = DefaultMessageBoxStyle,
const TranslatableString& titleStr = {});
static void IncEffectCounter(){ nEffectsDone++;};
//
// protected virtual methods
//
// Each subclass of Effect overrides one or more of these methods to
// do its processing.
//
protected:
// Called once each time an effect is called. Perform any initialization;
// make sure that the effect can be performed on the selected tracks and
// return false otherwise
virtual bool Init();
// Check whether effect should be skipped
// Typically this is only useful in automation, for example
// detecting that zero noise reduction is to be done,
2014-06-03 20:30:19 +00:00
// or that normalisation is being done without Dc bias shift
// or amplitude modification
virtual bool CheckWhetherSkipEffect() { return false; }
2014-06-03 20:30:19 +00:00
// Actually do the effect here.
virtual bool Process();
virtual bool ProcessPass();
virtual bool InitPass1();
virtual bool InitPass2();
virtual int GetPass();
// clean up any temporary memory, needed only per invocation of the
// effect, after either successful or failed or exception-aborted processing.
// Invoked inside a "finally" block so it must be no-throw.
virtual void End();
// Most effects just use the previewLength, but time-stretching/compressing
// effects need to use a different input length, so override this method.
virtual double CalcPreviewInputLength(double previewLength);
// The Effect class fully implements the Preview method for you.
// Only override it if you need to do preprocessing or cleanup.
virtual void Preview(bool dryOnly);
virtual void PopulateOrExchange(ShuttleGui & S);
2017-10-01 17:28:04 +00:00
virtual bool TransferDataToWindow() /* not override */;
virtual bool TransferDataFromWindow() /* not override */;
virtual bool EnableApply(bool enable = true);
virtual bool EnablePreview(bool enable = true);
2015-04-22 20:55:58 +00:00
virtual void EnableDebug(bool enable = true);
// No more virtuals!
// The Progress methods all return true if the user has cancelled;
// you should exit immediately if this happens (cleaning up memory
// is okay, but don't try to undo).
2014-06-03 20:30:19 +00:00
// Pass a fraction between 0.0 and 1.0
2019-12-08 03:37:02 +00:00
bool TotalProgress(double frac, const TranslatableString & = {});
2014-06-03 20:30:19 +00:00
// Pass a fraction between 0.0 and 1.0, for the current track
// (when doing one track at a time)
2019-12-08 03:37:02 +00:00
bool TrackProgress(int whichTrack, double frac, const TranslatableString & = {});
2014-06-03 20:30:19 +00:00
// Pass a fraction between 0.0 and 1.0, for the current track group
// (when doing stereo groups at a time)
2019-12-08 03:37:02 +00:00
bool TrackGroupProgress(int whichGroup, double frac, const TranslatableString & = {});
int GetNumWaveTracks() { return mNumTracks; }
int GetNumWaveGroups() { return mNumGroups; }
// Calculates the start time and length in samples for one or two channels
void GetBounds(
const WaveTrack &track, const WaveTrack *pRight,
sampleCount *start, sampleCount *len);
// Previewing linear effect can be optimised by pre-mixing. However this
// should not be used for non-linear effects such as dynamic processors
// To allow pre-mixing before Preview, set linearEffectFlag to true.
void SetLinearEffectFlag(bool linearEffectFlag);
// Most effects only need to preview a short selection. However some
// (such as fade effects) need to know the full selection length.
void SetPreviewFullSelectionFlag(bool previewDurationFlag);
// Use this if the effect needs to know if it is previewing
bool IsPreviewing() { return mIsPreview; }
// Most effects only require selected tracks to be copied for Preview.
// If IncludeNotSelectedPreviewTracks(true), then non-linear effects have
// preview copies of all wave tracks.
void IncludeNotSelectedPreviewTracks(bool includeNotSelected);
// Use this method to copy the input tracks to mOutputTracks, if
// doing the processing on them, and replacing the originals only on success (and not cancel).
// If not all sync-locked selected, then only selected wave tracks.
void CopyInputTracks(bool allSyncLockSelected = false);
// A global counter of all the successful Effect invocations.
static int nEffectsDone;
// For the use of analyzers, which don't need to make output wave tracks,
// but may need to add label tracks.
class AUDACITY_DLL_API AddedAnalysisTrack {
friend Effect;
AddedAnalysisTrack(Effect *pEffect, const wxString &name);
AddedAnalysisTrack(const AddedAnalysisTrack&) PROHIBITED;
public:
AddedAnalysisTrack() {}
// So you can have a vector of them
AddedAnalysisTrack(AddedAnalysisTrack &&that);
LabelTrack *get() const { return mpTrack; }
// Call this to indicate successful completion of the analyzer.
void Commit();
// Destructor undoes the addition of the analysis track if not committed.
~AddedAnalysisTrack();
private:
Effect *mpEffect{};
LabelTrack *mpTrack{};
};
// Set name to given value if that is not empty, else use default name
std::shared_ptr<AddedAnalysisTrack> AddAnalysisTrack(const wxString &name = wxString());
// For the use of analyzers, which don't need to make output wave tracks,
// but may need to modify label tracks.
class AUDACITY_DLL_API ModifiedAnalysisTrack {
friend Effect;
ModifiedAnalysisTrack
(Effect *pEffect, const LabelTrack *pOrigTrack, const wxString &name);
ModifiedAnalysisTrack(const ModifiedAnalysisTrack&) PROHIBITED;
public:
ModifiedAnalysisTrack();
// So you can have a vector of them
ModifiedAnalysisTrack(ModifiedAnalysisTrack &&that);
LabelTrack *get() const { return mpTrack; }
// Call this to indicate successful completion of the analyzer.
void Commit();
// Destructor undoes the modification of the analysis track if not committed.
~ModifiedAnalysisTrack();
private:
Effect *mpEffect{};
LabelTrack *mpTrack{};
std::shared_ptr<Track> mpOrigTrack{};
};
// Set name to given value if that is not empty, else use default name
ModifiedAnalysisTrack ModifyAnalysisTrack
(const LabelTrack *pOrigTrack, const wxString &name = wxString());
2014-06-03 20:30:19 +00:00
// If bGoodResult, replace mWaveTracks tracks in mTracks with successfully processed
// mOutputTracks copies, get rid of old mWaveTracks, and set mWaveTracks to mOutputTracks.
// Else clear and DELETE mOutputTracks copies.
void ReplaceProcessedTracks(const bool bGoodResult);
// Use this to append a NEW output track.
Track *AddToOutputTracks(const std::shared_ptr<Track> &t);
//
// protected data
//
// The Effect base class will set these variables, some or all of which
// may be needed by any particular subclass of Effect.
//
protected:
ProgressDialog *mProgress; // Temporary pointer, NOT deleted in destructor.
double mProjectRate; // Sample rate of the project - NEW tracks should
// be created with this rate...
double mSampleRate;
wxWeakRef<NotifyingSelectedRegion> mpSelectedRegion{};
WaveTrackFactory *mFactory;
const TrackList *inputTracks() const { return mTracks; }
const AudacityProject *FindProject() const;
std::shared_ptr<TrackList> mOutputTracks; // used only if CopyInputTracks() is called.
double mT0;
double mT1;
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
double mF0;
double mF1;
#endif
wxArrayString mPresetNames;
wxArrayString mPresetValues;
int mPass;
// UI
wxDialog *mUIDialog;
wxWindow *mUIParent;
2015-04-22 20:55:58 +00:00
int mUIResultID;
unsigned mUIFlags;
2015-04-22 20:55:58 +00:00
sampleCount mSampleCnt;
// Used only by the base Effect class
//
private:
void CountWaveTracks();
2014-06-03 20:30:19 +00:00
// Driver for client effects
bool ProcessTrack(int count,
ChannelNames map,
WaveTrack *left,
WaveTrack *right,
sampleCount start,
sampleCount len,
FloatBuffers &inBuffer,
FloatBuffers &outBuffer,
ArrayOf< float * > &inBufPos,
ArrayOf< float *> &outBufPos);
//
// private data
//
// Used only by the base Effect class
//
private:
2016-12-29 15:36:37 +00:00
TrackList *mTracks; // the complete list of all tracks
bool mIsBatch;
bool mIsLinearEffect;
bool mPreviewWithNotSelected;
bool mPreviewFullSelection;
double mDuration;
NumericFormatSymbol mDurationFormat;
bool mIsPreview;
2015-04-22 20:55:58 +00:00
bool mUIDebug;
std::vector<Track*> mIMap;
std::vector<Track*> mOMap;
int mNumTracks; //v This is really mNumWaveTracks, per CountWaveTracks() and GetNumWaveTracks().
int mNumGroups;
// For client driver
EffectClientInterface *mClient;
size_t mNumAudioIn;
size_t mNumAudioOut;
size_t mBufferSize;
size_t mBlockSize;
unsigned mNumChannels;
2020-01-23 19:48:21 +00:00
public:
const static wxString kUserPresetIdent;
const static wxString kFactoryPresetIdent;
const static wxString kCurrentSettingsIdent;
const static wxString kFactoryDefaultsIdent;
friend class EffectUIHost;
};
// FIXME:
// FIXME: Remove this once all effects are using the NEW dialog
// FIXME:
#define ID_EFFECT_PREVIEW ePreviewID
// Utility functions
inline float TrapFloat(float x, float min, float max)
{
if (x <= min)
return min;
if (x >= max)
return max;
return x;
}
inline double TrapDouble(double x, double min, double max)
{
if (x <= min)
return min;
if (x >= max)
return max;
return x;
}
inline long TrapLong(long x, long min, long max)
{
if (x <= min)
return min;
if (x >= max)
return max;
return x;
}
// Helper macros for defining, reading and verifying effect parameters
#define Param(name, type, key, def, min, max, scale) \
static const wxChar * KEY_ ## name = (key); \
static const type DEF_ ## name = (def); \
static const type MIN_ ## name = (min); \
static const type MAX_ ## name = (max); \
static const type SCL_ ## name = (scale);
#define PBasic(name, type, key, def) \
static const wxChar * KEY_ ## name = (key); \
static const type DEF_ ## name = (def);
#define PRange(name, type, key, def, min, max) \
PBasic(name, type, key, def); \
static const type MIN_ ## name = (min); \
static const type MAX_ ## name = (max);
#define PScale(name, type, key, def, min, max, scale) \
PRange(name, type, key, def, min, max); \
static const type SCL_ ## name = (scale);
#define ReadParam(type, name) \
type name = DEF_ ## name; \
if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name, MIN_ ## name, MAX_ ## name)) \
return false;
#define ReadBasic(type, name) \
type name; \
wxUnusedVar(MIN_ ##name); \
wxUnusedVar(MAX_ ##name); \
wxUnusedVar(SCL_ ##name); \
if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name)) \
return false;
#define ReadAndVerifyEnum(name, list, listSize) \
int name; \
if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name, list, listSize)) \
return false;
#define ReadAndVerifyEnumWithObsoletes(name, list, listSize, obsoleteList, nObsolete) \
int name; \
if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name, \
list, listSize, obsoleteList, nObsolete)) \
return false;
#define ReadAndVerifyInt(name) ReadParam(int, name)
#define ReadAndVerifyDouble(name) ReadParam(double, name)
#define ReadAndVerifyFloat(name) ReadParam(float, name)
#define ReadAndVerifyBool(name) ReadBasic(bool, name)
#define ReadAndVerifyString(name) ReadBasic(wxString, name)
#endif