Audacity 3.2.0
VST3Effect.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file VST3Effect.cpp
6
7 @author Vitaly Sverchinsky
8
9 @brief Part of Audacity VST3 module
10
11**********************************************************************/
12
13#include "VST3Effect.h"
14
15#include <wx/log.h>
16
17#include "internal/PlugFrame.h"
19
20#include "SelectFile.h"
21
22#include "ShuttleGui.h"
23
25#include "VST3OptionsDialog.h"
26#include "VST3Wrapper.h"
27
28#include "ConfigInterface.h"
29#include "VST3Instance.h"
30#include "VST3Editor.h"
31#include "VST3EffectsModule.h"
32
33
35{
36 using namespace Steinberg;
37
38 CloseUI();
39}
40
42 wxWindow& parent, wxDialog& dialog,
43 EffectEditor *pEditor, bool forceModal) const
44{
45#ifdef __WXMSW__
46 if(pEditor->IsGraphicalUI())
47 //Not all platforms support window style change.
48 //Plugins that support resizing provide their own handles,
49 //which may overlap with system handle. Not all plugins
50 //support free sizing (e.g. fixed steps or fixed ratio)
51 dialog.SetWindowStyle(dialog.GetWindowStyle() & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX));
52#endif
53
54 if(forceModal)
55 return dialog.ShowModal();
56
57 dialog.Show();
58 return 0;
59}
60
61std::unique_ptr<EffectEditor> VST3Effect::PopulateUI(const EffectPlugin &,
63 const EffectOutputs *) const
64{
65 bool useGUI { true };
66 GetConfig(*this, PluginSettings::Shared, wxT("Options"),
67 wxT("UseGUI"),
68 useGUI,
69 useGUI);
70
71 const auto vst3instance = dynamic_cast<VST3Instance*>(&instance);
72
73 return std::make_unique<VST3Editor>(S.GetParent(),
74 vst3instance->GetWrapper(), *this, GetType(), access, useGUI);
75}
76
77std::unique_ptr<EffectEditor> VST3Effect::MakeEditor(
79 const EffectOutputs *) const
80{
82 assert(false);
83 return nullptr;
84}
85
87 const EffectPlugin &, const EffectSettings& settings) const
88{
89 using namespace Steinberg;
90
91 const auto path = SelectFile(FileNames::Operation::Presets,
92 XO("Save VST3 Preset As:"),
93 wxEmptyString,
94 wxEmptyString,
95 wxT(".vstpreset"),
96 {
97 { XO("VST3 preset file"), { wxT("vstpreset") }, true }
98 },
99 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
100 NULL);
101
102 if (path.empty())
103 return;
104
105 auto wrapper = std::make_unique<VST3Wrapper>(*mModule, mEffectClassInfo);
106 wrapper->InitializeComponents();
107
108 auto dummy = EffectSettings { settings };
109 wrapper->FetchSettings(dummy);
110 wrapper->SavePresetToFile(path);
111}
112
114 const EffectPlugin &, EffectSettings& settings) const
115{
116 using namespace Steinberg;
117
118 const auto path = SelectFile(FileNames::Operation::Presets,
119 XO("Load VST3 preset:"),
120 wxEmptyString,
121 wxEmptyString,
122 wxT(".vstpreset"),
123 {
124 { XO("VST3 preset file"), { wxT("vstpreset") }, true }
125 },
126 wxFD_OPEN | wxRESIZE_BORDER,
127 nullptr
128 );
129 if(path.empty())
130 return {};
131
132 LoadPreset(path, settings);
133
134 return { nullptr };
135}
136
138{
139 VST3OptionsDialog{ *this }.ShowModal();
140}
141
142// Inject factory hook to make VST3Effect capable of UI
143static VST3EffectsModule::Factory::SubstituteInUnique<VST3Effect> scope;
wxT("CloseDown"))
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
XO("Cut/Copy/Paste")
FilePath SelectFile(FileNames::Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
Definition: SelectFile.cpp:17
#define S(N)
Definition: ToChars.cpp:64
static Settings & settings()
Definition: TrackInfo.cpp:51
static VST3EffectsModule::Factory::SubstituteInUnique< VST3Effect > scope
Definition: VST3Effect.cpp:143
bool CloseUI() const override
virtual bool IsGraphicalUI()
Performs effect computation.
Hold values to send to effect output meters.
Factory of instances of an effect.
Definition: EffectPlugin.h:36
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
void LoadPreset(const wxString &id, EffectSettings &settings) const
const VST3::Hosting::ClassInfo mEffectClassInfo
std::shared_ptr< VST3::Hosting::Module > mModule
EffectType GetType() const override
Type determines how it behaves.
std::unique_ptr< EffectEditor > PopulateUI(const EffectPlugin &plugin, ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const override
Adds controls to a panel that is given as the parent window of S
Definition: VST3Effect.cpp:61
virtual std::unique_ptr< EffectEditor > MakeEditor(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const final
Will never be called.
Definition: VST3Effect.cpp:77
void ExportPresets(const EffectPlugin &plugin, const EffectSettings &settings) const override
Definition: VST3Effect.cpp:86
OptionalMessage ImportPresets(const EffectPlugin &plugin, EffectSettings &settings) const override
Definition: VST3Effect.cpp:113
void ShowOptions(const EffectPlugin &plugin) const override
Definition: VST3Effect.cpp:137
int ShowClientInterface(const EffectPlugin &plugin, wxWindow &parent, wxDialog &dialog, EffectEditor *pEditor, bool forceModal) const override
Definition: VST3Effect.cpp:41
~VST3Effect() override
Definition: VST3Effect.cpp:34
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)
Externalized state of a plug-in.