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
27static constexpr auto SettingsStr = L"Settings";
28static constexpr auto BufferSizeStr = L"BufferSize";
29static constexpr auto UseLatencyStr = L"UseLatency";
30static constexpr auto UseGUIStr = L"UseGUI";
31
32namespace {
33template<typename T>
34bool GetSetting(const EffectDefinitionInterface &effect, const wchar_t *path,
35 T& var, const T &defaultValue)
36{
37 return GetConfig(effect, PluginSettings::Shared, SettingsStr, path,
38 var, defaultValue);
39}
40
41template<typename T>
42bool SetSetting(const EffectDefinitionInterface &effect, const wchar_t *path,
43 const T& value)
44{
45 return SetConfig(effect, PluginSettings::Shared, SettingsStr, path,
46 value);
47}
48}
49
51 const EffectDefinitionInterface &effect, int &bufferSize)
52{
53 return GetSetting(effect, BufferSizeStr, bufferSize, 8192);
54}
55
57 const EffectDefinitionInterface &effect, int bufferSize)
58{
59 return SetSetting(effect, BufferSizeStr, bufferSize);
60}
61
63 const EffectDefinitionInterface &effect, bool &useLatency)
64{
65 return GetSetting(effect, UseLatencyStr, useLatency, true);
66}
67
69 const EffectDefinitionInterface &effect, bool useLatency)
70{
71 return SetSetting(effect, UseLatencyStr, useLatency);
72}
73
75 const EffectDefinitionInterface &effect, bool &useGUI)
76{
77 return GetSetting(effect, UseGUIStr, useGUI, true);
78}
79
81 const EffectDefinitionInterface &effect, bool useGUI)
82{
83 return SetSetting(effect, UseGUIStr, useGUI);
84}
85
86#endif
static constexpr auto BufferSizeStr
static constexpr auto SettingsStr
static constexpr auto UseLatencyStr
static constexpr auto UseGUIStr
EffectDefinitionInterface is a ComponentInterface that adds some basic read-only information about ef...
LV2_API bool GetUseGUI(const EffectDefinitionInterface &effect, bool &useGUI)
LV2_API bool GetUseLatency(const EffectDefinitionInterface &effect, bool &useLatency)
LV2_API bool SetBufferSize(const EffectDefinitionInterface &effect, int bufferSize)
LV2_API bool SetUseLatency(const EffectDefinitionInterface &effect, bool useLatency)
LV2_API bool SetUseGUI(const EffectDefinitionInterface &effect, bool useGUI)
LV2_API bool GetBufferSize(const EffectDefinitionInterface &effect, int &bufferSize)
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 SetSetting(const EffectDefinitionInterface &effect, const wchar_t *path, const T &value)
bool GetSetting(const EffectDefinitionInterface &effect, const wchar_t *path, T &var, const T &defaultValue)