Audacity 3.2.0
LV2Preferences.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 LV2Preferences.cpp
6
7 Paul Licameli split from LV2Effect.cpp
8
9 Audacity(R) is copyright (c) 1999-2008 Audacity Team.
10 License: GPL v2 or later. See License.txt.
11
12**********************************************************************/
13
14#if defined(USE_LV2)
15
16#if defined(__GNUC__)
17#pragma GCC diagnostic ignored "-Wparentheses"
18#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
19#elif defined(__clang__)
20#pragma clang diagnostic ignored "-Wparentheses"
21#pragma clang diagnostic ignored "-Wdeprecated-declarations"
22#endif
23
24#include "LV2Preferences.h"
25#include "ConfigInterface.h"
26#include "ShuttleGui.h"
27#include "../../widgets/valnum.h"
28
29static constexpr auto SettingsStr = L"Settings";
30static constexpr auto BufferSizeStr = L"BufferSize";
31static constexpr auto UseLatencyStr = L"UseLatency";
32static constexpr auto UseGUIStr = L"UseGUI";
33
34namespace {
35template<typename T>
36bool GetSetting(const EffectDefinitionInterface &effect, const wchar_t *path,
37 T& var, const T &defaultValue)
38{
39 return GetConfig(effect, PluginSettings::Shared, SettingsStr, path,
40 var, defaultValue);
41}
42
43template<typename T>
44bool SetSetting(EffectDefinitionInterface &effect, const wchar_t *path,
45 const T& value)
46{
47 return SetConfig(effect, PluginSettings::Shared, SettingsStr, path,
48 value);
49}
50}
51
53 const EffectDefinitionInterface &effect, int &bufferSize)
54{
55 return GetSetting(effect, BufferSizeStr, bufferSize, 8192);
56}
57
59 EffectDefinitionInterface &effect, int bufferSize)
60{
61 return SetSetting(effect, BufferSizeStr, bufferSize);
62}
63
65 const EffectDefinitionInterface &effect, bool &useLatency)
66{
67 return GetSetting(effect, UseLatencyStr, useLatency, true);
68}
69
71 EffectDefinitionInterface &effect, bool useLatency)
72{
73 return SetSetting(effect, UseLatencyStr, useLatency);
74}
75
77 const EffectDefinitionInterface &effect, bool &useGUI)
78{
79 return GetSetting(effect, UseGUIStr, useGUI, true);
80}
81
83 EffectDefinitionInterface &effect, bool useGUI)
84{
85 return SetSetting(effect, UseGUIStr, useGUI);
86}
87
91
93 wxWindow *parent, EffectDefinitionInterface &effect)
94: wxDialogWrapper(parent, wxID_ANY, XO("LV2 Effect Settings"))
95, mEffect{ effect }
96{
97 using namespace LV2Preferences;
98 GetBufferSize(mEffect, mBufferSize);
99 GetUseLatency(mEffect, mUseLatency);
100 GetUseGUI(mEffect, mUseGUI);
101 ShuttleGui S(this, eIsCreating);
102 PopulateOrExchange(S);
103}
104
106{
107}
108
110{
111 S.SetBorder(5);
112 S.StartHorizontalLay(wxEXPAND, 1);
113 {
114 S.StartVerticalLay(false);
115 {
116 // This really shouldn't be required for LV2 plugins because they have the ability
117 // to specify their exact requirements in the TTL file and/or to check the host
118 // supplied min/max values. However, I've run across one (Harrison Consoles XT-EQ)
119 // that crashed on sizes greater than 8192.
120 S.StartStatic(XO("Buffer Size"));
121 {
122 IntegerValidator<int> vld(&mBufferSize);
123 vld.SetRange(8, DEFAULT_BLOCKSIZE);
124
125 S.AddVariableText( XO(
126"The buffer size controls the number of samples sent to the effect "
127"on each iteration. Smaller values will cause slower processing and "
128"some effects require 8192 samples or less to work properly. However "
129"most effects can accept large buffers and using them will greatly "
130"reduce processing time."),
131 false, 0, 650);
132
133 S.StartHorizontalLay(wxALIGN_LEFT);
134 {
135 wxTextCtrl *t;
136 t = S.TieNumericTextBox(
137 XXO("&Buffer Size (8 to %d) samples:")
139 mBufferSize,
140 12);
141 t->SetMinSize(wxSize(100, -1));
142 t->SetValidator(vld);
143 }
144 S.EndHorizontalLay();
145 }
146 S.EndStatic();
147
148 S.StartStatic(XO("Latency Compensation"));
149 {
150 S.AddVariableText( XO(
151"As part of their processing, some LV2 effects must delay returning "
152"audio to Audacity. When not compensating for this delay, you will "
153"notice that small silences have been inserted into the audio. "
154"Enabling this setting will provide that compensation, but it may "
155"not work for all LV2 effects."),
156 false, 0, 650);
157
158 S.StartHorizontalLay(wxALIGN_LEFT);
159 {
160 S.TieCheckBox(XXO("Enable &compensation"),
161 mUseLatency);
162 }
163 S.EndHorizontalLay();
164 }
165 S.EndStatic();
166
167 S.StartStatic(XO("Graphical Mode"));
168 {
169 S.AddVariableText( XO(
170"LV2 effects can have a graphical interface for setting parameter values."
171" A basic text-only method is also available. "
172" Reopen the effect for this to take effect."),
173 false, 0, 650);
174 S.TieCheckBox(XXO("Enable &graphical interface"),
175 mUseGUI);
176 }
177 S.EndStatic();
178 }
179 S.EndVerticalLay();
180 }
181 S.EndHorizontalLay();
182
183 S.AddStandardButtons();
184
185 Layout();
186 Fit();
187 Center();
188}
189
190void LV2Preferences::Dialog::OnOk(wxCommandEvent &WXUNUSED(evt))
191{
192 if (!Validate())
193 {
194 return;
195 }
196
198 PopulateOrExchange(S);
199
200 using namespace LV2Preferences;
201 SetBufferSize(mEffect, mBufferSize);
202 SetUseLatency(mEffect, mUseLatency);
203 SetUseGUI(mEffect, mUseGUI);
204
205 EndModal(wxID_OK);
206}
207
208#endif
END_EVENT_TABLE()
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
#define XXO(s)
Definition: Internat.h:44
#define XO(s)
Definition: Internat.h:31
static constexpr auto BufferSizeStr
static constexpr auto SettingsStr
static constexpr auto UseLatencyStr
static constexpr auto UseGUIStr
@ eIsCreating
Definition: ShuttleGui.h:39
@ eIsGettingFromDialog
Definition: ShuttleGui.h:40
#define S(N)
Definition: ToChars.cpp:64
EffectDefinitionInterface is a ComponentInterface that adds some basic read-only information about ef...
Base class for many of the effects in Audacity.
Definition: Effect.h:63
Abstract base class used in importing a file.
void OnOk(wxCommandEvent &evt)
void PopulateOrExchange(ShuttleGui &S)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628
bool GetUseGUI(const EffectDefinitionInterface &effect, bool &useGUI)
constexpr auto DEFAULT_BLOCKSIZE
Maximum block size in number of samples (not bytes)
bool SetUseLatency(EffectDefinitionInterface &effect, bool useLatency)
bool GetUseLatency(const EffectDefinitionInterface &effect, bool &useLatency)
bool SetBufferSize(EffectDefinitionInterface &effect, int bufferSize)
bool GetBufferSize(const EffectDefinitionInterface &effect, int &bufferSize)
bool SetUseGUI(EffectDefinitionInterface &effect, bool useGUI)
bool SetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, const Value &value)
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)
bool GetSetting(const EffectDefinitionInterface &effect, const wchar_t *path, T &var, const T &defaultValue)
bool SetSetting(EffectDefinitionInterface &effect, const wchar_t *path, const T &value)