Audacity  3.0.3
Effect.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  Effect.cpp
6 
7  Dominic Mazzoni
8  Vaughan Johnson
9  Martyn Shaw
10 
11 *******************************************************************//*******************************************************************/
17 
18 
19 #include "Effect.h"
20 #include "TimeWarper.h"
21 
22 #include <algorithm>
23 
24 #include <wx/defs.h>
25 #include <wx/sizer.h>
26 #include <wx/tokenzr.h>
27 
28 #include "../AudioIO.h"
30 #include "../DBConnection.h"
31 #include "../LabelTrack.h"
32 #include "../Mix.h"
33 #include "../PluginManager.h"
34 #include "../ProjectAudioManager.h"
35 #include "../ProjectFileIO.h"
36 #include "../ProjectSettings.h"
37 #include "../prefs/QualitySettings.h"
38 #include "../ShuttleGui.h"
39 #include "../Shuttle.h"
40 #include "../ViewInfo.h"
41 #include "../WaveTrack.h"
42 #include "../wxFileNameWrapper.h"
43 #include "../widgets/ProgressDialog.h"
44 #include "../tracks/playabletrack/wavetrack/ui/WaveTrackView.h"
45 #include "../tracks/playabletrack/wavetrack/ui/WaveTrackViewConstants.h"
46 #include "../widgets/NumericTextCtrl.h"
47 #include "../widgets/AudacityMessageBox.h"
48 
49 #include <unordered_map>
50 
51 // Effect application counter
53 
54 static const int kPlayID = 20102;
55 static const int kRewindID = 20103;
56 static const int kFFwdID = 20104;
57 
58 const wxString Effect::kUserPresetIdent = wxT("User Preset:");
59 const wxString Effect::kFactoryPresetIdent = wxT("Factory Preset:");
60 const wxString Effect::kCurrentSettingsIdent = wxT("<Current Settings>");
61 const wxString Effect::kFactoryDefaultsIdent = wxT("<Factory Defaults>");
62 
63 using t2bHash = std::unordered_map< void*, bool >;
64 
65 namespace {
66 
68 {
69  static Effect::VetoDialogHook sHook = nullptr;
70  return sHook;
71 }
72 
73 }
74 
77 {
78  auto &theHook = GetVetoDialogHook();
79  auto result = theHook;
80  theHook = hook;
81  return result;
82 }
83 
85 {
86  mClient = NULL;
87 
88  mTracks = NULL;
89  mT0 = 0.0;
90  mT1 = 0.0;
91  mDuration = 0.0;
92  mIsPreview = false;
93  mIsLinearEffect = false;
95  mPreviewFullSelection = false;
96  mNumTracks = 0;
97  mNumGroups = 0;
98  mProgress = NULL;
99 
100  mUIParent = NULL;
101  mUIDialog = NULL;
102  mUIFlags = 0;
103 
104  mNumAudioIn = 0;
105  mNumAudioOut = 0;
106 
107  mBufferSize = 0;
108  mBlockSize = 0;
109  mNumChannels = 0;
110 
111  mUIDebug = false;
112 
113  // PRL: I think this initialization of mProjectRate doesn't matter
114  // because it is always reassigned in DoEffect before it is used
115  // STF: but can't call AudioIOBase::GetOptimalSupportedSampleRate() here.
116  // (Which is called to compute the default-default value.) (Bug 2280)
118 
119  mIsBatch = false;
120 }
121 
123 {
124  if (mUIDialog)
125  {
126  mUIDialog->Close();
127  }
128 }
129 
130 // EffectDefinitionInterface implementation
131 
133 {
134  if (mClient)
135  {
136  return mClient->GetType();
137  }
138 
139  return EffectTypeNone;
140 }
141 
143 {
144  if (mClient)
145  {
146  return mClient->GetPath();
147  }
148 
150 }
151 
153 {
154  if (mClient)
155  {
156  return mClient->GetSymbol();
157  }
158 
159  return {};
160 }
161 
163 {
164  if (mClient)
165  {
166  return mClient->GetVendor();
167  }
168 
169  return XO("Audacity");
170 }
171 
173 {
174  if (mClient)
175  {
176  return mClient->GetVersion();
177  }
178 
179  return AUDACITY_VERSION_STRING;
180 }
181 
183 {
184  if (mClient)
185  {
186  return mClient->GetDescription();
187  }
188 
189  return {};
190 }
191 
193 {
194  if (mClient)
195  {
196  return mClient->GetFamily();
197  }
198 
199  // Unusually, the internal and visible strings differ for the built-in
200  // effect family.
201  return { wxT("Audacity"), XO("Built-in") };
202 }
203 
205 {
206  if (mClient)
207  {
208  return mClient->IsInteractive();
209  }
210 
211  return true;
212 }
213 
215 {
216  if (mClient)
217  {
218  return mClient->IsDefault();
219  }
220 
221  return true;
222 }
223 
225 {
226  if (mClient)
227  {
228  return false;
229  }
230 
231  return true;
232 }
233 
235 {
236  if (mClient)
237  {
238  return mClient->SupportsRealtime();
239  }
240 
241  return false;
242 }
243 
245 {
246  if (mClient)
247  {
248  return mClient->SupportsAutomation();
249  }
250 
251  return true;
252 }
253 
254 // EffectClientInterface implementation
255 
257 {
258  if (mClient)
259  {
260  return mClient->SetHost(host);
261  }
262 
263  return true;
264 }
265 
267 {
268  if (mClient)
269  {
270  return mClient->GetAudioInCount();
271  }
272 
273  return 0;
274 }
275 
277 {
278  if (mClient)
279  {
280  return mClient->GetAudioOutCount();
281  }
282 
283  return 0;
284 }
285 
287 {
288  if (mClient)
289  {
290  return mClient->GetMidiInCount();
291  }
292 
293  return 0;
294 }
295 
297 {
298  if (mClient)
299  {
300  return mClient->GetMidiOutCount();
301  }
302 
303  return 0;
304 }
305 
306 void Effect::SetSampleRate(double rate)
307 {
308  if (mClient)
309  {
310  mClient->SetSampleRate(rate);
311  }
312 
313  mSampleRate = rate;
314 }
315 
316 size_t Effect::SetBlockSize(size_t maxBlockSize)
317 {
318  if (mClient)
319  {
320  return mClient->SetBlockSize(maxBlockSize);
321  }
322 
323  mBlockSize = maxBlockSize;
324 
325  return mBlockSize;
326 }
327 
328 size_t Effect::GetBlockSize() const
329 {
330  if (mClient)
331  {
332  return mClient->GetBlockSize();
333  }
334 
335  return mBlockSize;
336 }
337 
339 {
340  if (mClient)
341  {
342  return mClient->GetLatency();
343  }
344 
345  return 0;
346 }
347 
349 {
350  if (mClient)
351  {
352  return mClient->GetTailSize();
353  }
354 
355  return 0;
356 }
357 
359 {
360  if (mClient)
361  {
362  return mClient->IsReady();
363  }
364 
365  return true;
366 }
367 
369 {
370  if (mClient)
371  {
372  return mClient->ProcessInitialize(totalLen, chanMap);
373  }
374 
375  return true;
376 }
377 
379 {
380  if (mClient)
381  {
382  return mClient->ProcessFinalize();
383  }
384 
385  return true;
386 }
387 
388 size_t Effect::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen)
389 {
390  if (mClient)
391  {
392  return mClient->ProcessBlock(inBlock, outBlock, blockLen);
393  }
394 
395  return 0;
396 }
397 
399 {
400  if (mClient)
401  {
403  return mClient->RealtimeInitialize();
404  }
405 
406  mBlockSize = 512;
407 
408  return false;
409 }
410 
411 bool Effect::RealtimeAddProcessor(unsigned numChannels, float sampleRate)
412 {
413  if (mClient)
414  {
415  return mClient->RealtimeAddProcessor(numChannels, sampleRate);
416  }
417 
418  return true;
419 }
420 
422 {
423  if (mClient)
424  {
425  return mClient->RealtimeFinalize();
426  }
427 
428  return false;
429 }
430 
432 {
433  if (mClient)
434  return mClient->RealtimeSuspend();
435 
436  return true;
437 }
438 
440 {
441  if (mClient)
442  return mClient->RealtimeResume();
443 
444  return true;
445 }
446 
448 {
449  if (mClient)
450  {
451  return mClient->RealtimeProcessStart();
452  }
453 
454  return true;
455 }
456 
457 size_t Effect::RealtimeProcess(int group,
458  float **inbuf,
459  float **outbuf,
460  size_t numSamples)
461 {
462  if (mClient)
463  {
464  return mClient->RealtimeProcess(group, inbuf, outbuf, numSamples);
465  }
466 
467  return 0;
468 }
469 
471 {
472  if (mClient)
473  {
474  return mClient->RealtimeProcessEnd();
475  }
476 
477  return true;
478 }
479 
480 bool Effect::ShowInterface(wxWindow &parent,
481  const EffectDialogFactory &factory, bool forceModal)
482 {
483  if (!IsInteractive())
484  {
485  return true;
486  }
487 
488  if (mUIDialog)
489  {
490  if ( mUIDialog->Close(true) )
491  mUIDialog = nullptr;
492  return false;
493  }
494 
495  if (mClient)
496  {
497  return mClient->ShowInterface(parent, factory, forceModal);
498  }
499 
500  // mUIDialog is null
501  auto cleanup = valueRestorer( mUIDialog );
502 
503  if ( factory )
504  mUIDialog = factory(parent, this, this);
505  if (!mUIDialog)
506  {
507  return false;
508  }
509 
510 
511  mUIDialog->Layout();
512  mUIDialog->Fit();
513  mUIDialog->SetMinSize(mUIDialog->GetSize());
514 
515  auto hook = GetVetoDialogHook();
516  if( hook && hook( mUIDialog ) )
517  return false;
518 
519  if( SupportsRealtime() && !forceModal )
520  {
521  mUIDialog->Show();
522  cleanup.release();
523 
524  // Return false to bypass effect processing
525  return false;
526  }
527 
528  bool res = mUIDialog->ShowModal() != 0;
529 
530  return res;
531 }
532 
534 {
535  if (mClient)
536  {
537  return mClient->GetAutomationParameters(parms);
538  }
539 
540  return true;
541 }
542 
544 {
545  if (mClient)
546  {
547  return mClient->SetAutomationParameters(parms);
548  }
549 
550  return true;
551 }
552 
554 {
555  if (mClient)
556  {
557  return mClient->LoadUserPreset(name);
558  }
559 
560  wxString parms;
561  if (!GetPrivateConfig(name, wxT("Parameters"), parms))
562  {
563  return false;
564  }
565 
566  return SetAutomationParameters(parms);
567 }
568 
570 {
571  if (mClient)
572  {
573  return mClient->SaveUserPreset(name);
574  }
575 
576  wxString parms;
577  if (!GetAutomationParameters(parms))
578  {
579  return false;
580  }
581 
582  return SetPrivateConfig(name, wxT("Parameters"), parms);
583 }
584 
586 {
587  if (mClient)
588  {
589  return mClient->GetFactoryPresets();
590  }
591 
592  return {};
593 }
594 
596 {
597  if (mClient)
598  {
599  return mClient->LoadFactoryPreset(id);
600  }
601 
602  return true;
603 }
604 
606 {
607  if (mClient)
608  {
609  return mClient->LoadFactoryDefaults();
610  }
611 
613 }
614 
615 // EffectUIClientInterface implementation
616 
618 {
619 }
620 
622 {
623  auto parent = S.GetParent();
624  mUIParent = parent;
625  mUIParent->PushEventHandler(this);
626 
627 // LoadUserPreset(GetCurrentSettingsGroup());
628 
630 
631  mUIParent->SetMinSize(mUIParent->GetSizer()->GetMinSize());
632 
633  return true;
634 }
635 
637 {
638  return false;
639 }
640 
642 {
643  return mUIParent->Validate();
644 }
645 
647 {
648  return true;
649 }
650 
652 {
653  if (mUIParent)
654  mUIParent->RemoveEventHandler(this);
655 
656  mUIParent = NULL;
657  mUIDialog = NULL;
658 
659  return true;
660 }
661 
663 {
664  return true;
665 }
666 
668 {
669  static const FileNames::FileTypes result {
670  { XO("Presets"), { wxT("txt") }, true },
672  };
673  return result;
674 };
675 
677 {
678  wxString params;
680  wxString commandId = GetSquashedName(GetSymbol().Internal()).GET();
681  params = commandId + ":" + params;
682 
683  auto path = FileNames::SelectFile(FileNames::Operation::Presets,
684  XO("Export Effect Parameters"),
685  wxEmptyString,
686  wxEmptyString,
687  wxEmptyString,
688  PresetTypes(),
689  wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
690  nullptr);
691  if (path.empty()) {
692  return;
693  }
694 
695  // Create/Open the file
696  wxFFile f(path, wxT("wb"));
697  if (!f.IsOpened())
698  {
700  XO("Could not open file: \"%s\"").Format( path ),
701  XO("Error Saving Effect Presets"),
702  wxICON_EXCLAMATION,
703  NULL);
704  return;
705  }
706 
707  f.Write(params);
708  if (f.Error())
709  {
711  XO("Error writing to file: \"%s\"").Format( path ),
712  XO("Error Saving Effect Presets"),
713  wxICON_EXCLAMATION,
714  NULL);
715  }
716 
717  f.Close();
718 
719 
720  //SetWindowTitle();
721 
722 }
723 
725 {
726  wxString params;
727 
728  auto path = FileNames::SelectFile(FileNames::Operation::Presets,
729  XO("Import Effect Parameters"),
730  wxEmptyString,
731  wxEmptyString,
732  wxEmptyString,
733  PresetTypes(),
734  wxFD_OPEN | wxRESIZE_BORDER,
735  nullptr);
736  if (path.empty()) {
737  return;
738  }
739 
740  wxFFile f(path);
741  if (f.IsOpened()) {
742  if (f.ReadAll(&params)) {
743  wxString ident = params.BeforeFirst(':');
744  params = params.AfterFirst(':');
745 
746  wxString commandId = GetSquashedName(GetSymbol().Internal()).GET();
747 
748  if (ident != commandId) {
749  // effect identifiers are a sensible length!
750  // must also have some params.
751  if ((params.Length() < 2 ) || (ident.Length() < 2) || (ident.Length() > 30))
752  {
754  /* i18n-hint %s will be replaced by a file name */
755  XO("%s: is not a valid presets file.\n")
756  .Format(wxFileNameFromPath(path)));
757  }
758  else
759  {
761  /* i18n-hint %s will be replaced by a file name */
762  XO("%s: is for a different Effect, Generator or Analyzer.\n")
763  .Format(wxFileNameFromPath(path)));
764  }
765  return;
766  }
768  }
769  }
770 
771  //SetWindowTitle();
772 
773 }
774 
776 {
777  // Get rid of leading and trailing white space
778  name.Trim(true).Trim(false);
779 
780  if (name.empty())
781  {
782  return name;
783  }
784 
785  wxStringTokenizer st(name, wxT(" "));
786  wxString id;
787 
788  // CamelCase the name
789  while (st.HasMoreTokens())
790  {
791  wxString tok = st.GetNextToken();
792 
793  id += tok.Left(1).MakeUpper() + tok.Mid(1).MakeLower();
794  }
795 
796  return id;
797 }
798 
800 {
801  return false;
802 }
803 
805 {
806 }
807 
808 // EffectHostInterface implementation
809 
811 {
812  return 30.0;
813 }
814 
816 {
817  if (mDuration < 0.0)
818  {
819  mDuration = 0.0;
820  }
821 
822  return mDuration;
823 }
824 
826 {
827  return mDurationFormat;
828 }
829 
831 {
832  if( !IsBatchProcessing() && FindProject() )
835 }
836 
837 void Effect::SetDuration(double seconds)
838 {
839  if (seconds < 0.0)
840  {
841  seconds = 0.0;
842  }
843 
844  if (GetType() == EffectTypeGenerate)
845  {
846  SetPrivateConfig(GetCurrentSettingsGroup(), wxT("LastUsedDuration"), seconds);
847  }
848 
849  mDuration = seconds;
850 
851  return;
852 }
853 
855 {
856  RegistryPath group = wxT("UserPresets");
857  if (!name.empty())
858  {
859  group += wxCONFIG_PATH_SEPARATOR + name;
860  }
861 
862  return group;
863 }
864 
866 {
867  return wxT("CurrentSettings");
868 }
869 
871 {
872  return wxT("FactoryDefaults");
873 }
874 
876 {
877  return wxT("SavedState");
878 }
879 
880 // ConfigClientInterface implementation
882 {
883  return PluginManager::Get().HasSharedConfigGroup(GetID(), group);
884 }
885 
887 {
888  return PluginManager::Get().GetSharedConfigSubgroups(GetID(), group, subgroups);
889 }
890 
891 bool Effect::GetSharedConfig(const RegistryPath & group, const RegistryPath & key, wxString & value, const wxString & defval)
892 {
893  return PluginManager::Get().GetSharedConfig(GetID(), group, key, value, defval);
894 }
895 
896 bool Effect::GetSharedConfig(const RegistryPath & group, const RegistryPath & key, int & value, int defval)
897 {
898  return PluginManager::Get().GetSharedConfig(GetID(), group, key, value, defval);
899 }
900 
901 bool Effect::GetSharedConfig(const RegistryPath & group, const RegistryPath & key, bool & value, bool defval)
902 {
903  return PluginManager::Get().GetSharedConfig(GetID(), group, key, value, defval);
904 }
905 
906 bool Effect::GetSharedConfig(const RegistryPath & group, const RegistryPath & key, float & value, float defval)
907 {
908  return PluginManager::Get().GetSharedConfig(GetID(), group, key, value, defval);
909 }
910 
911 bool Effect::GetSharedConfig(const RegistryPath & group, const RegistryPath & key, double & value, double defval)
912 {
913  return PluginManager::Get().GetSharedConfig(GetID(), group, key, value, defval);
914 }
915 
916 bool Effect::SetSharedConfig(const RegistryPath & group, const RegistryPath & key, const wxString & value)
917 {
918  return PluginManager::Get().SetSharedConfig(GetID(), group, key, value);
919 }
920 
921 bool Effect::SetSharedConfig(const RegistryPath & group, const RegistryPath & key, const int & value)
922 {
923  return PluginManager::Get().SetSharedConfig(GetID(), group, key, value);
924 }
925 
926 bool Effect::SetSharedConfig(const RegistryPath & group, const RegistryPath & key, const bool & value)
927 {
928  return PluginManager::Get().SetSharedConfig(GetID(), group, key, value);
929 }
930 
931 bool Effect::SetSharedConfig(const RegistryPath & group, const RegistryPath & key, const float & value)
932 {
933  return PluginManager::Get().SetSharedConfig(GetID(), group, key, value);
934 }
935 
936 bool Effect::SetSharedConfig(const RegistryPath & group, const RegistryPath & key, const double & value)
937 {
938  return PluginManager::Get().SetSharedConfig(GetID(), group, key, value);
939 }
940 
942 {
944 }
945 
947 {
948  return PluginManager::Get().RemoveSharedConfig(GetID(), group, key);
949 }
950 
952 {
954 }
955 
957 {
958  return PluginManager::Get().GetPrivateConfigSubgroups(GetID(), group, subgroups);
959 }
960 
961 bool Effect::GetPrivateConfig(const RegistryPath & group, const RegistryPath & key, wxString & value, const wxString & defval)
962 {
963  return PluginManager::Get().GetPrivateConfig(GetID(), group, key, value, defval);
964 }
965 
966 bool Effect::GetPrivateConfig(const RegistryPath & group, const RegistryPath & key, int & value, int defval)
967 {
968  return PluginManager::Get().GetPrivateConfig(GetID(), group, key, value, defval);
969 }
970 
971 bool Effect::GetPrivateConfig(const RegistryPath & group, const RegistryPath & key, bool & value, bool defval)
972 {
973  return PluginManager::Get().GetPrivateConfig(GetID(), group, key, value, defval);
974 }
975 
976 bool Effect::GetPrivateConfig(const RegistryPath & group, const RegistryPath & key, float & value, float defval)
977 {
978  return PluginManager::Get().GetPrivateConfig(GetID(), group, key, value, defval);
979 }
980 
981 bool Effect::GetPrivateConfig(const RegistryPath & group, const RegistryPath & key, double & value, double defval)
982 {
983  return PluginManager::Get().GetPrivateConfig(GetID(), group, key, value, defval);
984 }
985 
986 bool Effect::SetPrivateConfig(const RegistryPath & group, const RegistryPath & key, const wxString & value)
987 {
988  return PluginManager::Get().SetPrivateConfig(GetID(), group, key, value);
989 }
990 
991 bool Effect::SetPrivateConfig(const RegistryPath & group, const RegistryPath & key, const int & value)
992 {
993  return PluginManager::Get().SetPrivateConfig(GetID(), group, key, value);
994 }
995 
996 bool Effect::SetPrivateConfig(const RegistryPath & group, const RegistryPath & key, const bool & value)
997 {
998  return PluginManager::Get().SetPrivateConfig(GetID(), group, key, value);
999 }
1000 
1001 bool Effect::SetPrivateConfig(const RegistryPath & group, const RegistryPath & key, const float & value)
1002 {
1003  return PluginManager::Get().SetPrivateConfig(GetID(), group, key, value);
1004 }
1005 
1006 bool Effect::SetPrivateConfig(const RegistryPath & group, const RegistryPath & key, const double & value)
1007 {
1008  return PluginManager::Get().SetPrivateConfig(GetID(), group, key, value);
1009 }
1010 
1012 {
1014 }
1015 
1017 {
1018  return PluginManager::Get().RemovePrivateConfig(GetID(), group, key);
1019 }
1020 
1021 // Effect implementation
1022 
1024 {
1025  if (mClient)
1026  {
1027  return PluginManager::GetID(mClient);
1028  }
1029 
1030  return PluginManager::GetID(this);
1031 }
1032 
1034 {
1035  // Let destructor know we need to be shutdown
1036  mClient = client;
1037 
1038  // Set host so client startup can use our services
1039  if (!SetHost(this))
1040  {
1041  // Bail if the client startup fails
1042  mClient = NULL;
1043  return false;
1044  }
1045 
1048 
1049  bool haveDefaults;
1050  GetPrivateConfig(GetFactoryDefaultsGroup(), wxT("Initialized"), haveDefaults, false);
1051  if (!haveDefaults)
1052  {
1054  SetPrivateConfig(GetFactoryDefaultsGroup(), wxT("Initialized"), true);
1055  }
1057 
1058  return Startup();
1059 }
1060 
1062 {
1063  return true;
1064 }
1065 
1066 bool Effect::GetAutomationParameters(wxString & parms)
1067 {
1068  CommandParameters eap;
1069 
1071  {
1072  return false;
1073  }
1074 
1076  S.mpEap = &eap;
1077  if( DefineParams( S ) ){
1078  ;// got eap value using DefineParams.
1079  }
1080  // Won't be needed in future
1081  else if (!GetAutomationParameters(eap))
1082  {
1083  return false;
1084  }
1085 
1086  return eap.GetParameters(parms);
1087 }
1088 
1089 bool Effect::SetAutomationParameters(const wxString & parms)
1090 {
1091  wxString preset = parms;
1092  bool success = false;
1093  if (preset.StartsWith(kUserPresetIdent))
1094  {
1095  preset.Replace(kUserPresetIdent, wxEmptyString, false);
1096  success = LoadUserPreset(GetUserPresetsGroup(preset));
1097  }
1098  else if (preset.StartsWith(kFactoryPresetIdent))
1099  {
1100  preset.Replace(kFactoryPresetIdent, wxEmptyString, false);
1101  auto presets = GetFactoryPresets();
1102  success = LoadFactoryPreset( make_iterator_range( presets ).index( preset ) );
1103  }
1104  else if (preset.StartsWith(kCurrentSettingsIdent))
1105  {
1106  preset.Replace(kCurrentSettingsIdent, wxEmptyString, false);
1108  }
1109  else if (preset.StartsWith(kFactoryDefaultsIdent))
1110  {
1111  preset.Replace(kFactoryDefaultsIdent, wxEmptyString, false);
1113  }
1114  else
1115  {
1116  CommandParameters eap(parms);
1118  S.SetForValidating( &eap );
1119  // DefineParams returns false if not defined for this effect.
1120  if( !DefineParams( S ) )
1121  // the old method...
1122  success = SetAutomationParameters(eap);
1123  else if( !S.bOK )
1124  success = false;
1125  else{
1126  success = true;
1127  S.SetForWriting( &eap );
1128  DefineParams( S );
1129  }
1130  }
1131 
1132  if (!success)
1133  {
1135  XO("%s: Could not load settings below. Default settings will be used.\n\n%s")
1136  .Format( GetName(), preset ) );
1137  // We are using default settings and we still wish to continue.
1138  return true;
1139  //return false;
1140  }
1141 
1142  if (!mUIDialog)
1143  {
1144  return true;
1145  }
1146 
1147  return TransferDataToWindow();
1148 }
1149 
1151 {
1152  RegistryPaths presets;
1153 
1154  GetPrivateConfigSubgroups(GetUserPresetsGroup(wxEmptyString), presets);
1155 
1156  std::sort( presets.begin(), presets.end() );
1157 
1158  return presets;
1159 }
1160 
1162 {
1164 }
1165 
1167 {
1169 }
1170 
1172 {
1173  return {};
1174 }
1175 
1177 {
1178  return {};
1179 }
1180 
1181 void Effect::SetUIFlags(unsigned flags) {
1182  mUIFlags = flags;
1183 }
1184 
1185 unsigned Effect::TestUIFlags(unsigned mask) {
1186  return mask & mUIFlags;
1187 }
1188 
1190 {
1191  return mIsBatch;
1192 }
1193 
1195 {
1196  mIsBatch = start;
1197 
1198  if (start)
1199  {
1201  }
1202  else
1203  {
1205  }
1206 }
1207 
1208 bool Effect::DoEffect(double projectRate,
1209  TrackList *list,
1211  NotifyingSelectedRegion &selectedRegion,
1212  wxWindow *pParent,
1213  const EffectDialogFactory &dialogFactory)
1214 {
1215  wxASSERT(selectedRegion.duration() >= 0.0);
1216 
1217  mOutputTracks.reset();
1218 
1219  mpSelectedRegion = &selectedRegion;
1220  mFactory = factory;
1221  mProjectRate = projectRate;
1222  mTracks = list;
1223 
1224  // This is for performance purposes only, no additional recovery implied
1225  auto &pProject = *const_cast<AudacityProject*>(FindProject()); // how to remove this const_cast?
1226  auto &pIO = ProjectFileIO::Get(pProject);
1227  TransactionScope trans(pIO.GetConnection(), "Effect");
1228 
1229  // Update track/group counts
1230  CountWaveTracks();
1231 
1232  bool isSelection = false;
1233 
1234  mDuration = 0.0;
1235  if (GetType() == EffectTypeGenerate)
1236  {
1237  GetPrivateConfig(GetCurrentSettingsGroup(), wxT("LastUsedDuration"), mDuration, GetDefaultDuration());
1238  }
1239 
1240  WaveTrack *newTrack{};
1241  bool success = false;
1242  auto oldDuration = mDuration;
1243 
1244  auto cleanup = finally( [&] {
1245  if (!success) {
1246  if (newTrack) {
1247  mTracks->Remove(newTrack);
1248  }
1249  // LastUsedDuration may have been modified by Preview.
1250  SetDuration(oldDuration);
1251  }
1252  else
1253  trans.Commit();
1254 
1255  End();
1256  ReplaceProcessedTracks( false );
1257  } );
1258 
1259  // We don't yet know the effect type for code in the Nyquist Prompt, so
1260  // assume it requires a track and handle errors when the effect runs.
1261  if ((GetType() == EffectTypeGenerate || GetPath() == NYQUIST_PROMPT_ID) && (mNumTracks == 0)) {
1262  newTrack = mTracks->Add(mFactory->NewWaveTrack());
1263  newTrack->SetSelected(true);
1264  }
1265 
1266  mT0 = selectedRegion.t0();
1267  mT1 = selectedRegion.t1();
1268  if (mT1 > mT0)
1269  {
1270  // there is a selection: let's fit in there...
1271  // MJS: note that this is just for the TTC and is independent of the track rate
1272  // but we do need to make sure we have the right number of samples at the project rate
1273  double quantMT0 = QUANTIZED_TIME(mT0, mProjectRate);
1274  double quantMT1 = QUANTIZED_TIME(mT1, mProjectRate);
1275  mDuration = quantMT1 - quantMT0;
1276  isSelection = true;
1277  mT1 = mT0 + mDuration;
1278  }
1279 
1280  mDurationFormat = isSelection
1283 
1284 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
1285  mF0 = selectedRegion.f0();
1286  mF1 = selectedRegion.f1();
1287  wxArrayString Names;
1289  Names.push_back(wxT("control-f0"));
1291  Names.push_back(wxT("control-f1"));
1292  SetPresetParameters( &Names, NULL );
1293 
1294 #endif
1295  CountWaveTracks();
1296 
1297  // Note: Init may read parameters from preferences
1298  if (!Init())
1299  {
1300  return false;
1301  }
1302 
1303  // Prompting will be bypassed when applying an effect that has already
1304  // been configured, e.g. repeating the last effect on a different selection.
1305  // Prompting may call Effect::Preview
1306  if ( pParent && dialogFactory &&
1307  IsInteractive() &&
1308  !ShowInterface( *pParent, dialogFactory, IsBatchProcessing() ) )
1309  {
1310  return false;
1311  }
1312 
1313  bool returnVal = true;
1314  bool skipFlag = CheckWhetherSkipEffect();
1315  if (skipFlag == false)
1316  {
1317  auto name = GetName();
1318  ProgressDialog progress{
1319  name,
1320  XO("Applying %s...").Format( name ),
1322  };
1323  auto vr = valueRestorer( mProgress, &progress );
1324 
1325  {
1326  returnVal = Process();
1327  }
1328  }
1329 
1330  if (returnVal && (mT1 >= mT0 ))
1331  {
1332  selectedRegion.setTimes(mT0, mT1);
1333  }
1334 
1335  success = returnVal;
1336  return returnVal;
1337 }
1338 
1340  Effect &delegate, wxWindow &parent, const EffectDialogFactory &factory )
1341 {
1342  NotifyingSelectedRegion region;
1343  region.setTimes( mT0, mT1 );
1344 
1345  return delegate.DoEffect( mProjectRate, mTracks, mFactory,
1346  region, &parent, factory );
1347 }
1348 
1349 // All legacy effects should have this overridden
1351 {
1352  return true;
1353 }
1354 
1356 {
1357  return mPass;
1358 }
1359 
1361 {
1362  return true;
1363 }
1364 
1366 {
1367  return false;
1368 }
1369 
1371 {
1372  CopyInputTracks(true);
1373  bool bGoodResult = true;
1374 
1375  // It's possible that the number of channels the effect expects changed based on
1376  // the parameters (the Audacity Reverb effect does when the stereo width is 0).
1379 
1380  mPass = 1;
1381  if (InitPass1())
1382  {
1383  bGoodResult = ProcessPass();
1384  mPass = 2;
1385  if (bGoodResult && InitPass2())
1386  {
1387  bGoodResult = ProcessPass();
1388  }
1389  }
1390 
1391  ReplaceProcessedTracks(bGoodResult);
1392 
1393  return bGoodResult;
1394 }
1395 
1397 {
1398  bool bGoodResult = true;
1399  bool isGenerator = GetType() == EffectTypeGenerate;
1400 
1401  FloatBuffers inBuffer, outBuffer;
1402  ArrayOf<float *> inBufPos, outBufPos;
1403 
1404  ChannelName map[3];
1405 
1406  mBufferSize = 0;
1407  mBlockSize = 0;
1408 
1409  int count = 0;
1410  bool clear = false;
1411 
1412  const bool multichannel = mNumAudioIn > 1;
1413  auto range = multichannel
1414  ? mOutputTracks->Leaders()
1415  : mOutputTracks->Any();
1416  range.VisitWhile( bGoodResult,
1417  [&](WaveTrack *left, const Track::Fallthrough &fallthrough) {
1418  if (!left->GetSelected())
1419  return fallthrough();
1420 
1421  sampleCount len = 0;
1422  sampleCount start = 0;
1423 
1424  mNumChannels = 0;
1425  WaveTrack *right{};
1426 
1427  // Iterate either over one track which could be any channel,
1428  // or if multichannel, then over all channels of left,
1429  // which is a leader.
1430  for (auto channel :
1431  TrackList::Channels(left).StartingWith(left)) {
1432  if (channel->GetChannel() == Track::LeftChannel)
1434  else if (channel->GetChannel() == Track::RightChannel)
1436  else
1438 
1439  ++ mNumChannels;
1441 
1442  if (! multichannel)
1443  break;
1444 
1445  if (mNumChannels == 2) {
1446  // TODO: more-than-two-channels
1447  right = channel;
1448  clear = false;
1449  // Ignore other channels
1450  break;
1451  }
1452  }
1453 
1454  if (!isGenerator)
1455  {
1456  GetBounds(*left, right, &start, &len);
1457  mSampleCnt = len;
1458  }
1459  else
1461 
1462  // Let the client know the sample rate
1463  SetSampleRate(left->GetRate());
1464 
1465  // Get the block size the client wants to use
1466  auto max = left->GetMaxBlockSize() * 2;
1467  mBlockSize = SetBlockSize(max);
1468 
1469  // Calculate the buffer size to be at least the max rounded up to the clients
1470  // selected block size.
1471  const auto prevBufferSize = mBufferSize;
1472  mBufferSize = ((max + (mBlockSize - 1)) / mBlockSize) * mBlockSize;
1473 
1474  // If the buffer size has changed, then (re)allocate the buffers
1475  if (prevBufferSize != mBufferSize)
1476  {
1477  // Always create the number of input buffers the client expects even if we don't have
1478  // the same number of channels.
1479  inBufPos.reinit( mNumAudioIn );
1480  inBuffer.reinit( mNumAudioIn, mBufferSize );
1481 
1482  // We won't be using more than the first 2 buffers, so clear the rest (if any)
1483  for (size_t i = 2; i < mNumAudioIn; i++)
1484  {
1485  for (size_t j = 0; j < mBufferSize; j++)
1486  {
1487  inBuffer[i][j] = 0.0;
1488  }
1489  }
1490 
1491  // Always create the number of output buffers the client expects even if we don't have
1492  // the same number of channels.
1493  outBufPos.reinit( mNumAudioOut );
1494  // Output buffers get an extra mBlockSize worth to give extra room if
1495  // the plugin adds latency
1496  outBuffer.reinit( mNumAudioOut, mBufferSize + mBlockSize );
1497  }
1498 
1499  // (Re)Set the input buffer positions
1500  for (size_t i = 0; i < mNumAudioIn; i++)
1501  {
1502  inBufPos[i] = inBuffer[i].get();
1503  }
1504 
1505  // (Re)Set the output buffer positions
1506  for (size_t i = 0; i < mNumAudioOut; i++)
1507  {
1508  outBufPos[i] = outBuffer[i].get();
1509  }
1510 
1511  // Clear unused input buffers
1512  if (!right && !clear && mNumAudioIn > 1)
1513  {
1514  for (size_t j = 0; j < mBufferSize; j++)
1515  {
1516  inBuffer[1][j] = 0.0;
1517  }
1518  clear = true;
1519  }
1520 
1521  // Go process the track(s)
1522  bGoodResult = ProcessTrack(
1523  count, map, left, right, start, len,
1524  inBuffer, outBuffer, inBufPos, outBufPos);
1525  if (!bGoodResult)
1526  return;
1527 
1528  count++;
1529  },
1530  [&](Track *t) {
1531  if (t->IsSyncLockSelected())
1532  t->SyncLockAdjust(mT1, mT0 + mDuration);
1533  }
1534  );
1535 
1536  if (bGoodResult && GetType() == EffectTypeGenerate)
1537  {
1538  mT1 = mT0 + mDuration;
1539  }
1540 
1541  return bGoodResult;
1542 }
1543 
1544 bool Effect::ProcessTrack(int count,
1545  ChannelNames map,
1546  WaveTrack *left,
1547  WaveTrack *right,
1548  sampleCount start,
1549  sampleCount len,
1550  FloatBuffers &inBuffer,
1551  FloatBuffers &outBuffer,
1552  ArrayOf< float * > &inBufPos,
1553  ArrayOf< float *> &outBufPos)
1554 {
1555  bool rc = true;
1556 
1557  // Give the plugin a chance to initialize
1558  if (!ProcessInitialize(len, map))
1559  {
1560  return false;
1561  }
1562 
1563  { // Start scope for cleanup
1564  auto cleanup = finally( [&] {
1565  // Allow the plugin to cleanup
1566  if (!ProcessFinalize())
1567  {
1568  // In case of non-exceptional flow of control, set rc
1569  rc = false;
1570  }
1571  } );
1572 
1573  // For each input block of samples, we pass it to the effect along with a
1574  // variable output location. This output location is simply a pointer into a
1575  // much larger buffer. This reduces the number of calls required to add the
1576  // samples to the output track.
1577  //
1578  // Upon return from the effect, the output samples are "moved to the left" by
1579  // the number of samples in the current latency setting, effectively removing any
1580  // delay introduced by the effect.
1581  //
1582  // At the same time the total number of delayed samples are gathered and when
1583  // there is no further input data to process, the loop continues to call the
1584  // effect with an empty input buffer until the effect has had a chance to
1585  // return all of the remaining delayed samples.
1586  auto inPos = start;
1587  auto outPos = start;
1588 
1589  auto inputRemaining = len;
1590  decltype(GetLatency()) curDelay = 0, delayRemaining = 0;
1591  decltype(mBlockSize) curBlockSize = 0;
1592 
1593  decltype(mBufferSize) inputBufferCnt = 0;
1594  decltype(mBufferSize) outputBufferCnt = 0;
1595  bool cleared = false;
1596 
1597  auto chans = std::min<unsigned>(mNumAudioOut, mNumChannels);
1598 
1599  std::shared_ptr<WaveTrack> genLeft, genRight;
1600 
1601  decltype(len) genLength = 0;
1602  bool isGenerator = GetType() == EffectTypeGenerate;
1603  bool isProcessor = GetType() == EffectTypeProcess;
1604  double genDur = 0;
1605  if (isGenerator)
1606  {
1607  if (mIsPreview) {
1608  gPrefs->Read(wxT("/AudioIO/EffectsPreviewLen"), &genDur, 6.0);
1609  genDur = wxMin(mDuration, CalcPreviewInputLength(genDur));
1610  }
1611  else {
1612  genDur = mDuration;
1613  }
1614 
1615  genLength = sampleCount((left->GetRate() * genDur) + 0.5); // round to nearest sample
1616  delayRemaining = genLength;
1617  cleared = true;
1618 
1619  // Create temporary tracks
1620  genLeft = left->EmptyCopy();
1621 
1622  if (right)
1623  genRight = right->EmptyCopy();
1624  }
1625 
1626  // Call the effect until we run out of input or delayed samples
1627  while (inputRemaining != 0 || delayRemaining != 0)
1628  {
1629  // Still working on the input samples
1630  if (inputRemaining != 0)
1631  {
1632  // Need to refill the input buffers
1633  if (inputBufferCnt == 0)
1634  {
1635  // Calculate the number of samples to get
1636  inputBufferCnt =
1637  limitSampleBufferSize( mBufferSize, inputRemaining );
1638 
1639  // Fill the input buffers
1640  left->GetFloats(inBuffer[0].get(), inPos, inputBufferCnt);
1641  if (right)
1642  {
1643  right->GetFloats(inBuffer[1].get(), inPos, inputBufferCnt);
1644  }
1645 
1646  // Reset the input buffer positions
1647  for (size_t i = 0; i < mNumChannels; i++)
1648  {
1649  inBufPos[i] = inBuffer[i].get();
1650  }
1651  }
1652 
1653  // Calculate the number of samples to process
1654  curBlockSize = mBlockSize;
1655  if (curBlockSize > inputRemaining)
1656  {
1657  // We've reached the last block...set current block size to what's left
1658  // inputRemaining is positive and bounded by a size_t
1659  curBlockSize = inputRemaining.as_size_t();
1660  inputRemaining = 0;
1661 
1662  // Clear the remainder of the buffers so that a full block can be passed
1663  // to the effect
1664  auto cnt = mBlockSize - curBlockSize;
1665  for (size_t i = 0; i < mNumChannels; i++)
1666  {
1667  for (decltype(cnt) j = 0 ; j < cnt; j++)
1668  {
1669  inBufPos[i][j + curBlockSize] = 0.0;
1670  }
1671  }
1672 
1673  // Might be able to use up some of the delayed samples
1674  if (delayRemaining != 0)
1675  {
1676  // Don't use more than needed
1677  cnt = limitSampleBufferSize(cnt, delayRemaining);
1678  delayRemaining -= cnt;
1679  curBlockSize += cnt;
1680  }
1681  }
1682  }
1683  // We've exhausted the input samples and are now working on the delay
1684  else if (delayRemaining != 0)
1685  {
1686  // Calculate the number of samples to process
1687  curBlockSize = limitSampleBufferSize( mBlockSize, delayRemaining );
1688  delayRemaining -= curBlockSize;
1689 
1690  // From this point on, we only want to feed zeros to the plugin
1691  if (!cleared)
1692  {
1693  // Reset the input buffer positions
1694  for (size_t i = 0; i < mNumChannels; i++)
1695  {
1696  inBufPos[i] = inBuffer[i].get();
1697 
1698  // And clear
1699  for (size_t j = 0; j < mBlockSize; j++)
1700  {
1701  inBuffer[i][j] = 0.0;
1702  }
1703  }
1704  cleared = true;
1705  }
1706  }
1707 
1708  // Finally call the plugin to process the block
1709  decltype(curBlockSize) processed;
1710  try
1711  {
1712  processed = ProcessBlock(inBufPos.get(), outBufPos.get(), curBlockSize);
1713  }
1714  catch( const AudacityException & WXUNUSED(e) )
1715  {
1716  // PRL: Bug 437:
1717  // Pass this along to our application-level handler
1718  throw;
1719  }
1720  catch(...)
1721  {
1722  // PRL:
1723  // Exceptions for other reasons, maybe in third-party code...
1724  // Continue treating them as we used to, but I wonder if these
1725  // should now be treated the same way.
1726  return false;
1727  }
1728  wxASSERT(processed == curBlockSize);
1729  wxUnusedVar(processed);
1730 
1731  // Bump to next input buffer position
1732  if (inputRemaining != 0)
1733  {
1734  for (size_t i = 0; i < mNumChannels; i++)
1735  {
1736  inBufPos[i] += curBlockSize;
1737  }
1738  inputRemaining -= curBlockSize;
1739  inputBufferCnt -= curBlockSize;
1740  }
1741 
1742  // "ls" and "rs" serve as the input sample index for the left and
1743  // right channels when processing the input samples. If we flip
1744  // over to processing delayed samples, they simply become counters
1745  // for the progress display.
1746  inPos += curBlockSize;
1747 
1748  // Get the current number of delayed samples and accumulate
1749  if (isProcessor)
1750  {
1751  {
1752  auto delay = GetLatency();
1753  curDelay += delay;
1754  delayRemaining += delay;
1755  }
1756 
1757  // If the plugin has delayed the output by more samples than our current
1758  // block size, then we leave the output pointers alone. This effectively
1759  // removes those delayed samples from the output buffer.
1760  if (curDelay >= curBlockSize)
1761  {
1762  curDelay -= curBlockSize;
1763  curBlockSize = 0;
1764  }
1765  // We have some delayed samples, at the beginning of the output samples,
1766  // so overlay them by shifting the remaining output samples.
1767  else if (curDelay > 0)
1768  {
1769  // curDelay is bounded by curBlockSize:
1770  auto delay = curDelay.as_size_t();
1771  curBlockSize -= delay;
1772  for (size_t i = 0; i < chans; i++)
1773  {
1774  memmove(outBufPos[i], outBufPos[i] + delay, sizeof(float) * curBlockSize);
1775  }
1776  curDelay = 0;
1777  }
1778  }
1779 
1780  // Adjust the number of samples in the output buffers
1781  outputBufferCnt += curBlockSize;
1782 
1783  // Still have room in the output buffers
1784  if (outputBufferCnt < mBufferSize)
1785  {
1786  // Bump to next output buffer position
1787  for (size_t i = 0; i < chans; i++)
1788  {
1789  outBufPos[i] += curBlockSize;
1790  }
1791  }
1792  // Output buffers have filled
1793  else
1794  {
1795  if (isProcessor)
1796  {
1797  // Write them out
1798  left->Set((samplePtr) outBuffer[0].get(), floatSample, outPos, outputBufferCnt);
1799  if (right)
1800  {
1801  if (chans >= 2)
1802  {
1803  right->Set((samplePtr) outBuffer[1].get(), floatSample, outPos, outputBufferCnt);
1804  }
1805  else
1806  {
1807  right->Set((samplePtr) outBuffer[0].get(), floatSample, outPos, outputBufferCnt);
1808  }
1809  }
1810  }
1811  else if (isGenerator)
1812  {
1813  genLeft->Append((samplePtr) outBuffer[0].get(), floatSample, outputBufferCnt);
1814  if (genRight)
1815  {
1816  genRight->Append((samplePtr) outBuffer[1].get(), floatSample, outputBufferCnt);
1817  }
1818  }
1819 
1820  // Reset the output buffer positions
1821  for (size_t i = 0; i < chans; i++)
1822  {
1823  outBufPos[i] = outBuffer[i].get();
1824  }
1825 
1826  // Bump to the next track position
1827  outPos += outputBufferCnt;
1828  outputBufferCnt = 0;
1829  }
1830 
1831  if (mNumChannels > 1)
1832  {
1833  if (TrackGroupProgress(count,
1834  (inPos - start).as_double() /
1835  (isGenerator ? genLength : len).as_double()))
1836  {
1837  rc = false;
1838  break;
1839  }
1840  }
1841  else
1842  {
1843  if (TrackProgress(count,
1844  (inPos - start).as_double() /
1845  (isGenerator ? genLength : len).as_double()))
1846  {
1847  rc = false;
1848  break;
1849  }
1850  }
1851  }
1852 
1853  // Put any remaining output
1854  if (rc && outputBufferCnt)
1855  {
1856  if (isProcessor)
1857  {
1858  left->Set((samplePtr) outBuffer[0].get(), floatSample, outPos, outputBufferCnt);
1859  if (right)
1860  {
1861  if (chans >= 2)
1862  {
1863  right->Set((samplePtr) outBuffer[1].get(), floatSample, outPos, outputBufferCnt);
1864  }
1865  else
1866  {
1867  right->Set((samplePtr) outBuffer[0].get(), floatSample, outPos, outputBufferCnt);
1868  }
1869  }
1870  }
1871  else if (isGenerator)
1872  {
1873  genLeft->Append((samplePtr) outBuffer[0].get(), floatSample, outputBufferCnt);
1874  if (genRight)
1875  {
1876  genRight->Append((samplePtr) outBuffer[1].get(), floatSample, outputBufferCnt);
1877  }
1878  }
1879  }
1880 
1881  if (rc && isGenerator)
1882  {
1883  auto pProject = FindProject();
1884 
1885  // Transfer the data from the temporary tracks to the actual ones
1886  genLeft->Flush();
1887  // mT1 gives us the NEW selection. We want to replace up to GetSel1().
1888  auto &selectedRegion = ViewInfo::Get( *pProject ).selectedRegion;
1889  auto t1 = selectedRegion.t1();
1890  PasteTimeWarper warper{ t1, mT0 + genLeft->GetEndTime() };
1891  left->ClearAndPaste(mT0, t1, genLeft.get(), true, true,
1892  &warper);
1893 
1894  if (genRight)
1895  {
1896  genRight->Flush();
1897  right->ClearAndPaste(mT0, selectedRegion.t1(),
1898  genRight.get(), true, true, nullptr /* &warper */);
1899  }
1900  }
1901 
1902  } // End scope for cleanup
1903  return rc;
1904 }
1905 
1907 {
1908 }
1909 
1911 {
1912  return;
1913 }
1914 
1916 {
1917  return true;
1918 }
1919 
1921 {
1922  return true;
1923 }
1924 
1925 bool Effect::EnableApply(bool enable)
1926 {
1927  // May be called during initialization, so try to find the dialog
1928  wxWindow *dlg = mUIDialog;
1929  if (!dlg && mUIParent)
1930  {
1931  dlg = wxGetTopLevelParent(mUIParent);
1932  }
1933 
1934  if (dlg)
1935  {
1936  wxWindow *apply = dlg->FindWindow(wxID_APPLY);
1937 
1938  // Don't allow focus to get trapped
1939  if (!enable)
1940  {
1941  wxWindow *focus = dlg->FindFocus();
1942  if (focus == apply)
1943  {
1944  dlg->FindWindow(wxID_CLOSE)->SetFocus();
1945  }
1946  }
1947 
1948  apply->Enable(enable);
1949  }
1950 
1951  EnablePreview(enable);
1952 
1953  return enable;
1954 }
1955 
1956 bool Effect::EnablePreview(bool enable)
1957 {
1958  // May be called during initialization, so try to find the dialog
1959  wxWindow *dlg = mUIDialog;
1960  if (!dlg && mUIParent)
1961  {
1962  dlg = wxGetTopLevelParent(mUIParent);
1963  }
1964 
1965  if (dlg)
1966  {
1967  wxWindow *play = dlg->FindWindow(kPlayID);
1968  if (play)
1969  {
1970  wxWindow *rewind = dlg->FindWindow(kRewindID);
1971  wxWindow *ffwd = dlg->FindWindow(kFFwdID);
1972 
1973  // Don't allow focus to get trapped
1974  if (!enable)
1975  {
1976  wxWindow *focus = dlg->FindFocus();
1977  if (focus && (focus == play || focus == rewind || focus == ffwd))
1978  {
1979  dlg->FindWindow(wxID_CLOSE)->SetFocus();
1980  }
1981  }
1982 
1983  play->Enable(enable);
1984  if (SupportsRealtime())
1985  {
1986  rewind->Enable(enable);
1987  ffwd->Enable(enable);
1988  }
1989  }
1990  }
1991 
1992  return enable;
1993 }
1994 
1995 void Effect::EnableDebug(bool enable)
1996 {
1997  mUIDebug = enable;
1998 }
1999 
2000 void Effect::SetLinearEffectFlag(bool linearEffectFlag)
2001 {
2002  mIsLinearEffect = linearEffectFlag;
2003 }
2004 
2005 void Effect::SetPreviewFullSelectionFlag(bool previewDurationFlag)
2006 {
2007  mPreviewFullSelection = previewDurationFlag;
2008 }
2009 
2010 
2011 void Effect::IncludeNotSelectedPreviewTracks(bool includeNotSelected)
2012 {
2013  mPreviewWithNotSelected = includeNotSelected;
2014 }
2015 
2016 bool Effect::TotalProgress(double frac, const TranslatableString &msg)
2017 {
2018  auto updateResult = (mProgress ?
2019  mProgress->Update(frac, msg) :
2021  return (updateResult != ProgressResult::Success);
2022 }
2023 
2024 bool Effect::TrackProgress(int whichTrack, double frac, const TranslatableString &msg)
2025 {
2026  auto updateResult = (mProgress ?
2027  mProgress->Update(whichTrack + frac, (double) mNumTracks, msg) :
2029  return (updateResult != ProgressResult::Success);
2030 }
2031 
2032 bool Effect::TrackGroupProgress(int whichGroup, double frac, const TranslatableString &msg)
2033 {
2034  auto updateResult = (mProgress ?
2035  mProgress->Update(whichGroup + frac, (double) mNumGroups, msg) :
2037  return (updateResult != ProgressResult::Success);
2038 }
2039 
2041  const WaveTrack &track, const WaveTrack *pRight,
2042  sampleCount *start, sampleCount *len)
2043 {
2044  auto t0 = std::max( mT0, track.GetStartTime() );
2045  auto t1 = std::min( mT1, track.GetEndTime() );
2046 
2047  if ( pRight ) {
2048  t0 = std::min( t0, std::max( mT0, pRight->GetStartTime() ) );
2049  t1 = std::max( t1, std::min( mT1, pRight->GetEndTime() ) );
2050  }
2051 
2052  if (t1 > t0) {
2053  *start = track.TimeToLongSamples(t0);
2054  auto end = track.TimeToLongSamples(t1);
2055  *len = end - *start;
2056  }
2057  else {
2058  *start = 0;
2059  *len = 0;
2060  }
2061 }
2062 
2063 //
2064 // private methods
2065 //
2066 // Use this method to copy the input tracks to mOutputTracks, if
2067 // doing the processing on them, and replacing the originals only on success (and not cancel).
2068 // Copy the group tracks that have tracks selected
2069 // If not all sync-locked selected, then only selected wave tracks.
2070 void Effect::CopyInputTracks(bool allSyncLockSelected)
2071 {
2072  // Reset map
2073  mIMap.clear();
2074  mOMap.clear();
2075 
2077  const_cast<AudacityProject*>( FindProject() ) // how to remove this const_cast?
2078  );
2079 
2080  auto trackRange = mTracks->Any() +
2081  [&] (const Track *pTrack) {
2082  return allSyncLockSelected
2083  ? pTrack->IsSelectedOrSyncLockSelected()
2084  : track_cast<const WaveTrack*>( pTrack ) && pTrack->GetSelected();
2085  };
2086 
2087  t2bHash added;
2088 
2089  for (auto aTrack : trackRange)
2090  {
2091  Track *o = mOutputTracks->Add(aTrack->Duplicate());
2092  mIMap.push_back(aTrack);
2093  mOMap.push_back(o);
2094  }
2095 }
2096 
2097 Track *Effect::AddToOutputTracks(const std::shared_ptr<Track> &t)
2098 {
2099  mIMap.push_back(NULL);
2100  mOMap.push_back(t.get());
2101  return mOutputTracks->Add(t);
2102 }
2103 
2105  : mpEffect(pEffect)
2106 {
2107  LabelTrack::Holder pTrack{ std::make_shared<LabelTrack>() };
2108  mpTrack = pTrack.get();
2109  if (!name.empty())
2110  pTrack->SetName(name);
2111  pEffect->mTracks->Add( pTrack );
2112 }
2113 
2115 {
2116  mpEffect = that.mpEffect;
2117  mpTrack = that.mpTrack;
2118  that.Commit();
2119 }
2120 
2122 {
2123  mpEffect = nullptr;
2124 }
2125 
2127 {
2128  if (mpEffect) {
2129  // not committed -- DELETE the label track
2130  mpEffect->mTracks->Remove(mpTrack);
2131  }
2132 }
2133 
2134 auto Effect::AddAnalysisTrack(const wxString &name) -> std::shared_ptr<AddedAnalysisTrack>
2135 {
2136  return std::shared_ptr<AddedAnalysisTrack>
2137  { safenew AddedAnalysisTrack{ this, name } };
2138 }
2139 
2141  (Effect *pEffect, const LabelTrack *pOrigTrack, const wxString &name)
2142  : mpEffect(pEffect)
2143 {
2144  // copy LabelTrack here, so it can be undone on cancel
2145  auto newTrack = pOrigTrack->Copy(pOrigTrack->GetStartTime(), pOrigTrack->GetEndTime());
2146 
2147  mpTrack = static_cast<LabelTrack*>(newTrack.get());
2148 
2149  // Why doesn't LabelTrack::Copy complete the job? :
2150  mpTrack->SetOffset(pOrigTrack->GetStartTime());
2151  if (!name.empty())
2152  mpTrack->SetName(name);
2153 
2154  // mpOrigTrack came from mTracks which we own but expose as const to subclasses
2155  // So it's okay that we cast it back to const
2156  mpOrigTrack =
2157  pEffect->mTracks->Replace(const_cast<LabelTrack*>(pOrigTrack),
2158  newTrack );
2159 }
2160 
2162 {
2163  mpEffect = that.mpEffect;
2164  mpTrack = that.mpTrack;
2165  mpOrigTrack = std::move(that.mpOrigTrack);
2166  that.Commit();
2167 }
2168 
2170 {
2171  mpEffect = nullptr;
2172 }
2173 
2175 {
2176  if (mpEffect) {
2177  // not committed -- DELETE the label track
2178  // mpOrigTrack came from mTracks which we own but expose as const to subclasses
2179  // So it's okay that we cast it back to const
2180  mpEffect->mTracks->Replace(mpTrack, mpOrigTrack);
2181  }
2182 }
2183 
2185  (const LabelTrack *pOrigTrack, const wxString &name) -> ModifiedAnalysisTrack
2186 {
2187  return{ this, pOrigTrack, name };
2188 }
2189 
2190 // If bGoodResult, replace mTracks tracks with successfully processed mOutputTracks copies.
2191 // Else clear and DELETE mOutputTracks copies.
2192 void Effect::ReplaceProcessedTracks(const bool bGoodResult)
2193 {
2194  if (!bGoodResult) {
2195  // Free resources, unless already freed.
2196 
2197  // Processing failed or was cancelled so throw away the processed tracks.
2198  if ( mOutputTracks )
2199  mOutputTracks->Clear();
2200 
2201  // Reset map
2202  mIMap.clear();
2203  mOMap.clear();
2204 
2205  //TODO:undo the non-gui ODTask transfer
2206  return;
2207  }
2208 
2209  // Assume resources need to be freed.
2210  wxASSERT(mOutputTracks); // Make sure we at least did the CopyInputTracks().
2211 
2212  auto iterOut = mOutputTracks->ListOfTracks::begin(),
2213  iterEnd = mOutputTracks->ListOfTracks::end();
2214 
2215  size_t cnt = mOMap.size();
2216  size_t i = 0;
2217 
2218  for (; iterOut != iterEnd; ++i) {
2219  ListOfTracks::value_type o = *iterOut;
2220  // If tracks were removed from mOutputTracks, then there will be
2221  // tracks in the map that must be removed from mTracks.
2222  while (i < cnt && mOMap[i] != o.get()) {
2223  const auto t = mIMap[i];
2224  if (t) {
2225  mTracks->Remove(t);
2226  }
2227  i++;
2228  }
2229 
2230  // This should never happen
2231  wxASSERT(i < cnt);
2232 
2233  // Remove the track from the output list...don't DELETE it
2234  iterOut = mOutputTracks->erase(iterOut);
2235 
2236  const auto t = mIMap[i];
2237  if (t == NULL)
2238  {
2239  // This track is a NEW addition to output tracks; add it to mTracks
2240  mTracks->Add( o );
2241  }
2242  else
2243  {
2244  // Replace mTracks entry with the NEW track
2245  mTracks->Replace(t, o);
2246  }
2247  }
2248 
2249  // If tracks were removed from mOutputTracks, then there may be tracks
2250  // left at the end of the map that must be removed from mTracks.
2251  while (i < cnt) {
2252  const auto t = mIMap[i];
2253  if (t) {
2254  mTracks->Remove(t);
2255  }
2256  i++;
2257  }
2258 
2259  // Reset map
2260  mIMap.clear();
2261  mOMap.clear();
2262 
2263  // Make sure we processed everything
2264  wxASSERT(mOutputTracks->empty());
2265 
2266  // The output list is no longer needed
2267  mOutputTracks.reset();
2268  nEffectsDone++;
2269 }
2270 
2272 {
2273  if (!inputTracks())
2274  return nullptr;
2275  return inputTracks()->GetOwner();
2276 }
2277 
2279 {
2280  mNumTracks = mTracks->Selected< const WaveTrack >().size();
2281  mNumGroups = mTracks->SelectedLeaders< const WaveTrack >().size();
2282 }
2283 
2284 double Effect::CalcPreviewInputLength(double previewLength)
2285 {
2286  return previewLength;
2287 }
2288 
2290 {
2291  return false;
2292 }
2293 
2294 void Effect::Preview(bool dryOnly)
2295 {
2296  if (mNumTracks == 0) { // nothing to preview
2297  return;
2298  }
2299 
2300  auto gAudioIO = AudioIO::Get();
2301  if (gAudioIO->IsBusy()) {
2302  return;
2303  }
2304 
2305  wxWindow *FocusDialog = wxWindow::FindFocus();
2306 
2307  double previewDuration;
2308  bool isNyquist = GetFamily() == NYQUISTEFFECTS_FAMILY;
2309  bool isGenerator = GetType() == EffectTypeGenerate;
2310 
2311  // Mix a few seconds of audio from all of the tracks
2312  double previewLen;
2313  gPrefs->Read(wxT("/AudioIO/EffectsPreviewLen"), &previewLen, 6.0);
2314 
2315  const double rate = mProjectRate;
2316 
2317  if (isNyquist && isGenerator) {
2318  previewDuration = CalcPreviewInputLength(previewLen);
2319  }
2320  else {
2321  previewDuration = wxMin(mDuration, CalcPreviewInputLength(previewLen));
2322  }
2323 
2324  double t1 = mT0 + previewDuration;
2325 
2326  if ((t1 > mT1) && !isGenerator) {
2327  t1 = mT1;
2328  }
2329 
2330  if (t1 <= mT0)
2331  return;
2332 
2333  bool success = true;
2334 
2335  auto cleanup = finally( [&] {
2336 
2337  // Effect is already inited; we will call Process, End, and then Init
2338  // again, so the state is exactly the way it was before Preview
2339  // was called.
2340  if (!dryOnly) {
2341  End();
2342  GuardedCall( [&]{ Init(); } );
2343  }
2344 
2345  // In case any dialog control depends on mT1 or mDuration:
2346  if ( mUIDialog )
2347  mUIDialog->TransferDataToWindow();
2348  } );
2349 
2350  auto vr0 = valueRestorer( mT0 );
2351  auto vr1 = valueRestorer( mT1 );
2352  // Most effects should stop at t1.
2353  if (!mPreviewFullSelection)
2354  mT1 = t1;
2355 
2356  // In case any dialog control depends on mT1 or mDuration:
2357  if ( mUIDialog ) {
2358  mUIDialog->TransferDataToWindow();
2359  }
2360 
2361  // Save the original track list
2362  TrackList *saveTracks = mTracks;
2363 
2364  auto cleanup2 = finally( [&] {
2365  mTracks = saveTracks;
2366  if (FocusDialog) {
2367  FocusDialog->SetFocus();
2368  }
2369 
2370  // In case of failed effect, be sure to free memory.
2371  ReplaceProcessedTracks( false );
2372  } );
2373 
2374  // Build NEW tracklist from rendering tracks
2375  // Set the same owning project, so FindProject() can see it within Process()
2376  const auto pProject = saveTracks->GetOwner();
2377  auto uTracks = TrackList::Create( pProject );
2378  mTracks = uTracks.get();
2379 
2380  // Linear Effect preview optimised by pre-mixing to one track.
2381  // Generators need to generate per track.
2382  if (mIsLinearEffect && !isGenerator) {
2383  WaveTrack::Holder mixLeft, mixRight;
2384  MixAndRender(saveTracks, mFactory, rate, floatSample, mT0, t1, mixLeft, mixRight);
2385  if (!mixLeft)
2386  return;
2387 
2388  mixLeft->Offset(-mixLeft->GetStartTime());
2389  mixLeft->SetSelected(true);
2390  WaveTrackView::Get( *mixLeft )
2392  auto pLeft = mTracks->Add( mixLeft );
2393  Track *pRight{};
2394  if (mixRight) {
2395  mixRight->Offset(-mixRight->GetStartTime());
2396  mixRight->SetSelected(true);
2397  pRight = mTracks->Add( mixRight );
2398  }
2399  mTracks->GroupChannels(*pLeft, pRight ? 2 : 1);
2400  }
2401  else {
2402  for (auto src : saveTracks->Any< const WaveTrack >()) {
2403  if (src->GetSelected() || mPreviewWithNotSelected) {
2404  auto dest = src->Copy(mT0, t1);
2405  dest->SetSelected(src->GetSelected());
2406  WaveTrackView::Get( *static_cast<WaveTrack*>(dest.get()) )
2408  mTracks->Add( dest );
2409  }
2410  }
2411  }
2412 
2413  // NEW tracks start at time zero.
2414  // Adjust mT0 and mT1 to be the times to process, and to
2415  // play back in these tracks
2416  mT1 -= mT0;
2417  mT0 = 0.0;
2418 
2419  // Update track/group counts
2420  CountWaveTracks();
2421 
2422  // Apply effect
2423  if (!dryOnly) {
2424  ProgressDialog progress{
2425  GetName(),
2426  XO("Preparing preview"),
2428  }; // Have only "Stop" button.
2429  auto vr = valueRestorer( mProgress, &progress );
2430 
2431  auto vr2 = valueRestorer( mIsPreview, true );
2432 
2433  success = Process();
2434  }
2435 
2436  if (success)
2437  {
2438  auto tracks = ProjectAudioManager::GetAllPlaybackTracks(*mTracks, true);
2439 
2440  // Some effects (Paulstretch) may need to generate more
2441  // than previewLen, so take the min.
2442  t1 = std::min(mT0 + previewLen, mT1);
2443 
2444  // Start audio playing
2445  auto options = DefaultPlayOptions(*pProject);
2446  int token =
2447  gAudioIO->StartStream(tracks, mT0, t1, options);
2448 
2449  if (token) {
2450  auto previewing = ProgressResult::Success;
2451  // The progress dialog must be deleted before stopping the stream
2452  // to allow events to flow to the app during StopStream processing.
2453  // The progress dialog blocks these events.
2454  {
2455  ProgressDialog progress
2456  (GetName(), XO("Previewing"), pdlgHideCancelButton);
2457 
2458  while (gAudioIO->IsStreamActive(token) && previewing == ProgressResult::Success) {
2459  ::wxMilliSleep(100);
2460  previewing = progress.Update(gAudioIO->GetStreamTime() - mT0, t1 - mT0);
2461  }
2462  }
2463 
2464  gAudioIO->StopStream();
2465 
2466  while (gAudioIO->IsBusy()) {
2467  ::wxMilliSleep(100);
2468  }
2469  }
2470  else {
2471  using namespace BasicUI;
2473  wxWidgetsWindowPlacement{ FocusDialog }, XO("Error"),
2474  XO("Error opening sound device.\nTry changing the audio host, playback device and the project sample rate."),
2475  wxT("Error_opening_sound_device"),
2476  ErrorDialogOptions{ ErrorDialogType::ModalErrorReport } );
2477  }
2478  }
2479 }
2480 
2482  long style, const TranslatableString &titleStr)
2483 {
2484  auto title = titleStr.empty()
2485  ? GetName()
2486  : XO("%s: %s").Format( GetName(), titleStr );
2487  return AudacityMessageBox( message, title, style, mUIParent );
2488 }
2489 
Effect::mSampleCnt
sampleCount mSampleCnt
Definition: Effect.h:482
Effect::AddedAnalysisTrack::AddedAnalysisTrack
AddedAnalysisTrack()
Definition: Effect.h:387
Effect::GetAutomationParameters
bool GetAutomationParameters(CommandParameters &parms) override
Definition: Effect.cpp:533
FilePath
wxString FilePath
Definition: Identifier.h:227
ShuttleSetAutomation
Shuttle that sets parameters to a value (from a string)
Definition: Shuttle.h:106
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:156
Effect::GetSquashedName
static CommandID GetSquashedName(wxString name)
Definition: Effect.cpp:775
Effect::GetPass
virtual int GetPass()
Definition: Effect.cpp:1355
WaveTrack::Flush
void Flush()
Flush must be called after last Append.
Definition: WaveTrack.cpp:1611
CommandParameters
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
Definition: EffectAutomationParameters.h:67
Effect::DoEffect
bool DoEffect(double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={})
Definition: Effect.cpp:1208
NYQUIST_PROMPT_ID
#define NYQUIST_PROMPT_ID
Definition: PluginManager.h:360
Effect::ModifiedAnalysisTrack::ModifiedAnalysisTrack
ModifiedAnalysisTrack()
TranslatableString::empty
bool empty() const
Definition: TranslatableString.h:72
ShuttleSetAutomation::SetForValidating
void SetForValidating(CommandParameters *pEap)
Definition: Shuttle.h:113
valueRestorer
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
Definition: MemoryX.h:354
PluginManager::RemovePrivateConfigSubgroup
bool RemovePrivateConfigSubgroup(const PluginID &ID, const RegistryPath &group) override
Definition: PluginManager.cpp:638
Effect::mNumTracks
int mNumTracks
Definition: Effect.h:524
Effect::FindProject
const AudacityProject * FindProject() const
Definition: Effect.cpp:2271
EffectClientInterface::SetBlockSize
virtual size_t SetBlockSize(size_t maxBlockSize)=0
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
Effect::GetDuration
double GetDuration() override
Definition: Effect.cpp:815
GuardedCall
R GuardedCall(const F1 &body, const F2 &handler=F2::Default(), std::function< void(AudacityException *)> delayedHandler=DefaultDelayedHandlerAction{})
Execute some code on any thread; catch any AudacityException; enqueue error report on the main thread...
Definition: AudacityException.h:202
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:59
Effect::mUIDialog
wxDialog * mUIDialog
Definition: Effect.h:477
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption=XO("Message"), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: AudacityMessageBox.h:20
EffectClientInterface::RealtimeAddProcessor
virtual bool RealtimeAddProcessor(unsigned numChannels, float sampleRate)=0
Effect::SetLinearEffectFlag
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: Effect.cpp:2000
Effect::AddedAnalysisTrack
Definition: Effect.h:380
Effect::GetMidiInCount
int GetMidiInCount() override
Definition: Effect.cpp:286
BasicUI::ProgressResult::Success
@ Success
make_iterator_range
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:549
Track::RightChannel
static const auto RightChannel
Definition: Track.h:267
Effect::mProgress
ProgressDialog * mProgress
Definition: Effect.h:457
PluginManager::GetSharedConfig
bool GetSharedConfig(const PluginID &ID, const RegistryPath &group, const RegistryPath &key, wxString &value, const wxString &defval=_T("")) override
Definition: PluginManager.cpp:506
EffectClientInterface::RealtimeInitialize
virtual bool RealtimeInitialize()=0
Effect::EnableApply
virtual bool EnableApply(bool enable=true)
Definition: Effect.cpp:1925
WaveTrackViewConstants::NoDisplay
@ NoDisplay
Definition: WaveTrackViewConstants.h:40
Effect::IsInteractive
bool IsInteractive() override
Definition: Effect.cpp:204
Effect::EnableDebug
virtual void EnableDebug(bool enable=true)
Definition: Effect.cpp:1995
Effect::CloseUI
bool CloseUI() override
Definition: Effect.cpp:651
NotifyingSelectedRegion::duration
double duration() const
Definition: ViewInfo.h:51
Effect::GetSelectionFormat
virtual NumericFormatSymbol GetSelectionFormat()
Definition: Effect.cpp:830
EffectHostInterface
EffectHostInterface is a decorator of a EffectUIClientInterface. It adds virtual (abstract) functions...
Definition: EffectInterface.h:121
Effect::ManualPage
virtual ManualPageID ManualPage()
Definition: Effect.cpp:1171
Effect::ImportPresets
void ImportPresets() override
Definition: Effect.cpp:724
Effect.h
Effect::HasFactoryDefaults
virtual bool HasFactoryDefaults()
Definition: Effect.cpp:1166
ComponentInterface::GetSymbol
virtual ComponentInterfaceSymbol GetSymbol()=0
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
Effect::GetBlockSize
size_t GetBlockSize() const override
Definition: Effect.cpp:328
EffectClientInterface::SetSampleRate
virtual void SetSampleRate(double rate)=0
Effect::GetUserPresets
virtual RegistryPaths GetUserPresets()
Definition: Effect.cpp:1150
Effect::AddedAnalysisTrack::mpTrack
LabelTrack * mpTrack
Definition: Effect.h:402
Effect::MessageBox
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
Definition: Effect.cpp:2481
WaveTrack::GetEndTime
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1800
BasicUI::ShowErrorDialog
void ShowErrorDialog(const WindowPlacement &placement, const TranslatableString &dlogTitle, const TranslatableString &message, const ManualPageID &helpPage, const ErrorDialogOptions &options={})
Show an error dialog with a link to the manual for further help.
Definition: BasicUI.h:233
Effect::TransferDataToWindow
virtual bool TransferDataToWindow()
Definition: Effect.cpp:1915
Effect::mDuration
double mDuration
Definition: Effect.h:514
Effect::CopyInputTracks
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:2070
Effect::SupportsRealtime
bool SupportsRealtime() override
Definition: Effect.cpp:234
DefaultPlayOptions
AudioIOStartStreamOptions DefaultPlayOptions(AudacityProject &project)
Definition: ProjectAudioManager.cpp:1000
Effect::GetID
virtual PluginID GetID()
Definition: Effect.cpp:1023
Effect::RealtimeSuspend
bool RealtimeSuspend() override
Definition: Effect.cpp:431
ident
static CommandHandlerObject & ident(AudacityProject &project)
Definition: ModNullCallback.cpp:65
ChannelNameFrontRight
@ ChannelNameFrontRight
Definition: EffectInterface.h:150
Effect
Base class for many of the effects in Audacity.
Definition: Effect.h:72
EffectTypeGenerate
@ EffectTypeGenerate
Definition: EffectInterface.h:58
Effect::VetoDialogHook
bool(*)(wxDialog *) VetoDialogHook
Definition: Effect.h:87
TimeWarper.h
Contains declarations for TimeWarper, IdentityTimeWarper, ShiftTimeWarper, LinearTimeWarper,...
EffectClientInterface::RealtimeFinalize
virtual bool RealtimeFinalize()=0
RegistryPaths
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
PluginPath
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Identifier.h:214
pdlgHideStopButton
@ pdlgHideStopButton
Definition: ProgressDialog.h:38
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1468
EffectClientInterface::ProcessFinalize
virtual bool ProcessFinalize()=0
LabelTrack::GetStartTime
double GetStartTime() const override
Definition: LabelTrack.cpp:316
Format
Abstract base class used in importing a file.
Effect::IsLegacy
bool IsLegacy() override
Definition: Effect.cpp:224
TrackList
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1264
Effect::GetAudioInCount
unsigned GetAudioInCount() override
Definition: Effect.cpp:266
Effect::Effect
Effect()
Definition: Effect.cpp:84
EffectClientInterface::RealtimeProcessEnd
virtual bool RealtimeProcessEnd()=0
Effect::SetPreviewFullSelectionFlag
void SetPreviewFullSelectionFlag(bool previewDurationFlag)
Definition: Effect.cpp:2005
Effect::mT1
double mT1
Definition: Effect.h:467
ArrayOf::reinit
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:57
Effect::LoadUserPreset
bool LoadUserPreset(const RegistryPath &name) override
Definition: Effect.cpp:553
Effect::~Effect
virtual ~Effect()
Definition: Effect.cpp:122
Effect::Delegate
bool Delegate(Effect &delegate, wxWindow &parent, const EffectDialogFactory &factory)
Definition: Effect.cpp:1339
BUILTIN_EFFECT_PREFIX
#define BUILTIN_EFFECT_PREFIX
Definition: Effect.h:43
EffectTypeNone
@ EffectTypeNone
Definition: EffectInterface.h:56
EffectDefinitionInterface::IsInteractive
virtual bool IsInteractive()=0
Effect::mDurationFormat
NumericFormatSymbol mDurationFormat
Definition: Effect.h:515
Effect::ModifyAnalysisTrack
ModifiedAnalysisTrack ModifyAnalysisTrack(const LabelTrack *pOrigTrack, const wxString &name=wxString())
Definition: Effect.cpp:2185
XO
#define XO(s)
Definition: Internat.h:31
Effect::EnablePreview
virtual bool EnablePreview(bool enable=true)
Definition: Effect.cpp:1956
ProjectFileIO::Get
static ProjectFileIO & Get(AudacityProject &project)
Definition: ProjectFileIO.cpp:269
Effect::SetAutomationParameters
bool SetAutomationParameters(CommandParameters &parms) override
Definition: Effect.cpp:543
Effect::IsHidden
virtual bool IsHidden()
Definition: Effect.cpp:2289
Effect::mTracks
TrackList * mTracks
Definition: Effect.h:507
ProjectSettings::Get
static ProjectSettings & Get(AudacityProject &project)
Definition: ProjectSettings.cpp:40
Effect::ProcessFinalize
bool ProcessFinalize() override
Definition: Effect.cpp:378
Effect::SetVetoDialogHook
static VetoDialogHook SetVetoDialogHook(VetoDialogHook hook)
Definition: Effect.cpp:75
PluginManager::GetSharedConfigSubgroups
bool GetSharedConfigSubgroups(const PluginID &ID, const RegistryPath &group, RegistryPaths &subgroups) override
Definition: PluginManager.cpp:501
Effect::SetPrivateConfig
bool SetPrivateConfig(const RegistryPath &group, const RegistryPath &key, const wxString &value) override
Definition: Effect.cpp:986
TrackList::Add
TrackKind * Add(const std::shared_ptr< TrackKind > &t)
Definition: Track.h:1487
PluginManager::RemoveSharedConfig
bool RemoveSharedConfig(const PluginID &ID, const RegistryPath &group, const RegistryPath &key) override
Definition: PluginManager.cpp:567
Effect::mNumAudioIn
size_t mNumAudioIn
Definition: Effect.h:529
LabelTrack
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:88
CommandParameters::GetParameters
bool GetParameters(wxString &parms)
Definition: EffectAutomationParameters.h:258
NYQUISTEFFECTS_FAMILY
#define NYQUISTEFFECTS_FAMILY
Definition: Effect.h:60
Effect::IsBatchProcessing
virtual bool IsBatchProcessing()
Definition: Effect.cpp:1189
Effect::mPass
int mPass
Definition: Effect.h:474
ChannelNameFrontLeft
@ ChannelNameFrontLeft
Definition: EffectInterface.h:149
SelectedRegion::UndefinedFrequency
static const int UndefinedFrequency
Definition: SelectedRegion.h:44
Effect::PopulateUI
bool PopulateUI(ShuttleGui &S) final
Definition: Effect.cpp:621
EffectClientInterface::ProcessBlock
virtual size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen)=0
Effect::SetHost
bool SetHost(EffectHostInterface *host) override
Definition: Effect.cpp:256
ChannelNameEOL
@ ChannelNameEOL
Definition: EffectInterface.h:145
ChannelName
ChannelName
Definition: EffectInterface.h:143
Effect::GetUserPresetsGroup
RegistryPath GetUserPresetsGroup(const RegistryPath &name) override
Definition: Effect.cpp:854
EffectDefinitionInterface::SupportsRealtime
virtual bool SupportsRealtime()=0
Effect::mPreviewFullSelection
bool mPreviewFullSelection
Definition: Effect.h:512
Effect::InitPass2
virtual bool InitPass2()
Definition: Effect.cpp:1365
EffectClientInterface::ShowInterface
virtual bool ShowInterface(wxWindow &parent, const EffectDialogFactory &factory, bool forceModal=false)=0
EffectClientInterface::GetFactoryPresets
virtual RegistryPaths GetFactoryPresets()=0
EffectDefinitionInterface::SupportsAutomation
virtual bool SupportsAutomation()=0
FileNames::AllFiles
AUDACITY_DLL_API const FileType AllFiles
Definition: FileNames.h:74
Effect::AddToOutputTracks
Track * AddToOutputTracks(const std::shared_ptr< Track > &t)
Definition: Effect.cpp:2097
WaveTrack::ClearAndPaste
void ClearAndPaste(double t0, double t1, const Track *src, bool preserve=true, bool merge=true, const TimeWarper *effectWarper=NULL)
Definition: WaveTrack.cpp:748
Effect::SaveUserPreset
bool SaveUserPreset(const RegistryPath &name) override
Definition: Effect.cpp:569
PresetTypes
static const FileNames::FileTypes & PresetTypes()
Definition: Effect.cpp:667
PluginManager::HasPrivateConfigGroup
bool HasPrivateConfigGroup(const PluginID &ID, const RegistryPath &group)
Definition: PluginManager.cpp:578
TrackList::SelectedLeaders
auto SelectedLeaders() -> TrackIterRange< TrackType >
Definition: Track.h:1406
Effect::GetPrivateConfigSubgroups
bool GetPrivateConfigSubgroups(const RegistryPath &group, RegistryPaths &paths) override
Definition: Effect.cpp:956
PluginManager::RemovePrivateConfig
bool RemovePrivateConfig(const PluginID &ID, const RegistryPath &group, const RegistryPath &key) override
Definition: PluginManager.cpp:649
Effect::TransferDataFromWindow
virtual bool TransferDataFromWindow()
Definition: Effect.cpp:1920
t2bHash
std::unordered_map< void *, bool > t2bHash
Definition: Effect.cpp:63
WaveTrack::EmptyCopy
Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory={}) const
Definition: WaveTrack.cpp:572
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterfaceSymbol.h:27
Effect::AddAnalysisTrack
std::shared_ptr< AddedAnalysisTrack > AddAnalysisTrack(const wxString &name=wxString())
Definition: Effect.cpp:2134
Effect::mFactory
WaveTrackFactory * mFactory
Definition: Effect.h:462
NotifyingSelectedRegion::t1
double t1() const
Definition: ViewInfo.h:46
wxWidgetsWindowPlacement
Window placement information for wxWidgetsBasicUI can be constructed from a wxWindow pointer.
Definition: wxWidgetsBasicUI.h:20
Effect::ProcessPass
virtual bool ProcessPass()
Definition: Effect.cpp:1396
ComponentInterface::GetVendor
virtual VendorSymbol GetVendor()=0
Effect::GetMidiOutCount
int GetMidiOutCount() override
Definition: Effect.cpp:296
Effect::mIsBatch
bool mIsBatch
Definition: Effect.h:509
NotifyingSelectedRegion::setTimes
bool setTimes(double t0, double t1)
Definition: ViewInfo.cpp:57
WaveTrack::Set
void Set(constSamplePtr buffer, sampleFormat format, sampleCount start, size_t len)
Definition: WaveTrack.cpp:1981
floatSample
@ floatSample
Definition: SampleFormat.h:34
Effect::HideUI
bool HideUI() override
Definition: Effect.cpp:646
NumericConverter::TimeAndSampleFormat
static NumericFormatSymbol TimeAndSampleFormat()
Definition: NumericTextCtrl.cpp:690
ArraysOf::reinit
void reinit(Integral count)
Definition: MemoryX.h:109
WaveTrack::Holder
std::shared_ptr< WaveTrack > Holder
Definition: WaveTrack.h:94
Effect::End
virtual void End()
Definition: Effect.cpp:1906
Effect::GetAudioOutCount
unsigned GetAudioOutCount() override
Definition: Effect.cpp:276
Effect::SetSampleRate
void SetSampleRate(double rate) override
Definition: Effect.cpp:306
Effect::AddedAnalysisTrack::~AddedAnalysisTrack
~AddedAnalysisTrack()
Definition: Effect.cpp:2126
Effect::RealtimeProcessEnd
bool RealtimeProcessEnd() override
Definition: Effect.cpp:470
Effect::ProcessBlock
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
Definition: Effect.cpp:388
Effect::mProjectRate
double mProjectRate
Definition: Effect.h:458
Effect::mBufferSize
size_t mBufferSize
Definition: Effect.h:532
NumericConverter::DefaultSelectionFormat
static NumericFormatSymbol DefaultSelectionFormat()
Definition: NumericTextCtrl.cpp:688
AudacityException
Base class for exceptions specially processed by the application.
Definition: AudacityException.h:33
EffectClientInterface::RealtimeSuspend
virtual bool RealtimeSuspend()=0
EffectClientInterface::GetAudioOutCount
virtual unsigned GetAudioOutCount()=0
EffectClientInterface::GetMidiOutCount
virtual int GetMidiOutCount()=0
ViewInfo::selectedRegion
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:200
ShuttleParams::mpEap
CommandParameters * mpEap
Definition: Shuttle.h:66
Effect::inputTracks
const TrackList * inputTracks() const
Definition: Effect.h:463
Effect::PopulateOrExchange
virtual void PopulateOrExchange(ShuttleGui &S)
Definition: Effect.cpp:1910
EffectClientInterface::SetAutomationParameters
virtual bool SetAutomationParameters(CommandParameters &parms)=0
ProgressDialog
ProgressDialog Class.
Definition: ProgressDialog.h:51
Effect::mT0
double mT0
Definition: Effect.h:466
factory
static RegisteredToolbarFactory factory
Definition: ControlToolBar.cpp:806
Track::Offset
void Offset(double t)
Definition: Track.h:428
anonymous_namespace{Effect.cpp}::GetVetoDialogHook
Effect::VetoDialogHook & GetVetoDialogHook()
Definition: Effect.cpp:67
ArraysOf< float >
ShuttleGetAutomation
Shuttle that gets parameter values into a string.
Definition: Shuttle.h:88
EffectClientInterface::LoadFactoryDefaults
virtual bool LoadFactoryDefaults()=0
Effect::mpSelectedRegion
wxWeakRef< NotifyingSelectedRegion > mpSelectedRegion
Definition: Effect.h:461
Effect::ValidateUI
bool ValidateUI() override
Definition: Effect.cpp:641
LabelTrack::GetEndTime
double GetEndTime() const override
Definition: LabelTrack.cpp:324
Effect::mIsLinearEffect
bool mIsLinearEffect
Definition: Effect.h:510
Effect::GetFactoryPresets
RegistryPaths GetFactoryPresets() override
Definition: Effect.cpp:585
ComponentInterface::GetPath
virtual PluginPath GetPath()=0
EffectClientInterface::GetMidiInCount
virtual int GetMidiInCount()=0
EffectClientInterface::LoadFactoryPreset
virtual bool LoadFactoryPreset(int id)=0
LabelTrack::SetOffset
void SetOffset(double dOffset) override
Definition: LabelTrack.cpp:146
Effect::LoadFactoryDefaults
bool LoadFactoryDefaults() override
Definition: Effect.cpp:605
Effect::GetLatency
sampleCount GetLatency() override
Definition: Effect.cpp:338
Effect::GetDefaultDuration
double GetDefaultDuration() override
Definition: Effect.cpp:810
EffectClientInterface::SetHost
virtual bool SetHost(EffectHostInterface *host)=0
Effect::GetType
EffectType GetType() override
Definition: Effect.cpp:132
EffectClientInterface::GetTailSize
virtual size_t GetTailSize()=0
PluginID
wxString PluginID
Definition: EffectManager.h:30
PluginManager::SetPrivateConfig
bool SetPrivateConfig(const PluginID &ID, const RegistryPath &group, const RegistryPath &key, const wxString &value) override
Definition: PluginManager.cpp:613
Effect::CheckWhetherSkipEffect
virtual bool CheckWhetherSkipEffect()
Definition: Effect.h:299
Effect::IsReady
bool IsReady() override
Definition: Effect.cpp:358
Effect::SupportsAutomation
bool SupportsAutomation() override
Definition: Effect.cpp:244
Effect::kCurrentSettingsIdent
static const wxString kCurrentSettingsIdent
Definition: Effect.h:539
Effect::ReplaceProcessedTracks
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2192
Effect::RemoveSharedConfigSubgroup
bool RemoveSharedConfigSubgroup(const RegistryPath &group) override
Definition: Effect.cpp:941
name
const TranslatableString name
Definition: Distortion.cpp:98
kPlayID
static const int kPlayID
Definition: Effect.cpp:54
Track::Fallthrough
Continuation<> Fallthrough
Type of arguments passed as optional second parameter to TypeSwitch<void>() cases.
Definition: Track.h:488
Effect::ExportPresets
void ExportPresets() override
Definition: Effect.cpp:676
PluginManager::GetPrivateConfigSubgroups
bool GetPrivateConfigSubgroups(const PluginID &ID, const RegistryPath &group, RegistryPaths &subgroups) override
Definition: PluginManager.cpp:583
ProgressDialog::Update
ProgressResult Update(int value, const TranslatableString &message={})
Definition: ProgressDialog.cpp:1327
QualitySettings::DefaultSampleRate
AUDACITY_DLL_API IntSetting DefaultSampleRate
Definition: QualitySettings.cpp:15
Effect::mNumAudioOut
size_t mNumAudioOut
Definition: Effect.h:530
ShuttleGuiBase::GetParent
wxWindow * GetParent()
Definition: ShuttleGui.h:496
ProjectSettings::GetSelectionFormat
const NumericFormatSymbol & GetSelectionFormat() const
Definition: ProjectSettings.cpp:153
Effect::GetSharedConfig
bool GetSharedConfig(const RegistryPath &group, const RegistryPath &key, wxString &value, const wxString &defval={}) override
Definition: Effect.cpp:891
Track::LeftChannel
static const auto LeftChannel
Definition: Track.h:266
Effect::kUserPresetIdent
static const wxString kUserPresetIdent
Definition: Effect.h:537
Effect::InitPass1
virtual bool InitPass1()
Definition: Effect.cpp:1360
TransactionScope
RAII for a database transaction, possibly nested.
Definition: DBConnection.h:136
Effect::RemovePrivateConfigSubgroup
bool RemovePrivateConfigSubgroup(const RegistryPath &group) override
Definition: Effect.cpp:1011
Effect::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: Effect.cpp:152
EffectDefinitionInterface::GetType
virtual EffectType GetType()=0
Effect::mUIFlags
unsigned mUIFlags
Definition: Effect.h:480
EffectClientInterface::EffectDialogFactory
std::function< wxDialog *(wxWindow &parent, EffectHostInterface *, EffectUIClientInterface *) > EffectDialogFactory
Definition: EffectInterface.h:190
Effect::CalcPreviewInputLength
virtual double CalcPreviewInputLength(double previewLength)
Definition: Effect.cpp:2284
WaveTrack::GetStartTime
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1780
EffectClientInterface::ProcessInitialize
virtual bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL)=0
Effect::TestUIFlags
virtual unsigned TestUIFlags(unsigned mask)
Definition: Effect.cpp:1185
NumericConverter::HoursMinsSecondsFormat
static NumericFormatSymbol HoursMinsSecondsFormat()
Definition: NumericTextCtrl.cpp:694
Effect::HasPrivateConfigGroup
bool HasPrivateConfigGroup(const RegistryPath &group) override
Definition: Effect.cpp:951
Effect::HasSharedConfigGroup
bool HasSharedConfigGroup(const RegistryPath &group) override
Definition: Effect.cpp:881
Effect::mNumChannels
unsigned mNumChannels
Definition: Effect.h:534
ComponentInterface::GetDescription
virtual TranslatableString GetDescription()=0
Effect::RealtimeFinalize
bool RealtimeFinalize() override
Definition: Effect.cpp:421
Effect::mUIDebug
bool mUIDebug
Definition: Effect.h:519
WaveTrack::Append
bool Append(constSamplePtr buffer, sampleFormat format, size_t len, unsigned int stride=1)
Append the sample data to the WaveTrack. You must call Flush() after the last Append.
Definition: WaveTrack.cpp:1544
Setting::ReadWithDefault
bool ReadWithDefault(T *pVar, const T &defaultValue) const
overload of ReadWithDefault returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:134
ChannelNames
enum ChannelName * ChannelNames
Effect::GetFactoryDefaultsGroup
RegistryPath GetFactoryDefaultsGroup() override
Definition: Effect.cpp:870
Effect::SetHostUI
void SetHostUI(EffectUIHostInterface *host) override
Definition: Effect.cpp:617
Effect::mOutputTracks
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:465
title
static const auto title
Definition: UpdateNoticeDialog.cpp:23
Effect::RealtimeAddProcessor
bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override
Definition: Effect.cpp:411
EffectUIHostInterface
EffectUIHostInterface has nothing in it. It is provided so that an Effect can call SetHostUI passing ...
Definition: EffectInterface.h:257
Effect::ModifiedAnalysisTrack::Commit
void Commit()
Definition: Effect.cpp:2169
BasicUI::ErrorDialogOptions
Options for variations of error dialogs; the default is for modal dialogs.
Definition: BasicUI.h:49
NotifyingSelectedRegion::f0
double f0() const
Definition: ViewInfo.h:47
Effect::ShowOptions
void ShowOptions() override
Definition: Effect.cpp:804
Effect::GetCurrentSettingsGroup
RegistryPath GetCurrentSettingsGroup() override
Definition: Effect.cpp:865
WaveTrackFactory
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
Definition: WaveTrack.h:701
Effect::Preview
virtual void Preview(bool dryOnly)
Definition: Effect.cpp:2294
Effect::CanExportPresets
bool CanExportPresets() override
Definition: Effect.cpp:662
RegistryPath
wxString RegistryPath
Definition: Identifier.h:218
kFFwdID
static const int kFFwdID
Definition: Effect.cpp:56
Track::GetSelected
bool GetSelected() const
Definition: Track.h:415
Identifier::GET
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
Definition: Identifier.h:66
Effect::mBlockSize
size_t mBlockSize
Definition: Effect.h:533
Effect::HasOptions
bool HasOptions() override
Definition: Effect.cpp:799
Effect::RealtimeProcess
size_t RealtimeProcess(int group, float **inbuf, float **outbuf, size_t numSamples) override
Definition: Effect.cpp:457
samplePtr
char * samplePtr
Definition: SampleFormat.h:49
EffectClientInterface::GetLatency
virtual sampleCount GetLatency()=0
Effect::Init
virtual bool Init()
Definition: Effect.cpp:1350
Effect::GetVendor
VendorSymbol GetVendor() override
Definition: Effect.cpp:162
Effect::SetDuration
void SetDuration(double duration) override
Definition: Effect.cpp:837
EffectClientInterface
EffectClientInterface provides the ident interface to Effect, and is what makes Effect into a plug-in...
Definition: EffectInterface.h:185
TrackList::GetOwner
AudacityProject * GetOwner()
Definition: Track.h:1299
Effect::ModifiedAnalysisTrack::mpTrack
LabelTrack * mpTrack
Definition: Effect.h:433
id
int id
Definition: WaveTrackControls.cpp:590
Effect::ModifiedAnalysisTrack
Definition: Effect.h:410
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
WaveTrack::GetMaxBlockSize
size_t GetMaxBlockSize() const
Definition: WaveTrack.cpp:1581
PluginManager::GetPrivateConfig
bool GetPrivateConfig(const PluginID &ID, const RegistryPath &group, const RegistryPath &key, wxString &value, const wxString &defval=_T("")) override
Definition: PluginManager.cpp:588
NotifyingSelectedRegion::f1
double f1() const
Definition: ViewInfo.h:48
Effect::RemovePrivateConfig
bool RemovePrivateConfig(const RegistryPath &group, const RegistryPath &key) override
Definition: Effect.cpp:1016
Effect::mIsPreview
bool mIsPreview
Definition: Effect.h:517
Effect::mSampleRate
double mSampleRate
Definition: Effect.h:460
PluginManager::Get
static PluginManager & Get()
Definition: PluginManager.cpp:695
EffectClientInterface::LoadUserPreset
virtual bool LoadUserPreset(const RegistryPath &name)=0
MixAndRender
void MixAndRender(TrackList *tracks, WaveTrackFactory *trackFactory, double rate, sampleFormat format, double startTime, double endTime, WaveTrack::Holder &uLeft, WaveTrack::Holder &uRight)
Mixes together all input tracks, applying any envelopes, amplitude gain, panning, and real-time effec...
Definition: Mix.cpp:43
Effect::mOMap
std::vector< Track * > mOMap
Definition: Effect.h:522
Effect::RealtimeInitialize
bool RealtimeInitialize() override
Definition: Effect.cpp:398
BasicUI
Definition: Export.h:39
Effect::GetFamily
EffectFamilySymbol GetFamily() override
Definition: Effect.cpp:192
WaveTrack::TimeToLongSamples
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: WaveTrack.cpp:1770
key
static const AudacityProject::AttachedObjects::RegisteredFactory key
Definition: CommandManager.cpp:197
TrackList::GroupChannels
void GroupChannels(Track &track, size_t groupSize, bool resetChannels=true)
Define a group of channels starting at the given track.
Definition: Track.cpp:707
EffectClientInterface::IsReady
virtual bool IsReady()=0
FileNames::SelectFile
AUDACITY_DLL_API FilePath SelectFile(Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
Effect::SetPresetParameters
void SetPresetParameters(const wxArrayString *Names, const wxArrayString *Values)
Definition: Effect.h:251
Track::SetName
void SetName(const wxString &n)
Definition: Track.cpp:83
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:478
TaggedIdentifier< CommandIdTag, false >
Effect::RealtimeResume
bool RealtimeResume() override
Definition: Effect.cpp:439
PluginManager::GetID
static PluginID GetID(ModuleInterface *module)
Definition: PluginManager.cpp:1553
Effect::GetDescription
TranslatableString GetDescription() override
Definition: Effect.cpp:182
Effect::CountWaveTracks
void CountWaveTracks()
Definition: Effect.cpp:2278
Effect::ProcessInitialize
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL) override
Definition: Effect.cpp:368
sampleCount
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
Effect::mNumGroups
int mNumGroups
Definition: Effect.h:525
Effect::GetPath
PluginPath GetPath() override
Definition: Effect.cpp:142
kRewindID
static const int kRewindID
Definition: Effect.cpp:55
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:113
Effect::GetBounds
void GetBounds(const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
Definition: Effect.cpp:2040
Effect::IncludeNotSelectedPreviewTracks
void IncludeNotSelectedPreviewTracks(bool includeNotSelected)
Definition: Effect.cpp:2011
Effect::HasCurrentSettings
virtual bool HasCurrentSettings()
Definition: Effect.cpp:1161
Effect::IsDefault
bool IsDefault() override
Definition: Effect.cpp:214
TrackList::Replace
ListOfTracks::value_type Replace(Track *t, const ListOfTracks::value_type &with)
Definition: Track.cpp:758
WaveTrackView::Get
static WaveTrackView & Get(WaveTrack &track)
Definition: WaveTrackView.cpp:771
Effect::IsGraphicalUI
bool IsGraphicalUI() override
Definition: Effect.cpp:636
Effect::HelpPage
virtual FilePath HelpPage()
Definition: Effect.cpp:1176
wxWidgetsBasicUI.h
Implementation of BasicUI using wxWidgets.
EffectClientInterface::GetAudioInCount
virtual unsigned GetAudioInCount()=0
Effect::ProcessTrack
bool ProcessTrack(int count, ChannelNames map, WaveTrack *left, WaveTrack *right, sampleCount start, sampleCount len, FloatBuffers &inBuffer, FloatBuffers &outBuffer, ArrayOf< float * > &inBufPos, ArrayOf< float * > &outBufPos)
Definition: Effect.cpp:1544
ComponentInterfaceSymbol::Internal
const wxString & Internal() const
Definition: ComponentInterfaceSymbol.h:55
Effect::nEffectsDone
static int nEffectsDone
Definition: Effect.h:376
Effect::SetSharedConfig
bool SetSharedConfig(const RegistryPath &group, const RegistryPath &key, const wxString &value) override
Definition: Effect.cpp:916
EffectClientInterface::GetBlockSize
virtual size_t GetBlockSize() const =0
ExceptionType::Internal
@ Internal
Indicates internal failure from Audacity.
TrackList::Create
static std::shared_ptr< TrackList > Create(AudacityProject *pOwner)
Definition: Track.cpp:512
ShuttleSetAutomation::bOK
bool bOK
Definition: Shuttle.h:108
Effect::TotalProgress
bool TotalProgress(double frac, const TranslatableString &={})
Definition: Effect.cpp:2016
Effect::RealtimeProcessStart
bool RealtimeProcessStart() override
Definition: Effect.cpp:447
EffectClientInterface::RealtimeProcess
virtual size_t RealtimeProcess(int group, float **inBuf, float **outBuf, size_t numSamples)=0
Effect::GetSharedConfigSubgroups
bool GetSharedConfigSubgroups(const RegistryPath &group, RegistryPaths &subgroups) override
Definition: Effect.cpp:886
ProjectAudioManager::GetAllPlaybackTracks
static TransportTracks GetAllPlaybackTracks(TrackList &trackList, bool selectedOnly, bool useMidi=false)
Definition: ProjectAudioManager.cpp:1036
Effect::ModifiedAnalysisTrack::~ModifiedAnalysisTrack
~ModifiedAnalysisTrack()
Definition: Effect.cpp:2174
FileNames::FileTypes
std::vector< FileType > FileTypes
Definition: FileNames.h:79
Effect::GetDurationFormat
NumericFormatSymbol GetDurationFormat() override
Definition: Effect.cpp:825
NotifyingSelectedRegion::t0
double t0() const
Definition: ViewInfo.h:45
PluginManager::RemoveSharedConfigSubgroup
bool RemoveSharedConfigSubgroup(const PluginID &ID, const RegistryPath &group) override
Definition: PluginManager.cpp:556
params
EffectDistortion::Params params
Definition: Distortion.cpp:99
Effect::GetSavedStateGroup
virtual wxString GetSavedStateGroup()
Definition: Effect.cpp:875
Effect::kFactoryDefaultsIdent
static const wxString kFactoryDefaultsIdent
Definition: Effect.h:540
TrackList::Any
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1355
TrackList::Remove
TrackNodePointer Remove(Track *t)
Remove the Track and return an iterator to what followed it.
Definition: Track.cpp:780
Effect::Startup
virtual bool Startup()
Definition: Effect.cpp:1061
EffectClientInterface::GetAutomationParameters
virtual bool GetAutomationParameters(CommandParameters &parms)=0
ComponentInterface::GetName
TranslatableString GetName()
Definition: PluginManager.cpp:2083
TransactionScope::Commit
bool Commit()
Definition: DBConnection.cpp:658
ChannelNameMono
@ ChannelNameMono
Definition: EffectInterface.h:147
EffectClientInterface::RealtimeResume
virtual bool RealtimeResume()=0
ComponentInterface::GetVersion
virtual wxString GetVersion()=0
AudioIO::Get
static AudioIO * Get()
Definition: AudioIO.cpp:505
EffectClientInterface::RealtimeProcessStart
virtual bool RealtimeProcessStart()=0
EffectType
EffectType
Definition: EffectInterface.h:55
safenew
#define safenew
Definition: MemoryX.h:10
QUANTIZED_TIME
#define QUANTIZED_TIME(time, rate)
Definition: MemoryX.h:626
Effect::GetPrivateConfig
bool GetPrivateConfig(const RegistryPath &group, const RegistryPath &key, wxString &value, const wxString &defval={}) override
Definition: Effect.cpp:961
Effect::kFactoryPresetIdent
static const wxString kFactoryPresetIdent
Definition: Effect.h:538
LabelTrack::Copy
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: LabelTrack.cpp:694
WaveTrackView::SetDisplay
void SetDisplay(Display display, bool exclusive=true)
Definition: WaveTrackView.cpp:871
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:21
Effect::ModifiedAnalysisTrack::mpOrigTrack
std::shared_ptr< Track > mpOrigTrack
Definition: Effect.h:434
Effect::ShowInterface
bool ShowInterface(wxWindow &parent, const EffectDialogFactory &factory, bool forceModal=false) override
Definition: Effect.cpp:480
ComponentInterface::DefineParams
virtual bool DefineParams(ShuttleParams &WXUNUSED(S))
Definition: ComponentInterface.h:85
EffectDefinitionInterface::GetFamily
virtual EffectFamilySymbol GetFamily()=0
Effect::TrackGroupProgress
bool TrackGroupProgress(int whichGroup, double frac, const TranslatableString &={})
Definition: Effect.cpp:2032
PasteTimeWarper
Unit slope but with either a jump (pasting more) or a flat interval (pasting less)
Definition: TimeWarper.h:181
Effect::SetBlockSize
size_t SetBlockSize(size_t maxBlockSize) override
Definition: Effect.cpp:316
WaveTrack::GetFloats
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Retrieve samples from a track in floating-point format, regardless of the storage format.
Definition: WaveTrack.h:261
Effect::mIMap
std::vector< Track * > mIMap
Definition: Effect.h:521
TrackList::Selected
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1372
WaveTrackFactory::NewWaveTrack
std::shared_ptr< WaveTrack > NewWaveTrack(sampleFormat format=(sampleFormat) 0, double rate=0)
Definition: WaveTrack.cpp:85
Effect::TrackProgress
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={})
Definition: Effect.cpp:2024
ArrayOf
Memory.h template class for making an array of float, bool, etc.
Definition: MemoryX.h:27
ShuttleSetAutomation::SetForWriting
void SetForWriting(CommandParameters *pEap)
Definition: Shuttle.h:114
Effect::GetVersion
wxString GetVersion() override
Definition: Effect.cpp:172
Effect::Process
virtual bool Process()
Definition: Effect.cpp:1370
Effect::mPreviewWithNotSelected
bool mPreviewWithNotSelected
Definition: Effect.h:511
PluginManager::SetSharedConfig
bool SetSharedConfig(const PluginID &ID, const RegistryPath &group, const RegistryPath &key, const wxString &value) override
Definition: PluginManager.cpp:531
pdlgHideCancelButton
@ pdlgHideCancelButton
Definition: ProgressDialog.h:39
EffectClientInterface::SaveUserPreset
virtual bool SaveUserPreset(const RegistryPath &name)=0
PluginManager::HasSharedConfigGroup
bool HasSharedConfigGroup(const PluginID &ID, const RegistryPath &group)
Definition: PluginManager.cpp:496
Effect::mClient
EffectClientInterface * mClient
Definition: Effect.h:528
EffectDefinitionInterface::IsDefault
virtual bool IsDefault()=0
Effect::GetTailSize
size_t GetTailSize() override
Definition: Effect.cpp:348
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
LabelTrack::Holder
std::shared_ptr< LabelTrack > Holder
Definition: LabelTrack.h:105
Effect::LoadFactoryPreset
bool LoadFactoryPreset(int id) override
Definition: Effect.cpp:595
Effect::AddedAnalysisTrack::Commit
void Commit()
Definition: Effect.cpp:2121
Effect::RemoveSharedConfig
bool RemoveSharedConfig(const RegistryPath &group, const RegistryPath &key) override
Definition: Effect.cpp:946
Effect::SetBatchProcessing
virtual void SetBatchProcessing(bool start)
Definition: Effect.cpp:1194
NotifyingSelectedRegion
Definition: ViewInfo.h:42
WaveTrack::GetRate
double GetRate() const
Definition: WaveTrack.cpp:358
Effect::SetUIFlags
virtual void SetUIFlags(unsigned flags)
Definition: Effect.cpp:1181