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

#include <Generator.h>

Inheritance diagram for Generator:
Collaboration diagram for Generator:

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
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 ( )

Definition at line 27 of file Generator.h.

27 { }

Member Function Documentation

◆ BeforeGenerate()

virtual void Generator::BeforeGenerate ( )

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)

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 ( )

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 ( )

Reimplemented from Effect.

Definition at line 37 of file Generator.h.

37 { return true; }

◆ Process()

bool Generator::Process ( )

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;
36  // Set up mOutputTracks.
37  // This effect needs all for sync-lock grouping.
38  this->CopyInputTracks(true);
40  // Iterate over the tracks
41  bool bGoodResult = true;
42  int ntrack = 0;
44  mOutputTracks->Any().VisitWhile( bGoodResult,
45  [&](WaveTrack *track, const Track::Fallthrough &fallthrough) {
46  if (!track->GetSelected())
47  return fallthrough();
48  bool editClipCanMove = GetEditClipsCanMove();
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  }
65  if (GetDuration() > 0.0)
66  {
67  auto pProject = FindProject();
68  // Create a temporary track
69  auto tmp = track->EmptyCopy();
70  BeforeTrack(*track);
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  }
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  }
99  ntrack++;
100  },
101  [&](Track *t) {
103  t->SyncLockAdjust(mT1, mT0 + GetDuration());
104  }
105  }
106  );
108  if (bGoodResult) {
109  Success();
111  this->ReplaceProcessedTracks(bGoodResult);
113  mT1 = mT0 + GetDuration(); // Update selection.
114  }
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 ( )

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