Audacity 3.2.0
Public Member Functions | List of all members
BasicEffectUIServices Class Reference

#include <BasicEffectUIServices.h>

Inheritance diagram for BasicEffectUIServices:
[legend]
Collaboration diagram for BasicEffectUIServices:
[legend]

Public Member Functions

int ShowClientInterface (const EffectPlugin &plugin, wxWindow &parent, wxDialog &dialog, EffectEditor *pEditor, bool forceModal) const override
 
void ExportPresets (const EffectPlugin &plugin, const EffectSettings &settings) const override
 
OptionalMessage ImportPresets (const EffectPlugin &plugin, EffectSettings &settings) const override
 
void ShowOptions (const EffectPlugin &plugin) const override
 
bool ValidateUI (const EffectPlugin &context, EffectSettings &) const override
 
bool CloseUI () const override
 
- Public Member Functions inherited from EffectUIServices
virtual ~EffectUIServices ()
 
virtual int ShowHostInterface (EffectBase &plugin, wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false)
 
virtual int ShowClientInterface (const EffectPlugin &plugin, wxWindow &parent, wxDialog &dialog, EffectEditor *pEditor, bool forceModal=false) const =0
 
virtual std::unique_ptr< EffectEditorPopulateUI (const EffectPlugin &plugin, ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const =0
 Adds controls to a panel that is given as the parent window of S More...
 
virtual void ExportPresets (const EffectPlugin &plugin, const EffectSettings &settings) const =0
 
virtual OptionalMessage ImportPresets (const EffectPlugin &plugin, EffectSettings &settings) const =0
 
virtual void ShowOptions (const EffectPlugin &plugin) const =0
 
virtual bool ValidateUI (const EffectPlugin &context, EffectSettings &settings) const =0
 
virtual bool CloseUI () const =0
 

Additional Inherited Members

- Public Types inherited from EffectUIServices
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Static Public Member Functions inherited from EffectUIServices
static int DoMessageBox (const EffectPlugin &plugin, const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 

Detailed Description

Supplies implementations of all pure virtual functions of the base class except PopulateUI

Definition at line 21 of file BasicEffectUIServices.h.

Member Function Documentation

◆ CloseUI()

bool BasicEffectUIServices::CloseUI ( ) const
overridevirtual

Implements EffectUIServices.

Reimplemented in LV2Effect.

Definition at line 43 of file BasicEffectUIServices.cpp.

44{
45 return true;
46}

Referenced by VST3Effect::~VST3Effect().

Here is the caller graph for this function:

◆ ExportPresets()

void BasicEffectUIServices::ExportPresets ( const EffectPlugin plugin,
const EffectSettings settings 
) const
overridevirtual

Implements EffectUIServices.

Reimplemented in LadspaEffect, LV2Effect, VSTEffect, and VST3Effect.

Definition at line 57 of file BasicEffectUIServices.cpp.

59{
60 wxString params;
62 auto commandId = plugin.GetSquashedName(plugin.GetSymbol().Internal());
63 params = commandId.GET() + ":" + params;
64
65 auto path = SelectFile(FileNames::Operation::Presets,
66 XO("Export Effect Parameters"),
67 wxEmptyString,
68 wxEmptyString,
69 wxEmptyString,
71 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
72 nullptr);
73 if (path.empty()) {
74 return;
75 }
76
77 // Create/Open the file
78 wxFFile f(path, wxT("wb"));
79 if (!f.IsOpened())
80 {
82 XO("Could not open file: \"%s\"").Format( path ),
83 XO("Error Saving Effect Presets"),
84 wxICON_EXCLAMATION,
85 NULL);
86 return;
87 }
88
89 f.Write(params);
90 if (f.Error())
91 {
93 XO("Error writing to file: \"%s\"").Format( path ),
94 XO("Error Saving Effect Presets"),
95 wxICON_EXCLAMATION,
96 NULL);
97 }
98
99 f.Close();
100
101
102 //SetWindowTitle();
103
104}
wxT("CloseDown"))
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
static const FileNames::FileTypes & PresetTypes()
EffectDistortionSettings params
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
static Settings & settings()
Definition: TrackInfo.cpp:51
virtual ComponentInterfaceSymbol GetSymbol() const =0
const wxString & Internal() const
static Identifier GetSquashedName(const Identifier &ident)
A utility that strips spaces and CamelCases a name.
virtual bool SaveSettingsAsString(const EffectSettings &settings, wxString &parms) const =0
Abstract base class used in importing a file.

References AudacityMessageBox(), EffectDefinitionInterface::GetSquashedName(), ComponentInterface::GetSymbol(), ComponentInterfaceSymbol::Internal(), params, PresetTypes(), EffectPlugin::SaveSettingsAsString(), SelectFile(), settings(), wxT(), and XO().

Here is the call graph for this function:

◆ ImportPresets()

OptionalMessage BasicEffectUIServices::ImportPresets ( const EffectPlugin plugin,
EffectSettings settings 
) const
overridevirtual
Returns
nullopt for failure

Implements EffectUIServices.

Reimplemented in LadspaEffect, LV2Effect, VSTEffect, and VST3Effect.

Definition at line 106 of file BasicEffectUIServices.cpp.

108{
109 wxString params;
110
111 auto path = SelectFile(FileNames::Operation::Presets,
112 XO("Import Effect Parameters"),
113 wxEmptyString,
114 wxEmptyString,
115 wxEmptyString,
116 PresetTypes(),
117 wxFD_OPEN | wxRESIZE_BORDER,
118 nullptr);
119 if (path.empty()) {
120 return {};
121 }
122
123 wxFFile f(path);
124 if (!f.IsOpened())
125 return {};
126
127 OptionalMessage result{};
128
129 if (f.ReadAll(&params)) {
130 wxString ident = params.BeforeFirst(':');
131 params = params.AfterFirst(':');
132
133 auto commandId = plugin.GetSquashedName(plugin.GetSymbol().Internal());
134
135 if (ident != commandId) {
136 // effect identifiers are a sensible length!
137 // must also have some params.
138 if ((params.Length() < 2 ) || (ident.Length() < 2) ||
139 (ident.Length() > 30))
140 {
142 /* i18n-hint %s will be replaced by a file name */
143 XO("%s: is not a valid presets file.\n")
144 .Format(wxFileNameFromPath(path)));
145 }
146 else
147 {
149 /* i18n-hint %s will be replaced by a file name */
150 XO("%s: is for a different Effect, Generator or Analyzer.\n")
151 .Format(wxFileNameFromPath(path)));
152 }
153 return {};
154 }
155 result = plugin.LoadSettingsFromString(params, settings);
156 }
157
158 //SetWindowTitle();
159
160 return result;
161}
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
static CommandHandlerObject & ident(AudacityProject &project)
virtual OptionalMessage LoadSettingsFromString(const wxString &parms, EffectSettings &settings) const =0
static int DoMessageBox(const EffectPlugin &plugin, const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})

References EffectUIServices::DoMessageBox(), EffectDefinitionInterface::GetSquashedName(), ComponentInterface::GetSymbol(), ident(), ComponentInterfaceSymbol::Internal(), EffectPlugin::LoadSettingsFromString(), params, PresetTypes(), SelectFile(), settings(), and XO().

Here is the call graph for this function:

◆ ShowClientInterface()

int BasicEffectUIServices::ShowClientInterface ( const EffectPlugin plugin,
wxWindow &  parent,
wxDialog &  dialog,
EffectEditor pEditor,
bool  forceModal 
) const
overridevirtual
Returns
0 if destructive effect processing should not proceed (and there may be a non-modal dialog still opened); otherwise, modal dialog return code

Implements EffectUIServices.

Reimplemented in LadspaEffect, LV2Effect, VSTEffect, and VST3Effect.

Definition at line 23 of file BasicEffectUIServices.cpp.

25{
26 dialog.Layout();
27 dialog.Fit();
28 dialog.SetMinSize(dialog.GetSize());
29 if (plugin.SupportsRealtime() && !forceModal) {
30 dialog.Show();
31 // Return false to bypass effect processing
32 return 0;
33 }
34 return dialog.ShowModal();
35}

References EffectDefinitionInterface::SupportsRealtime().

Here is the call graph for this function:

◆ ShowOptions()

void BasicEffectUIServices::ShowOptions ( const EffectPlugin plugin) const
overridevirtual

Implements EffectUIServices.

Reimplemented in LadspaEffect, LV2Effect, VSTEffect, and VST3Effect.

Definition at line 163 of file BasicEffectUIServices.cpp.

164{
165}

◆ ValidateUI()

bool BasicEffectUIServices::ValidateUI ( const EffectPlugin context,
EffectSettings  
) const
overridevirtual

Implements EffectUIServices.

Reimplemented in EffectEqualization.

Definition at line 37 of file BasicEffectUIServices.cpp.

39{
40 return true;
41}

Referenced by EffectBassTreble::Editor::OnBassSlider(), EffectBassTreble::Editor::OnBassText(), EffectDistortion::Editor::OnDCBlockCheckbox(), EffectPhaser::Editor::OnDepthSlider(), EffectWahwah::Editor::OnDepthSlider(), EffectPhaser::Editor::OnDepthText(), EffectWahwah::Editor::OnDepthText(), EffectPhaser::Editor::OnDryWetSlider(), EffectPhaser::Editor::OnDryWetText(), EffectPhaser::Editor::OnFeedbackSlider(), EffectPhaser::Editor::OnFeedbackText(), EffectWahwah::Editor::OnFreqOffSlider(), EffectWahwah::Editor::OnFreqOffText(), EffectPhaser::Editor::OnFreqSlider(), EffectWahwah::Editor::OnFreqSlider(), EffectPhaser::Editor::OnFreqText(), EffectWahwah::Editor::OnFreqText(), EffectBassTreble::Editor::OnGainSlider(), EffectPhaser::Editor::OnGainSlider(), EffectWahwah::Editor::OnGainSlider(), EffectBassTreble::Editor::OnGainText(), EffectPhaser::Editor::OnGainText(), EffectWahwah::Editor::OnGainText(), EffectBassTreble::Editor::OnLinkCheckbox(), EffectDistortion::Editor::OnNoiseFloorSlider(), EffectDistortion::Editor::OnNoiseFloorText(), EffectDistortion::Editor::OnParam1Slider(), EffectDistortion::Editor::OnParam1Text(), EffectDistortion::Editor::OnParam2Slider(), EffectDistortion::Editor::OnParam2Text(), EffectPhaser::Editor::OnPhaseSlider(), EffectWahwah::Editor::OnPhaseSlider(), EffectPhaser::Editor::OnPhaseText(), EffectWahwah::Editor::OnPhaseText(), EffectDistortion::Editor::OnRepeatsSlider(), EffectDistortion::Editor::OnRepeatsText(), EffectWahwah::Editor::OnResonanceSlider(), EffectWahwah::Editor::OnResonanceText(), EffectPhaser::Editor::OnStagesSlider(), EffectPhaser::Editor::OnStagesText(), EffectDistortion::Editor::OnThresholdSlider(), EffectDistortion::Editor::OnThresholdText(), EffectBassTreble::Editor::OnTrebleSlider(), EffectBassTreble::Editor::OnTrebleText(), EffectDistortion::Editor::OnTypeChoice(), and SpinSliderHandlers().

Here is the caller graph for this function:

The documentation for this class was generated from the following files: