Audacity  3.2.0
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
 Type determines how it behaves. More...
 
EffectFamilySymbol GetFamily () override
 Report identifier and user-visible name of the effect protocol. More...
 
bool IsInteractive () override
 Whether the effect needs a dialog for entry of settings. More...
 
bool IsDefault () override
 Whether the effect sorts "above the line" in the menus. More...
 
bool IsLegacy () override
 
bool SupportsRealtime () override
 Whether the effect supports realtime previewing (while audio is playing). More...
 
bool SupportsAutomation () override
 Whether the effect can be used without the UI, in a macro. More...
 
bool GetAutomationParameters (CommandParameters &parms) override
 Save current settings into parms. More...
 
bool SetAutomationParameters (CommandParameters &parms) override
 Change settings to those stored in parms. More...
 
bool LoadUserPreset (const RegistryPath &name) override
 Change settings to a user-named preset. More...
 
bool SaveUserPreset (const RegistryPath &name) override
 Save current settings as a user-named preset. More...
 
RegistryPaths GetFactoryPresets () override
 Report names of factory presets. More...
 
bool LoadFactoryPreset (int id) override
 Change settings to the preset whose name is GetFactoryPresets()[id] More...
 
bool LoadFactoryDefaults () override
 Change settings back to "factory default". More...
 
bool SetHost (EffectHostInterface *host) override
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
int GetMidiInCount () override
 
int GetMidiOutCount () override
 
sampleCount GetLatency () override
 Called for destructive, non-realtime effect computation. More...
 
size_t GetTailSize () override
 
void SetSampleRate (double rate) override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
size_t GetBlockSize () const override
 
bool ProcessInitialize (sampleCount totalLen, ChannelNames chanMap=NULL) override
 Called for destructive, non-realtime effect computation. More...
 
bool ProcessFinalize () override
 Called for destructive, non-realtime effect computation. More...
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 Called for destructive, non-realtime effect computation. More...
 
bool RealtimeInitialize () override
 
bool RealtimeAddProcessor (unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize () override
 
bool RealtimeSuspend () override
 
bool RealtimeResume () noexcept override
 
bool RealtimeProcessStart () override
 
size_t RealtimeProcess (int group, float **inbuf, float **outbuf, size_t numSamples) override
 
bool RealtimeProcessEnd () noexcept override
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, bool forceModal=false) override
 
bool PopulateUI (ShuttleGui &S) final
 Adds controls to a panel that is given as the parent window of S More...
 
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
 
EffectDefinitionInterfaceGetDefinition () 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 ()
 
int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, bool forceModal=false) override
 
unsigned TestUIFlags (unsigned mask)
 
void SetPresetParameters (const wxArrayString *Names, const wxArrayString *Values)
 
virtual bool Startup (EffectUIClientInterface *client)
 
virtual bool GetAutomationParametersAsString (wxString &parms)
 
virtual bool SetAutomationParametersFromString (const wxString &parms)
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
bool DoEffect (double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={})
 
bool Delegate (Effect &delegate, wxWindow &parent, const EffectDialogFactory &factory)
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
virtual bool Startup ()
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
- Public Member Functions inherited from EffectProcessor
virtual ~EffectProcessor ()
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetClassification ()
 Determines which menu it appears in; default same as GetType(). More...
 
virtual bool EnablesDebug ()
 Whether the effect dialog should have a Debug button; default, always false. More...
 
virtual ManualPageID ManualPage ()
 Name of a page in the Audacity alpha manual, default is empty. More...
 
virtual FilePath HelpPage ()
 Fully qualified local help file name, default is empty. More...
 
virtual bool IsHiddenFromMenus ()
 Default is false. More...
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 
- Public Member Functions inherited from EffectUIHostInterface
virtual ~EffectUIHostInterface ()
 
- Public Member Functions inherited from EffectHostInterface
virtual ~EffectHostInterface ()
 

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
bool EnableApply (bool enable=true)
 
bool EnablePreview (bool enable=true)
 
virtual bool CheckWhetherSkipEffect ()
 
virtual bool ProcessPass ()
 
virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual void End ()
 
virtual double CalcPreviewInputLength (double previewLength)
 
virtual void Preview (bool dryOnly)
 
virtual void PopulateOrExchange (ShuttleGui &S)
 
virtual bool TransferDataToWindow ()
 
virtual bool TransferDataFromWindow ()
 
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 }
 
- Static Public Member Functions inherited from Effect
static void IncEffectCounter ()
 
- Static Public Member Functions inherited from EffectDefinitionInterface
static Identifier GetSquashedName (const Identifier &ident)
 A utility that strips spaces and CamelCases a name. More...
 
- 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
BasicUI::ProgressDialogmProgress = nullptr
 
double mProjectRate
 
double mSampleRate
 
WaveTrackFactorymFactory
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0
 
double mT1
 
wxArrayString mPresetNames
 
wxArrayString mPresetValues
 
int mPass
 
wxWeakRef< wxDialog > mHostUIDialog
 This smart pointer tracks the lifetime of the dialog. More...
 
wxWeakRef< wxDialog > mUIDialog
 This weak pointer may be the same as the above, or null. More...
 
wxWindow * mUIParent
 
unsigned mUIFlags { 0 }
 
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

If Process() is not overridden, it uses ProcessInitialize(), ProcessBlock(), and ProcessFinalize() methods of EffectProcessor, and also GetLatency() to determine how many leading output samples to discard and how many extra samples to produce.

Reimplemented from Effect.

Definition at line 30 of file Generator.cpp.

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

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(), SyncLock::IsSyncLockSelected(), 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:235
Generator::Failure
virtual void Failure()
Definition: Generator.h:47
Effect::FindProject
const AudacityProject * FindProject() const
Definition: Effect.cpp:2035
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:75
Effect::GetDuration
double GetDuration() override
Definition: Effect.cpp:769
GetEditClipsCanMove
bool GetEditClipsCanMove()
Definition: WaveTrack.cpp:2849
Effect::MessageBox
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
Definition: Effect.cpp:2238
Effect::CopyInputTracks
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:1834
Generator::GenerateTrack
virtual bool GenerateTrack(WaveTrack *tmp, const WaveTrack &track, int ntrack)=0
Effect::mT1
double mT1
Definition: Effect.h:424
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:917
Generator::Success
virtual void Success()
Definition: Generator.h:46
WaveTrack::EmptyCopy
Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory={}) const
Definition: WaveTrack.cpp:709
Generator::BeforeTrack
virtual void BeforeTrack(const WaveTrack &WXUNUSED(track))
Definition: Generator.h:42
ViewInfo::selectedRegion
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:215
WaveTrack::Clear
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:790
Effect::mT0
double mT0
Definition: Effect.h:423
Generator::BeforeGenerate
virtual void BeforeGenerate()
Definition: Generator.h:41
SyncLock::IsSyncLockSelected
static bool IsSyncLockSelected(const Track *pTrack)
Definition: SyncLock.cpp:43
WaveTrack::IsEmpty
bool IsEmpty(double t0, double t1) const
Returns true if there are no WaveClips in the specified region.
Definition: WaveTrack.cpp:609
Effect::ReplaceProcessedTracks
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:1956
Track::Fallthrough
Continuation<> Fallthrough
Type of arguments passed as optional second parameter to TypeSwitch<void>() cases.
Definition: Track.h:499
Effect::mOutputTracks
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:422
Track::GetSelected
bool GetSelected() const
Definition: Track.h:428
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:224
WaveTrack::GetRate
double GetRate() const override
Definition: WaveTrack.cpp:495
PasteTimeWarper
Unit slope but with either a jump (pasting more) or a flat interval (pasting less)
Definition: TimeWarper.h:181