JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
vsteditcontroller.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------
2// Project : VST SDK
3//
4// Category : Helpers
5// Filename : public.sdk/source/vst/vsteditcontroller.h
6// Created by : Steinberg, 04/2005
7// Description : VST Edit Controller Implementation
8//
9//-----------------------------------------------------------------------------
10// LICENSE
11// (c) 2023, Steinberg Media Technologies GmbH, All Rights Reserved
12//-----------------------------------------------------------------------------
13// Redistribution and use in source and binary forms, with or without modification,
14// are permitted provided that the following conditions are met:
15//
16// * Redistributions of source code must retain the above copyright notice,
17// this list of conditions and the following disclaimer.
18// * Redistributions in binary form must reproduce the above copyright notice,
19// this list of conditions and the following disclaimer in the documentation
20// and/or other materials provided with the distribution.
21// * Neither the name of the Steinberg Media Technologies nor the names of its
22// contributors may be used to endorse or promote products derived from this
23// software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
34// OF THE POSSIBILITY OF SUCH DAMAGE.
35//-----------------------------------------------------------------------------
36
37#pragma once
38
42
45
46#include <map>
47#include <string>
48#include <vector>
49
50//------------------------------------------------------------------------
51namespace Steinberg {
52namespace Vst {
53
54class EditorView;
55
56//------------------------------------------------------------------------
62{
63public:
64//------------------------------------------------------------------------
66
67 //---from IEditController-------
68 tresult PLUGIN_API setComponentState (IBStream* state) SMTG_OVERRIDE;
69 tresult PLUGIN_API setState (IBStream* state) SMTG_OVERRIDE;
70 tresult PLUGIN_API getState (IBStream* state) SMTG_OVERRIDE;
71 int32 PLUGIN_API getParameterCount () SMTG_OVERRIDE;
72 tresult PLUGIN_API getParameterInfo (int32 paramIndex, ParameterInfo& info) SMTG_OVERRIDE;
73 tresult PLUGIN_API getParamStringByValue (ParamID tag, ParamValue valueNormalized, String128 string) SMTG_OVERRIDE;
74 tresult PLUGIN_API getParamValueByString (ParamID tag, TChar* string, ParamValue& valueNormalized) SMTG_OVERRIDE;
75 ParamValue PLUGIN_API normalizedParamToPlain (ParamID tag, ParamValue valueNormalized) SMTG_OVERRIDE;
76 ParamValue PLUGIN_API plainParamToNormalized (ParamID tag, ParamValue plainValue) SMTG_OVERRIDE;
77 ParamValue PLUGIN_API getParamNormalized (ParamID tag) SMTG_OVERRIDE;
78 tresult PLUGIN_API setParamNormalized (ParamID tag, ParamValue value) SMTG_OVERRIDE;
79 tresult PLUGIN_API setComponentHandler (IComponentHandler* handler) SMTG_OVERRIDE;
80 IPlugView* PLUGIN_API createView (FIDString /*name*/) SMTG_OVERRIDE {return nullptr;}
81
82 //---from IEditController2-------
83 tresult PLUGIN_API setKnobMode (KnobMode mode) SMTG_OVERRIDE { hostKnobMode = mode; return kResultTrue; }
84 tresult PLUGIN_API openHelp (TBool /*onlyCheck*/) SMTG_OVERRIDE {return kResultFalse;}
85 tresult PLUGIN_API openAboutBox (TBool /*onlyCheck*/) SMTG_OVERRIDE {return kResultFalse;}
86
87 //---from ComponentBase---------
88 tresult PLUGIN_API initialize (FUnknown* context) SMTG_OVERRIDE;
89 tresult PLUGIN_API terminate () SMTG_OVERRIDE;
90
91 //---Internal Methods-------
92 virtual tresult beginEdit (ParamID tag);
93 virtual tresult performEdit (ParamID tag, ParamValue valueNormalized);
94 virtual tresult endEdit (ParamID tag);
95 virtual tresult startGroupEdit ();
96 virtual tresult finishGroupEdit ();
97
98 virtual void editorDestroyed (EditorView* /*editor*/) {}
99 virtual void editorAttached (EditorView* /*editor*/) {}
100 virtual void editorRemoved (EditorView* /*editor*/) {}
101
102 static KnobMode getHostKnobMode () { return hostKnobMode; }
103
105 virtual Parameter* getParameterObject (ParamID tag) { return parameters.getParameter (tag); }
106
108 virtual tresult getParameterInfoByTag (ParamID tag, ParameterInfo& info);
109
111 virtual tresult setDirty (TBool state);
112
114 virtual tresult requestOpenEditor (FIDString name = ViewType::kEditor);
115
116 //---Accessor Methods-------
117 IComponentHandler* getComponentHandler () const { return componentHandler; }
118
119 //---Interface---------
120 OBJ_METHODS (EditController, ComponentBase)
122 DEF_INTERFACE (IEditController)
123 DEF_INTERFACE (IEditController2)
124 END_DEFINE_INTERFACES (ComponentBase)
125 REFCOUNT_METHODS (ComponentBase)
126//------------------------------------------------------------------------
127protected:
128 IPtr<IComponentHandler> componentHandler;
129 IPtr<IComponentHandler2> componentHandler2;
130
131 ParameterContainer parameters;
132
133 static KnobMode hostKnobMode;
134};
135
136//------------------------------------------------------------------------
141{
142public:
143//------------------------------------------------------------------------
144 EditorView (EditController* controller, ViewRect* size = nullptr);
145 ~EditorView () override;
146
148 EditController* getController () const { return controller; }
149
150 //---from CPluginView-------------
151 void attachedToParent () SMTG_OVERRIDE;
152 void removedFromParent () SMTG_OVERRIDE;
153
154//------------------------------------------------------------------------
155protected:
156 IPtr<EditController> controller;
157};
158
159//------------------------------------------------------------------------
163class Unit : public FObject
164{
165public:
166//------------------------------------------------------------------------
167 Unit (const String128 name, UnitID unitId, UnitID parentUnitId = kRootUnitId,
168 ProgramListID programListId = kNoProgramListId);
169 Unit (const UnitInfo& unit);
170
172 const UnitInfo& getInfo () const { return info; }
173
175 UnitID getID () const { return info.id; }
176
178 void setID (UnitID newID) { info.id = newID; }
179
181 const TChar* getName () const { return info.name; }
182
184 void setName (const String128 newName);
185
187 ProgramListID getProgramListID () const { return info.programListId; }
188
190 void setProgramListID (ProgramListID newID) { info.programListId = newID; }
191
192 OBJ_METHODS (Unit, FObject)
193//------------------------------------------------------------------------
194protected:
195 Unit ();
196 UnitInfo info;
197};
198
199//------------------------------------------------------------------------
203class ProgramList : public FObject
204{
205public:
206//------------------------------------------------------------------------
207 ProgramList (const String128 name, ProgramListID listId, UnitID unitId);
208 ProgramList (const ProgramList& programList);
209
210 const ProgramListInfo& getInfo () const { return info; }
211 ProgramListID getID () const { return info.id; }
212 const TChar* getName () const { return info.name; }
213 int32 getCount () const { return info.programCount; }
214
215 virtual tresult getProgramName (int32 programIndex, String128 name /*out*/);
216 virtual tresult setProgramName (int32 programIndex, const String128 name /*in*/);
217 virtual tresult getProgramInfo (int32 programIndex, CString attributeId,
218 String128 value /*out*/);
219 virtual tresult hasPitchNames (int32 programIndex)
220 {
221 (void)programIndex;
222 return kResultFalse;
223 }
224 virtual tresult getPitchName (int32 programIndex, int16 midiPitch, String128 name /*out*/)
225 {
226 (void)programIndex;
227 (void)midiPitch;
228 (void)name;
229 return kResultFalse;
230 }
231
233 virtual int32 addProgram (const String128 name);
234
236 virtual bool setProgramInfo (int32 programIndex, CString attributeId, const String128 value);
237
239 virtual Parameter* getParameter ();
240
241 OBJ_METHODS (ProgramList, FObject)
242//------------------------------------------------------------------------
243protected:
247 ProgramListInfo info;
248 UnitID unitId;
249 StringVector programNames;
250 ProgramInfoVector programInfos;
251 Parameter* parameter;
252};
253
254//------------------------------------------------------------------------
259{
260public:
261 ProgramListWithPitchNames (const String128 name, ProgramListID listId, UnitID unitId);
262
264 bool setPitchName (int32 programIndex, int16 pitch, const String128 pitchName);
265
268 bool removePitchName (int32 programIndex, int16 pitch);
269
270 //---from ProgramList---------
271 int32 addProgram (const String128 name) SMTG_OVERRIDE;
272 tresult hasPitchNames (int32 programIndex) SMTG_OVERRIDE;
273 tresult getPitchName (int32 programIndex, int16 midiPitch,
274 String128 name /*out*/) SMTG_OVERRIDE;
275
277protected:
280 PitchNamesVector pitchNames;
281};
282
283//------------------------------------------------------------------------
289{
290public:
292 ~EditControllerEx1 () override;
293
294 //---from ComponentBase---------
295 tresult PLUGIN_API terminate () SMTG_OVERRIDE;
296
298 bool addUnit (Unit* unit);
299
301 bool addProgramList (ProgramList* list);
302
304 ProgramList* getProgramList (ProgramListID listId) const;
305
307 tresult notifyProgramListChange (ProgramListID listId, int32 programIndex = kAllProgramInvalid);
308
309 //---from IUnitInfo------------------
310 int32 PLUGIN_API getUnitCount () SMTG_OVERRIDE { return static_cast<int32> (units.size ()); }
311 tresult PLUGIN_API getUnitInfo (int32 unitIndex, UnitInfo& info /*out*/) SMTG_OVERRIDE;
312
313 int32 PLUGIN_API getProgramListCount () SMTG_OVERRIDE;
314 tresult PLUGIN_API getProgramListInfo (int32 listIndex,
315 ProgramListInfo& info /*out*/) SMTG_OVERRIDE;
316 tresult PLUGIN_API getProgramName (ProgramListID listId, int32 programIndex,
317 String128 name /*out*/) SMTG_OVERRIDE;
318 tresult PLUGIN_API getProgramInfo (ProgramListID listId, int32 programIndex,
319 CString attributeId /*in*/,
320 String128 attributeValue /*out*/) SMTG_OVERRIDE;
321
322 tresult PLUGIN_API hasProgramPitchNames (ProgramListID listId,
323 int32 programIndex) SMTG_OVERRIDE;
324 tresult PLUGIN_API getProgramPitchName (ProgramListID listId, int32 programIndex,
325 int16 midiPitch, String128 name /*out*/) SMTG_OVERRIDE;
326
327 virtual tresult setProgramName (ProgramListID listId, int32 programIndex,
328 const String128 name /*in*/);
329
330 // units selection --------------------
331 UnitID PLUGIN_API getSelectedUnit () SMTG_OVERRIDE { return selectedUnit; }
332 tresult PLUGIN_API selectUnit (UnitID unitId) SMTG_OVERRIDE
333 {
334 selectedUnit = unitId;
335 return kResultTrue;
336 }
337
338 tresult PLUGIN_API getUnitByBus (MediaType /*type*/, BusDirection /*dir*/, int32 /*busIndex*/,
339 int32 /*channel*/, UnitID& /*unitId*/ /*out*/) SMTG_OVERRIDE
340 {
341 return kResultFalse;
342 }
343 tresult PLUGIN_API setUnitProgramData (int32 /*listOrUnitId*/, int32 /*programIndex*/,
344 IBStream* /*data*/) SMTG_OVERRIDE
345 {
346 return kResultFalse;
347 }
348
350 virtual tresult notifyUnitSelection ();
351
352 //---from IDependent------------------
353 void PLUGIN_API update (FUnknown* changedUnknown, int32 message) SMTG_OVERRIDE;
354
355 //---Interface---------
356 OBJ_METHODS (EditControllerEx1, EditController)
361
362protected:
363 using ProgramListVector = std::vector<IPtr<ProgramList>>;
365 using UnitVector = std::vector<IPtr<Unit>>;
366 UnitVector units;
367 ProgramListVector programLists;
368 ProgramIndexMap programIndexMap;
369 UnitID selectedUnit {kRootUnitId};
370};
371
372//------------------------------------------------------------------------
373} // namespace Vst
374} // namespace Steinberg
Plug-In view default implementation.
Definition pluginview.h:50
Implements FUnknown and IDependent.
Definition fobject.h:84
The basic interface of all interfaces.
Definition funknown.h:375
Base class for streams.
Definition ibstream.h:30
Plug-in definition of a view.
Definition iplugview.h:123
IPtr - Smart pointer template class.
Base class for VST 3 Component and Edit Controller.
Advanced implementation (support IUnitInfo) for a VST 3 edit controller.
int32 PLUGIN_API getUnitCount() SMTG_OVERRIDE
Returns the flat count of units.
tresult PLUGIN_API setUnitProgramData(int32, int32, IBStream *) SMTG_OVERRIDE
Receives a preset data stream.
tresult PLUGIN_API getUnitByBus(MediaType, BusDirection, int32, int32, UnitID &) SMTG_OVERRIDE
Gets the according unit if there is an unambiguous relation between a channel or a bus and a unit.
tresult PLUGIN_API selectUnit(UnitID unitId) SMTG_OVERRIDE
Sets a new selected unit.
Default implementation for a VST 3 edit controller.
tresult PLUGIN_API openAboutBox(TBool) SMTG_OVERRIDE
Host could ask to open the plug-in about box.
virtual Parameter * getParameterObject(ParamID tag)
Gets for a given tag the parameter object.
virtual tresult getParameterInfoByTag(ParamID tag, ParameterInfo &info)
Gets for a given tag the parameter information.
int32 PLUGIN_API getParameterCount() SMTG_OVERRIDE
Returns the number of parameters exported.
tresult PLUGIN_API setComponentHandler(IComponentHandler *handler) SMTG_OVERRIDE
Gets from host a handler which allows the Plugin-in to communicate with the host.
virtual tresult performEdit(ParamID tag, ParamValue valueNormalized)
will inform the host about the value change
virtual void editorRemoved(EditorView *)
called from EditorView if it was removed from a parent
tresult PLUGIN_API setKnobMode(KnobMode mode) SMTG_OVERRIDE
Host could set the Knob Mode for the plug-in.
virtual tresult finishGroupEdit()
calls IComponentHandler2::finishGroupEdit() if host supports it
tresult PLUGIN_API initialize(FUnknown *context) SMTG_OVERRIDE
The host passes a number of interfaces as context to initialize the plug-in class.
virtual tresult startGroupEdit()
calls IComponentHandler2::startGroupEdit() if host supports it
ParamValue PLUGIN_API plainParamToNormalized(ParamID tag, ParamValue plainValue) SMTG_OVERRIDE
Returns for a given paramID and a plain value its normalized value.
tresult PLUGIN_API setParamNormalized(ParamID tag, ParamValue value) SMTG_OVERRIDE
Sets the normalized value to the parameter associated to the paramID.
ParamValue PLUGIN_API normalizedParamToPlain(ParamID tag, ParamValue valueNormalized) SMTG_OVERRIDE
Returns for a given paramID and a normalized value its plain representation (for example -6 for -6dB ...
virtual tresult requestOpenEditor(FIDString name=ViewType::kEditor)
Calls IComponentHandler2::requestOpenEditor (name) if host supports it.
tresult PLUGIN_API getState(IBStream *state) SMTG_OVERRIDE
Gets the controller state.
virtual void editorDestroyed(EditorView *)
called from EditorView if it was destroyed
virtual tresult setDirty(TBool state)
Calls IComponentHandler2::setDirty (state) if host supports it.
tresult PLUGIN_API getParamValueByString(ParamID tag, TChar *string, ParamValue &valueNormalized) SMTG_OVERRIDE
Gets for a given paramID and string its normalized value.
tresult PLUGIN_API openHelp(TBool) SMTG_OVERRIDE
Host could ask to open the plug-in help (could be: opening a PDF document or link to a web page).
tresult PLUGIN_API getParameterInfo(int32 paramIndex, ParameterInfo &info) SMTG_OVERRIDE
Gets for a given index the parameter information.
virtual tresult beginEdit(ParamID tag)
to be called before a serie of performEdit
tresult PLUGIN_API getParamStringByValue(ParamID tag, ParamValue valueNormalized, String128 string) SMTG_OVERRIDE
Gets for a given paramID and normalized value its associated string representation.
ParamValue PLUGIN_API getParamNormalized(ParamID tag) SMTG_OVERRIDE
Returns the normalized value of the parameter associated to the paramID.
tresult PLUGIN_API terminate() SMTG_OVERRIDE
This function is called before the plug-in is unloaded and can be used for cleanups.
virtual tresult endEdit(ParamID tag)
to be called after a serie of performEdit
virtual void editorAttached(EditorView *)
called from EditorView if it was attached to a parent
IPlugView *PLUGIN_API createView(FIDString) SMTG_OVERRIDE
Creates the editor view of the plug-in, currently only "editor" is supported, see ViewType.
static KnobMode getHostKnobMode()
return host knob mode
tresult PLUGIN_API setComponentState(IBStream *state) SMTG_OVERRIDE
Receives the component state.
tresult PLUGIN_API setState(IBStream *state) SMTG_OVERRIDE
Sets the controller state.
View related to an edit controller.
void attachedToParent() SMTG_OVERRIDE
Calls when this view will be attached to its parent view.
void removedFromParent() SMTG_OVERRIDE
Calls when this view will be removed from its parent view.
EditController * getController() const
Gets its controller part.
Host callback interface for an edit controller: Vst::IComponentHandler.
Edit controller component interface extension: Vst::IEditController2.
Edit controller component interface: Vst::IEditController.
Edit controller extension to describe the plug-in structure: Vst::IUnitInfo.
Definition ivstunits.h:145
Parameter * getParameter(ParamID tag) const
Gets parameter by ID.
Description of a Parameter.
ProgramListWithPitchNames element.
void setID(UnitID newID)
Sets a new Unit ID.
void setProgramListID(ProgramListID newID)
Sets a new ProgramList ID.
UnitID getID() const
Returns its Unit ID.
const TChar * getName() const
Returns its Unit Name.
const UnitInfo & getInfo() const
Returns its info.
ProgramListID getProgramListID() const
Returns its ProgramList ID.
#define DEFINE_INTERFACES
Start defining interfaces.
Definition fobject.h:387
#define DEF_INTERFACE(InterfaceName)
Add a interfaces.
Definition fobject.h:394
#define END_DEFINE_INTERFACES(BaseClass)
End defining interfaces.
Definition fobject.h:400
#define REFCOUNT_METHODS(BaseClass)
Delegate refcount functions to BaseClass.
Definition fobject.h:360
int32 KnobMode
Knob Mode Type.
uint32 ParamID
parameter identifier
Definition vsttypes.h:81
TChar String128[128]
128 character UTF-16 string
Definition vsttypes.h:69
char16 TChar
UTF-16 character.
Definition vsttypes.h:68
double ParamValue
parameter value type
Definition vsttypes.h:80
int32 ProgramListID
program list identifier
Definition vsttypes.h:82
int32 BusDirection
bus direction (in/out)
Definition vsttypes.h:76
int32 UnitID
unit identifier
Definition vsttypes.h:79
const char8 * CString
C-String.
Definition vsttypes.h:70
int32 MediaType
media type (audio/event)
Definition vsttypes.h:75
ProgramListID id
program list identifier
Definition ivstunits.h:58
Basic Program List Description.
Definition ivstunits.h:57
Basic Unit Description.
Definition ivstunits.h:45
Graphical rectangle structure.
Definition iplugview.h:35
Controller Parameter Info.