Audacity  3.2.0
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
EffectRepeat Class Referencefinal

An Effect that repeats audio several times over. More...

#include <Repeat.h>

Inheritance diagram for EffectRepeat:
Collaboration diagram for EffectRepeat:

Public Member Functions

 EffectRepeat ()
virtual ~EffectRepeat ()
ComponentInterfaceSymbol GetSymbol () override
TranslatableString GetDescription () override
ManualPageID ManualPage () override
 Name of a page in the Audacity alpha manual, default is empty. More...
EffectType GetType () override
 Type determines how it behaves. 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 DefineParams (ShuttleParams &S) override
bool Process () override
void PopulateOrExchange (ShuttleGui &S) override
bool TransferDataToWindow () override
bool TransferDataFromWindow () override
- Public Member Functions inherited from Effect
 Effect ()
virtual ~Effect ()
PluginPath GetPath () override
VendorSymbol GetVendor () override
wxString GetVersion () override
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 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 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 ()

Static Public Attributes

static const ComponentInterfaceSymbol Symbol { XO("Repeat") }
- 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>")

Private Member Functions

void OnRepeatTextChange (wxCommandEvent &evt)
void DisplayNewTime ()

Private Attributes

int repeatCount
wxTextCtrl * mRepeatCount
wxStaticText * mCurrentTime
wxStaticText * mTotalTime

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...
- Protected Member Functions inherited from Effect
bool EnableApply (bool enable=true)
bool EnablePreview (bool enable=true)
virtual bool Init ()
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)
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
- 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

An Effect that repeats audio several times over.

Definition at line 21 of file Repeat.h.

Constructor & Destructor Documentation

◆ EffectRepeat()

EffectRepeat::EffectRepeat ( )

Definition at line 56 of file Repeat.cpp.

57 {
58  repeatCount = DEF_Count;
60  SetLinearEffectFlag(true);
61 }

◆ ~EffectRepeat()

EffectRepeat::~EffectRepeat ( )

Definition at line 63 of file Repeat.cpp.

64 {
65 }

Member Function Documentation

◆ DefineParams()

bool EffectRepeat::DefineParams ( ShuttleParams S)

Definition at line 92 of file Repeat.cpp.

92  {
93  S.SHUTTLE_PARAM( repeatCount, Count );
94  return true;
95 }

References repeatCount, and S.

◆ DisplayNewTime()

void EffectRepeat::DisplayNewTime ( )

Definition at line 225 of file Repeat.cpp.

226 {
227  long l;
228  wxString str;
229  mRepeatCount->GetValue().ToLong(&l);
233  mT1 - mT0,
234  mProjectRate);
236  str = wxString::Format( _("Current selection length: %s"), nc.GetString() );
238  mCurrentTime->SetLabel(str);
239  mCurrentTime->SetName(str); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
241  if (l > 0) {
242  EnableApply(true);
243  repeatCount = l;
245  nc.SetValue((mT1 - mT0) * (repeatCount + 1));
246  str = wxString::Format( _("New selection length: %s"), nc.GetString() );
247  }
248  else {
249  str = _("Warning: No repeats.");
250  EnableApply(false);
251  }
252  mTotalTime->SetLabel(str);
253  mTotalTime->SetName(str); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
254 }

References _, Effect::EnableApply(), Effect::GetSelectionFormat(), NumericConverter::GetString(), mCurrentTime, Effect::mProjectRate, mRepeatCount, Effect::mT0, Effect::mT1, mTotalTime, repeatCount, NumericConverter::SetValue(), str, and NumericConverter::TIME.

Referenced by OnRepeatTextChange(), and TransferDataToWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAutomationParameters()

bool EffectRepeat::GetAutomationParameters ( CommandParameters parms)

Save current settings into parms.

Reimplemented from Effect.

Definition at line 97 of file Repeat.cpp.

98 {
99  parms.Write(KEY_Count, repeatCount);
101  return true;
102 }

References repeatCount.

◆ GetDescription()

TranslatableString EffectRepeat::GetDescription ( )

Reimplemented from Effect.

Definition at line 74 of file Repeat.cpp.

75 {
76  return XO("Repeats the selection the specified number of times");
77 }

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol EffectRepeat::GetSymbol ( )

Reimplemented from Effect.

Definition at line 69 of file Repeat.cpp.

70 {
71  return Symbol;
72 }

References Symbol.

◆ GetType()

EffectType EffectRepeat::GetType ( )

Type determines how it behaves.

Reimplemented from Effect.

Definition at line 86 of file Repeat.cpp.

87 {
88  return EffectTypeProcess;
89 }

References EffectTypeProcess.

◆ ManualPage()

ManualPageID EffectRepeat::ManualPage ( )

Name of a page in the Audacity alpha manual, default is empty.

Reimplemented from EffectDefinitionInterface.

Definition at line 79 of file Repeat.cpp.

80 {
81  return L"Repeat";
82 }

◆ OnRepeatTextChange()

void EffectRepeat::OnRepeatTextChange ( wxCommandEvent &  evt)

Definition at line 256 of file Repeat.cpp.

257 {
258  DisplayNewTime();
259 }

References DisplayNewTime().

Here is the call graph for this function:

◆ PopulateOrExchange()

void EffectRepeat::PopulateOrExchange ( ShuttleGui S)

Reimplemented from Effect.

Definition at line 179 of file Repeat.cpp.

180 {
181  S.StartHorizontalLay(wxCENTER, false);
182  {
183  mRepeatCount = S.Validator<IntegerValidator<int>>(
184  &repeatCount, NumValidatorStyle::DEFAULT,
185  MIN_Count, 2147483647 / mProjectRate
186  )
187  .AddTextBox(XXO("&Number of repeats to add:"), wxT(""), 12);
188  }
189  S.EndHorizontalLay();
191  S.StartMultiColumn(1, wxCENTER);
192  {
193  mCurrentTime = S.AddVariableText(
194  XO("Current selection length: dd:hh:mm:ss"));
195  mTotalTime = S.AddVariableText(XO("New selection length: dd:hh:mm:ss"));
196  }
197  S.EndMultiColumn();
198 }

References mCurrentTime, Effect::mProjectRate, mRepeatCount, mTotalTime, repeatCount, S, XO, and XXO.

◆ Process()

bool EffectRepeat::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 115 of file Repeat.cpp.

116 {
117  // Set up mOutputTracks.
118  // This effect needs all for sync-lock grouping.
119  CopyInputTracks(true);
121  int nTrack = 0;
122  bool bGoodResult = true;
123  double maxDestLen = 0.0; // used to change selection to generated bit
125  mOutputTracks->Any().VisitWhile( bGoodResult,
126  [&](LabelTrack *track)
127  {
129  {
130  if (!track->Repeat(mT0, mT1, repeatCount))
131  bGoodResult = false;
132  }
133  },
134  [&](WaveTrack *track, const Track::Fallthrough &fallthrough)
135  {
136  if (!track->GetSelected())
137  return fallthrough(); // Fall through to next lambda
138  auto start = track->TimeToLongSamples(mT0);
139  auto end = track->TimeToLongSamples(mT1);
140  auto len = end - start;
141  double tLen = track->LongSamplesToTime(len);
142  double tc = mT0 + tLen;
144  if (len <= 0)
145  return;
147  auto dest = track->Copy(mT0, mT1);
148  for(int j=0; j<repeatCount; j++)
149  {
150  if (TrackProgress(nTrack, j / repeatCount)) // TrackProgress returns true on Cancel.
151  {
152  bGoodResult = false;
153  return;
154  }
155  track->Paste(tc, dest.get());
156  tc += tLen;
157  }
158  if (tc > maxDestLen)
159  maxDestLen = tc;
160  nTrack++;
161  },
162  [&](Track *t)
163  {
165  t->SyncLockAdjust(mT1, mT1 + (mT1 - mT0) * repeatCount);
166  }
167  );
169  if (bGoodResult)
170  {
171  // Select the NEW bits + original bit
172  mT1 = maxDestLen;
173  }
175  ReplaceProcessedTracks(bGoodResult);
176  return bGoodResult;
177 }

References WaveTrack::Copy(), Effect::CopyInputTracks(), Track::GetSelected(), SyncLock::IsSelectedOrSyncLockSelected(), SyncLock::IsSyncLockSelected(), SampleTrack::LongSamplesToTime(), Effect::mOutputTracks, Effect::mT0, Effect::mT1, WaveTrack::Paste(), LabelTrack::Repeat(), repeatCount, Effect::ReplaceProcessedTracks(), SampleTrack::TimeToLongSamples(), and Effect::TrackProgress().

Here is the call graph for this function:

◆ SetAutomationParameters()

bool EffectRepeat::SetAutomationParameters ( CommandParameters parms)

Change settings to those stored in parms.

Reimplemented from Effect.

Definition at line 104 of file Repeat.cpp.

105 {
106  ReadAndVerifyInt(Count);
108  repeatCount = Count;
110  return true;
111 }

References ReadAndVerifyInt, and repeatCount.

◆ TransferDataFromWindow()

bool EffectRepeat::TransferDataFromWindow ( )

Reimplemented from Effect.

Definition at line 209 of file Repeat.cpp.

210 {
211  if (!mUIParent->Validate())
212  {
213  return false;
214  }
216  long l;
218  mRepeatCount->GetValue().ToLong(&l);
220  repeatCount = (int) l;
222  return true;
223 }

References mRepeatCount, Effect::mUIParent, and repeatCount.

◆ TransferDataToWindow()

bool EffectRepeat::TransferDataToWindow ( )

Reimplemented from Effect.

Definition at line 200 of file Repeat.cpp.

201 {
202  mRepeatCount->ChangeValue(wxString::Format(wxT("%d"), repeatCount));
204  DisplayNewTime();
206  return true;
207 }

References DisplayNewTime(), mRepeatCount, and repeatCount.

Here is the call graph for this function:

Member Data Documentation

◆ mCurrentTime

wxStaticText* EffectRepeat::mCurrentTime

Definition at line 62 of file Repeat.h.

Referenced by DisplayNewTime(), and PopulateOrExchange().

◆ mRepeatCount

wxTextCtrl* EffectRepeat::mRepeatCount

◆ mTotalTime

wxStaticText* EffectRepeat::mTotalTime

Definition at line 63 of file Repeat.h.

Referenced by DisplayNewTime(), and PopulateOrExchange().

◆ repeatCount

int EffectRepeat::repeatCount

◆ Symbol

const ComponentInterfaceSymbol EffectRepeat::Symbol { XO("Repeat") }

Definition at line 24 of file Repeat.h.

Referenced by GetSymbol().

The documentation for this class was generated from the following files:
A Track that contains audio waveform data.
Definition: WaveTrack.h:75
@ EffectTypeProcess
Definition: EffectInterface.h:56
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: Effect.cpp:1764
bool EnableApply(bool enable=true)
Definition: Effect.cpp:1694
#define S(N)
Definition: ToChars.cpp:64
virtual NumericFormatSymbol GetSelectionFormat()
Definition: Effect.cpp:784
void DisplayNewTime()
Definition: Repeat.cpp:225
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:1834
#define str(a)
Definition: DBConnection.cpp:30
double mT1
Definition: Effect.h:424
static const ComponentInterfaceSymbol Symbol
Definition: Repeat.h:24
#define XO(s)
Definition: Internat.h:31
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:89
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: WaveTrack.cpp:718
double mProjectRate
Definition: Effect.h:416
#define ReadAndVerifyInt(name)
Definition: Effect.h:591
#define XXO(s)
Definition: Internat.h:44
double mT0
Definition: Effect.h:423
static bool IsSyncLockSelected(const Track *pTrack)
Definition: SyncLock.cpp:43
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:1956
void Paste(double t0, const Track *src) override
Definition: WaveTrack.cpp:1568
Definition: NumericTextCtrl.h:52
Continuation<> Fallthrough
Type of arguments passed as optional second parameter to TypeSwitch<void>() cases.
Definition: Track.h:499
static bool IsSelectedOrSyncLockSelected(const Track *pTrack)
Definition: SyncLock.cpp:73
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:422
bool GetSelected() const
Definition: Track.h:428
NumericConverter provides the advanced formatting control used in the selection bar of Audacity.
Definition: NumericTextCtrl.h:48
wxTextCtrl * mRepeatCount
Definition: Repeat.h:61
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:224
wxWindow * mUIParent
Definition: Effect.h:438
wxStaticText * mCurrentTime
Definition: Repeat.h:62
#define _(s)
Definition: Internat.h:75
bool Repeat(double t0, double t1, int n)
Definition: LabelTrack.cpp:792
wxStaticText * mTotalTime
Definition: Repeat.h:63
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: SampleTrack.cpp:35
int repeatCount
Definition: Repeat.h:59
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
Definition: SampleTrack.cpp:40
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={})
Definition: Effect.cpp:1788