Audacity  3.0.3
Public Member Functions | Protected Member Functions | List of all members
Generator Class Referenceabstract

#include <Generator.h>

Inheritance diagram for Generator:
[legend]
Collaboration diagram for Generator:
[legend]

Public Member Functions

 Generator ()
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
PluginPath GetPath () override
 
ComponentInterfaceSymbol GetSymbol () override
 
VendorSymbol GetVendor () override
 
wxString GetVersion () override
 
TranslatableString GetDescription () override
 
EffectType GetType () override
 
EffectFamilySymbol GetFamily () override
 
bool IsInteractive () override
 
bool IsDefault () override
 
bool IsLegacy () override
 
bool SupportsRealtime () override
 
bool SupportsAutomation () override
 
bool SetHost (EffectHostInterface *host) override
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
int GetMidiInCount () override
 
int GetMidiOutCount () override
 
sampleCount GetLatency () override
 
size_t GetTailSize () override
 
void SetSampleRate (double rate) override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
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
 
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
 
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
 
bool HasOptions () override
 
void ShowOptions () override
 
double GetDefaultDuration () override
 
double GetDuration () override
 
NumericFormatSymbol GetDurationFormat () override
 
virtual NumericFormatSymbol GetSelectionFormat ()
 
void SetDuration (double duration) override
 
RegistryPath GetUserPresetsGroup (const RegistryPath &name) override
 
RegistryPath GetCurrentSettingsGroup () override
 
RegistryPath GetFactoryDefaultsGroup () override
 
virtual wxString GetSavedStateGroup ()
 
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
 
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 ()
 
virtual ManualPageID ManualPage ()
 
virtual FilePath HelpPage ()
 
virtual void SetUIFlags (unsigned flags)
 
virtual unsigned TestUIFlags (unsigned mask)
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
void SetPresetParameters (const wxArrayString *Names, const wxArrayString *Values)
 
bool DoEffect (double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={})
 
bool Delegate (Effect &delegate, wxWindow &parent, const EffectDialogFactory &factory)
 
virtual bool IsHidden ()
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
- Public Member Functions inherited from EffectClientInterface
virtual ~EffectClientInterface ()
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetClassification ()
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
- Public Member Functions inherited from EffectHostInterface
virtual ~EffectHostInterface ()
 
- Public Member Functions inherited from ConfigClientInterface
virtual ~ConfigClientInterface ()
 

Protected Member Functions

virtual bool GenerateTrack (WaveTrack *tmp, const WaveTrack &track, int ntrack)=0
 
bool Init () override
 
virtual void BeforeGenerate ()
 
virtual void BeforeTrack (const WaveTrack &WXUNUSED(track))
 
virtual void Success ()
 
virtual void Failure ()
 
AUDACITY_DLL_API bool Process () override
 
- Protected Member Functions inherited from Effect
virtual bool CheckWhetherSkipEffect ()
 
virtual bool ProcessPass ()
 
virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual int GetPass ()
 
virtual void End ()
 
virtual double CalcPreviewInputLength (double previewLength)
 
virtual void Preview (bool dryOnly)
 
virtual void PopulateOrExchange (ShuttleGui &S)
 
virtual bool TransferDataToWindow ()
 
virtual bool TransferDataFromWindow ()
 
virtual bool EnableApply (bool enable=true)
 
virtual bool EnablePreview (bool enable=true)
 
virtual void EnableDebug (bool enable=true)
 
bool TotalProgress (double frac, const TranslatableString &={})
 
bool TrackProgress (int whichTrack, double frac, const TranslatableString &={})
 
bool TrackGroupProgress (int whichGroup, double frac, const TranslatableString &={})
 
int GetNumWaveTracks ()
 
int GetNumWaveGroups ()
 
void GetBounds (const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing ()
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void CopyInputTracks (bool allSyncLockSelected=false)
 
std::shared_ptr< AddedAnalysisTrackAddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
TrackAddToOutputTracks (const std::shared_ptr< Track > &t)
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 

Additional Inherited Members

- Public Types inherited from Effect
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
using VetoDialogHook = bool(*)(wxDialog *)
 
- Public Types inherited from EffectClientInterface
using EffectDialogFactory = std::function< wxDialog *(wxWindow &parent, EffectHostInterface *, EffectUIClientInterface *) >
 
- Static Public Member Functions inherited from Effect
static VetoDialogHook SetVetoDialogHook (VetoDialogHook hook)
 
static CommandID GetSquashedName (wxString name)
 
static void IncEffectCounter ()
 
- Static Public Attributes inherited from Effect
static const wxString kUserPresetIdent = wxT("User Preset:")
 
static const wxString kFactoryPresetIdent = wxT("Factory Preset:")
 
static const wxString kCurrentSettingsIdent = wxT("<Current Settings>")
 
static const wxString kFactoryDefaultsIdent = wxT("<Factory Defaults>")
 
- Protected Attributes inherited from Effect
ProgressDialogmProgress
 
double mProjectRate
 
double mSampleRate
 
wxWeakRef< NotifyingSelectedRegionmpSelectedRegion {}
 
WaveTrackFactorymFactory
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0
 
double mT1
 
wxArrayString mPresetNames
 
wxArrayString mPresetValues
 
int mPass
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 
int mUIResultID
 
unsigned mUIFlags
 
sampleCount mSampleCnt
 
- Static Protected Attributes inherited from Effect
static int nEffectsDone =0
 

Detailed Description

Definition at line 24 of file Generator.h.

Constructor & Destructor Documentation

◆ Generator()

Generator::Generator ( )
inline

Definition at line 27 of file Generator.h.

27 { }

Member Function Documentation

◆ BeforeGenerate()

virtual void Generator::BeforeGenerate ( )
inlineprotectedvirtual

Definition at line 41 of file Generator.h.

41 { };

Referenced by Process().

Here is the caller graph for this function:

◆ BeforeTrack()

virtual void Generator::BeforeTrack ( const WaveTrack WXUNUSEDtrack)
inlineprotectedvirtual

Definition at line 42 of file Generator.h.

42 { };

Referenced by Process().

Here is the caller graph for this function:

◆ Failure()

virtual void Generator::Failure ( )
inlineprotectedvirtual

Definition at line 47 of file Generator.h.

47 {};

Referenced by Process().

Here is the caller graph for this function:

◆ GenerateTrack()

virtual bool Generator::GenerateTrack ( WaveTrack tmp,
const WaveTrack track,
int  ntrack 
)
protectedpure virtual

Implemented in EffectSilence, and BlockGenerator.

Referenced by Process().

Here is the caller graph for this function:

◆ Init()

bool Generator::Init ( )
inlineoverrideprotectedvirtual

Reimplemented from Effect.

Definition at line 37 of file Generator.h.

37 { return true; }

◆ Process()

bool Generator::Process ( )
overrideprotectedvirtual

Reimplemented from Effect.

Definition at line 29 of file Generator.cpp.

30 {
31  if (GetDuration() < 0.0)
32  return false;
33 
34 
35  // Set up mOutputTracks.
36  // This effect needs all for sync-lock grouping.
37  this->CopyInputTracks(true);
38 
39  // Iterate over the tracks
40  bool bGoodResult = true;
41  int ntrack = 0;
42 
43  mOutputTracks->Any().VisitWhile( bGoodResult,
44  [&](WaveTrack *track, const Track::Fallthrough &fallthrough) {
45  if (!track->GetSelected())
46  return fallthrough();
47  bool editClipCanMove = GetEditClipsCanMove();
48 
49  //if we can't move clips, and we're generating into an empty space,
50  //make sure there's room.
51  if (!editClipCanMove &&
52  track->IsEmpty(mT0, mT1+1.0/track->GetRate()) &&
53  !track->IsEmpty(mT0, mT0+GetDuration()-(mT1-mT0)-1.0/track->GetRate()))
54  {
56  XO("There is not enough room available to generate the audio"),
57  wxICON_STOP,
58  XO("Error") );
59  Failure();
60  bGoodResult = false;
61  return;
62  }
63 
64  if (GetDuration() > 0.0)
65  {
66  auto pProject = FindProject();
67  // Create a temporary track
68  auto tmp = track->EmptyCopy();
69  BeforeTrack(*track);
71 
72  // Fill it with data
73  if (!GenerateTrack(&*tmp, *track, ntrack))
74  bGoodResult = false;
75  else {
76  // Transfer the data from the temporary track to the actual one
77  tmp->Flush();
78  PasteTimeWarper warper{ mT1, mT0+GetDuration() };
79  const auto &selectedRegion =
80  ViewInfo::Get( *pProject ).selectedRegion;
81  track->ClearAndPaste(
82  selectedRegion.t0(), selectedRegion.t1(),
83  &*tmp, true, false, &warper);
84  }
85 
86  if (!bGoodResult) {
87  Failure();
88  return;
89  }
90  }
91  else
92  {
93  // If the duration is zero, there's no need to actually
94  // generate anything
95  track->Clear(mT0, mT1);
96  }
97 
98  ntrack++;
99  },
100  [&](Track *t) {
101  if (t->IsSyncLockSelected()) {
102  t->SyncLockAdjust(mT1, mT0 + GetDuration());
103  }
104  }
105  );
106 
107  if (bGoodResult) {
108  Success();
109 
110  this->ReplaceProcessedTracks(bGoodResult);
111 
112  mT1 = mT0 + GetDuration(); // Update selection.
113  }
114 
115  return bGoodResult;
116 }

References BeforeGenerate(), BeforeTrack(), WaveTrack::Clear(), WaveTrack::ClearAndPaste(), Effect::CopyInputTracks(), WaveTrack::EmptyCopy(), Failure(), Effect::FindProject(), GenerateTrack(), ViewInfo::Get(), Effect::GetDuration(), GetEditClipsCanMove(), WaveTrack::GetRate(), Track::GetSelected(), WaveTrack::IsEmpty(), Effect::MessageBox(), Effect::mOutputTracks, Effect::mT0, Effect::mT1, Effect::ReplaceProcessedTracks(), ViewInfo::selectedRegion, Success(), and XO.

Here is the call graph for this function:

◆ Success()

virtual void Generator::Success ( )
inlineprotectedvirtual

Definition at line 46 of file Generator.h.

46 { };

Referenced by Process().

Here is the caller graph for this function:

The documentation for this class was generated from the following files:
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:161
Generator::Failure
virtual void Failure()
Definition: Generator.h:47
Effect::FindProject
const AudacityProject * FindProject() const
Definition: Effect.cpp:2272
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
Effect::GetDuration
double GetDuration() override
Definition: Effect.cpp:816
Effect::MessageBox
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
Definition: Effect.cpp:2482
Effect::CopyInputTracks
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:2071
Generator::GenerateTrack
virtual bool GenerateTrack(WaveTrack *tmp, const WaveTrack &track, int ntrack)=0
Effect::mT1
double mT1
Definition: Effect.h:467
GetEditClipsCanMove
bool GetEditClipsCanMove()
Definition: TracksBehaviorsPrefs.cpp:143
XO
#define XO(s)
Definition: Internat.h:31
WaveTrack::ClearAndPaste
void ClearAndPaste(double t0, double t1, const Track *src, bool preserve=true, bool merge=true, const TimeWarper *effectWarper=NULL)
Definition: WaveTrack.cpp:847
Generator::Success
virtual void Success()
Definition: Generator.h:46
WaveTrack::EmptyCopy
Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory={}) const
Definition: WaveTrack.cpp:666
Generator::BeforeTrack
virtual void BeforeTrack(const WaveTrack &WXUNUSED(track))
Definition: Generator.h:42
ViewInfo::selectedRegion
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:196
WaveTrack::Clear
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:751
Effect::mT0
double mT0
Definition: Effect.h:466
Generator::BeforeGenerate
virtual void BeforeGenerate()
Definition: Generator.h:41
WaveTrack::IsEmpty
bool IsEmpty(double t0, double t1) const
Returns true if there are no WaveClips in the specified region.
Definition: WaveTrack.cpp:556
Effect::ReplaceProcessedTracks
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2193
Track::Fallthrough
Continuation<> Fallthrough
Type of arguments passed as optional second parameter to TypeSwitch<void>() cases.
Definition: Track.h:504
Effect::mOutputTracks
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:465
Track::GetSelected
bool GetSelected() const
Definition: Track.h:431
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
PasteTimeWarper
Unit slope but with either a jump (pasting more) or a flat interval (pasting less)
Definition: TimeWarper.h:181
WaveTrack::GetRate
double GetRate() const
Definition: WaveTrack.cpp:452