Audacity  3.0.3
EffectsPrefs.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  EffectsPrefs.cpp
6 
7  Brian Gunlogson
8  Joshua Haberman
9  Dominic Mazzoni
10  James Crook
11 
12 
13 *******************************************************************//*******************************************************************/
19 
20 
21 #include "EffectsPrefs.h"
22 
23 #include <wx/choice.h>
24 #include <wx/defs.h>
25 
26 #include "../Languages.h"
27 #include "../PluginManager.h"
28 #include "../Prefs.h"
29 #include "../ShuttleGui.h"
30 
31 EffectsPrefs::EffectsPrefs(wxWindow * parent, wxWindowID winid)
32 : PrefsPanel(parent, winid, XO("Effects"))
33 {
34  Populate();
35 }
36 
38 {
39 }
40 
42 {
44 }
45 
47 {
48  return XO("Preferences for Effects");
49 }
50 
52 {
53  return "Effects_Preferences";
54 }
55 
57 {
58  //------------------------- Main section --------------------
59  // Now construct the GUI itself.
60  // Use 'eIsCreatingFromPrefs' so that the GUI is
61  // initialised with values from gPrefs.
64  // ----------------------- End of main section --------------
65 }
66 
68  wxT("/Effects/GroupBy"),
69  {
70  ByColumns,
71  {
72  XO("Sorted by Effect Name") ,
73  XO("Sorted by Publisher and Effect Name") ,
74  XO("Sorted by Type and Effect Name") ,
75  XO("Grouped by Publisher") ,
76  XO("Grouped by Type") ,
77  },
78  {
79  wxT("sortby:name") ,
80  wxT("sortby:publisher:name") ,
81  wxT("sortby:type:name") ,
82  wxT("groupby:publisher") ,
83  wxT("groupby:type") ,
84  }
85  },
86  0 // "sortby:name"
87 };
88 
89 namespace {
90 
91 // Rather than hard-code an exhaustive list of effect families in this file,
92 // pretend we don't know, but discover them instead by querying the module and
93 // effect managers.
94 
95 // But then we would like to have prompts with accelerator characters that are
96 // distinct. We collect some prompts in the following map.
97 
98 // It is not required that each module be found here, nor that each module
99 // mentioned here be found.
100 const std::map< wxString, TranslatableString > SuggestedPrompts{
101 
102 /* i18n-hint: Audio Unit is the name of an Apple audio software protocol */
103  { wxT("AudioUnit"), XXO("Audio Unit") },
104 
105 /* i18n-hint: abbreviates "Linux Audio Developer's Simple Plugin API"
106  (Application programming interface)
107  */
108  { wxT("LADSPA"), XXO("&LADSPA") },
109 
110 /* i18n-hint: abbreviates
111  "Linux Audio Developer's Simple Plugin API (LADSPA) version 2" */
112  { wxT("LV2"), XXO("LV&2") },
113 
114 /* i18n-hint: "Nyquist" is an embedded interpreted programming language in
115  Audacity, named in honor of the Swedish-American Harry Nyquist (or Nyqvist).
116  In the translations of this and other strings, you may transliterate the
117  name into another alphabet. */
118  { wxT("Nyquist"), XXO("N&yquist") },
119 
120 /* i18n-hint: Vamp is the proper name of a software protocol for sound analysis.
121  It is not an abbreviation for anything. See http://vamp-plugins.org */
122  { wxT("Vamp"), XXO("&Vamp") },
123 
124 /* i18n-hint: Abbreviates Virtual Studio Technology, an audio software protocol
125  developed by Steinberg GmbH */
126  { wxT("VST"), XXO("V&ST") },
127 
128 };
129 
130 // Collect needed prompts and settings paths, at most once, on demand
131 struct Entry {
133  wxString setting;
134 };
135 static const std::vector< Entry > &GetModuleData()
136 {
137  struct ModuleData : public std::vector< Entry > {
138  ModuleData() {
139  auto &pm = PluginManager::Get();
140  for (auto plug = pm.GetFirstPlugin(PluginTypeModule);
141  plug;
142  plug = pm.GetNextPlugin(PluginTypeModule)) {
143  auto internal = plug->GetEffectFamily();
144  if ( internal.empty() )
145  continue;
146 
147  TranslatableString prompt;
148  auto iter = SuggestedPrompts.find( internal );
149  if ( iter == SuggestedPrompts.end() )
150  // For the built-in modules this Msgid includes " Effects",
151  // but those strings were never shown to the user,
152  // and the prompts in the table above do not include it.
153  // If there should be new modules, it is not important for them
154  // to follow the " Effects" convention, but instead they can
155  // have shorter msgids.
156  prompt = plug->GetSymbol().Msgid();
157  else
158  prompt = iter->second;
159 
160  auto setting = pm.GetPluginEnabledSetting( *plug );
161 
162  push_back( { prompt, setting } );
163  }
164  // Guarantee some determinate ordering
165  std::sort( begin(), end(),
166  []( const Entry &a, const Entry &b ){
167  return a.setting < b.setting;
168  }
169  );
170  }
171  };
172  static ModuleData theData;
173  return theData;
174 }
175 
176 }
177 
179 {
180  S.SetBorder(2);
181  S.StartScroller();
182 
183  S.StartStatic(XO("Enable Effects"));
184  {
185  for ( const auto &entry : GetModuleData() )
186  {
187  S.TieCheckBox(
188  entry.prompt,
189  {entry.setting,
190  true}
191  );
192  }
193  }
194  S.EndStatic();
195 
196  S.StartStatic(XO("Effect Options"));
197  {
198  S.StartMultiColumn(2);
199  {
200  wxChoice *c = S
201  .MinSize()
202  .TieChoice( XXO("S&ort or Group:"), EffectsGroupBy);
203 
204  S.TieIntegerTextBox(XXO("&Maximum effects per group (0 to disable):"),
205  {wxT("/Effects/MaxPerGroup"),
206 #if defined(__WXGTK__)
207  15
208 #else
209  0
210 #endif
211  },
212  5);
213  }
214  S.EndMultiColumn();
215  }
216  S.EndStatic();
217 
218 #ifndef EXPERIMENTAL_EFFECT_MANAGEMENT
219  S.StartStatic(XO("Plugin Options"));
220  {
221  S.TieCheckBox(XXO("Check for updated plugins when Audacity starts"),
222  {wxT("/Plugins/CheckForUpdates"),
223  true});
224  S.TieCheckBox(XXO("Rescan plugins next time Audacity is started"),
225  {wxT("/Plugins/Rescan"),
226  false});
227  }
228  S.EndStatic();
229 #endif
230 
231 #ifdef EXPERIMENTAL_EQ_SSE_THREADED
232  S.StartStatic(XO("Instruction Set"));
233  {
234  S.TieCheckBox(XXO("&Use SSE/SSE2/.../AVX"),
235  {wxT("/SSE/GUI"),
236  true});
237  }
238  S.EndStatic();
239 #endif
240  S.EndScroller();
241 }
242 
244 {
245  ShuttleGui S(this, eIsSavingToPrefs);
247 
248  return true;
249 }
250 
251 namespace{
253  [](wxWindow *parent, wxWindowID winid, AudacityProject *)
254  {
255  wxASSERT(parent); // to justify safenew
256  return safenew EffectsPrefs(parent, winid);
257  }
258 };
259 }
TranslatableString
Definition: Types.h:290
EffectsPrefs::~EffectsPrefs
~EffectsPrefs()
Definition: EffectsPrefs.cpp:37
ShuttleGuiBase::TieIntegerTextBox
virtual wxTextCtrl * TieIntegerTextBox(const TranslatableString &Prompt, const SettingSpec< int > &Setting, const int nChars)
Definition: ShuttleGui.cpp:1906
anonymous_namespace{EffectsPrefs.cpp}::SuggestedPrompts
const std::map< wxString, TranslatableString > SuggestedPrompts
Definition: EffectsPrefs.cpp:100
ShuttleGuiBase::TieCheckBox
wxCheckBox * TieCheckBox(const TranslatableString &Prompt, bool &Var)
Definition: ShuttleGui.cpp:1603
EffectsPrefs::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: EffectsPrefs.cpp:178
EffectsPrefs::Populate
void Populate()
Definition: EffectsPrefs.cpp:56
PrefsPanel::Registration
Definition: PrefsPanel.h:83
ShuttleGui::MinSize
ShuttleGui & MinSize()
Definition: ShuttleGui.h:740
XO
#define XO(s)
Definition: Internat.h:32
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1212
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterface.h:60
PluginTypeModule
@ PluginTypeModule
Definition: PluginManager.h:40
ShuttleGuiBase::EndScroller
void EndScroller()
Definition: ShuttleGui.cpp:964
EffectsPrefs::EffectsPrefs
EffectsPrefs(wxWindow *parent, wxWindowID winid)
Definition: EffectsPrefs.cpp:31
ChoiceSetting
Definition: Prefs.h:90
EFFECTS_PREFS_PLUGIN_SYMBOL
#define EFFECTS_PREFS_PLUGIN_SYMBOL
Definition: EffectsPrefs.h:23
XXO
#define XXO(s)
Definition: Internat.h:45
ShuttleGuiBase::StartScroller
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:931
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1203
EffectsPrefs::Commit
bool Commit() override
Definition: EffectsPrefs.cpp:243
EffectsPrefs::GetDescription
TranslatableString GetDescription() override
Definition: EffectsPrefs.cpp:46
anonymous_namespace{EffectsPrefs.cpp}::Entry::prompt
TranslatableString prompt
Definition: EffectsPrefs.cpp:132
EffectsPrefs.h
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:886
eIsSavingToPrefs
@ eIsSavingToPrefs
Definition: ShuttleGui.h:46
anonymous_namespace{EffectsPrefs.cpp}::Entry::setting
wxString setting
Definition: EffectsPrefs.cpp:133
PluginManager::Get
static PluginManager & Get()
Definition: PluginManager.cpp:1761
EffectsPrefs
A PrefsPanel for general GUI preferences.
Definition: EffectsPrefs.h:26
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:112
anonymous_namespace{EffectsPrefs.cpp}::Entry
Definition: EffectsPrefs.cpp:131
anonymous_namespace{EffectsPrefs.cpp}::GetModuleData
static const std::vector< Entry > & GetModuleData()
Definition: EffectsPrefs.cpp:135
PrefsPanel
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:50
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:497
ByColumns
ByColumns_t ByColumns
Definition: Prefs.cpp:373
eIsCreatingFromPrefs
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:45
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:915
safenew
#define safenew
Definition: MemoryX.h:8
anonymous_namespace{EffectsPrefs.cpp}::sAttachment
PrefsPanel::Registration sAttachment
Definition: EffectsPrefs.cpp:252
EffectsPrefs::HelpPageName
wxString HelpPageName() override
Definition: EffectsPrefs.cpp:51
ShuttleGuiBase::TieChoice
wxChoice * TieChoice(const TranslatableString &Prompt, TranslatableString &Selected, const TranslatableStrings &choices)
Definition: ShuttleGui.cpp:1701
EffectsPrefs::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: EffectsPrefs.cpp:41
EffectsGroupBy
ChoiceSetting EffectsGroupBy
Definition: EffectsPrefs.cpp:67
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:638