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
vstcomponent.cpp
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2// Project : VST SDK
3//
4// Category : Helpers
5// Filename : public.sdk/source/vst/vstcomponent.cpp
6// Created by : Steinberg, 04/2005
7// Description : Basic VST Plug-in 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#include "vstcomponent.h"
38
39namespace Steinberg {
40namespace Vst {
41
42//------------------------------------------------------------------------
43// Component Implementation
44//------------------------------------------------------------------------
46: audioInputs (kAudio, kInput)
47, audioOutputs (kAudio, kOutput)
48, eventInputs (kEvent, kInput)
49, eventOutputs (kEvent, kOutput)
50{
51}
52
53//------------------------------------------------------------------------
54tresult PLUGIN_API Component::initialize (FUnknown* context)
55{
56 return ComponentBase::initialize (context);
57}
58
59//------------------------------------------------------------------------
60tresult PLUGIN_API Component::terminate ()
61{
62 // remove all busses
63 removeAllBusses ();
64
66}
67
68//------------------------------------------------------------------------
69BusList* Component::getBusList (MediaType type, BusDirection dir)
70{
71 if (type == kAudio)
72 return dir == kInput ? &audioInputs : &audioOutputs;
73 if (type == kEvent)
74 return dir == kInput ? &eventInputs : &eventOutputs;
75 return nullptr;
76}
77
78//------------------------------------------------------------------------
80{
81 audioInputs.clear ();
82 audioOutputs.clear ();
83
84 return kResultOk;
85}
86
87//------------------------------------------------------------------------
89{
90 eventInputs.clear ();
91 eventOutputs.clear ();
92
93 return kResultOk;
94}
95
96//------------------------------------------------------------------------
97tresult Component::removeAllBusses ()
98{
101
102 return kResultOk;
103}
104
105//------------------------------------------------------------------------
106tresult PLUGIN_API Component::getControllerClassId (TUID classID)
107{
108 if (controllerClass.isValid ())
109 {
110 controllerClass.toTUID (classID);
111 return kResultTrue;
112 }
113 return kResultFalse;
114}
115
116//------------------------------------------------------------------------
117tresult PLUGIN_API Component::setIoMode (IoMode /*mode*/)
118{
119 return kNotImplemented;
120}
121
122//------------------------------------------------------------------------
124{
125 BusList* busList = getBusList (type, dir);
126 return busList ? static_cast<int32> (busList->size ()) : 0;
127}
128
129//------------------------------------------------------------------------
130tresult PLUGIN_API Component::getBusInfo (MediaType type, BusDirection dir, int32 index,
131 BusInfo& info)
132{
133 if (index < 0)
134 return kInvalidArgument;
135 BusList* busList = getBusList (type, dir);
136 if (busList == nullptr)
137 return kInvalidArgument;
138 if (index >= static_cast<int32> (busList->size ()))
139 return kInvalidArgument;
140
141 Bus* bus = busList->at (index);
142 info.mediaType = type;
143 info.direction = dir;
144 if (bus->getInfo (info))
145 return kResultTrue;
146 return kResultFalse;
147}
148
149//------------------------------------------------------------------------
150tresult PLUGIN_API Component::getRoutingInfo (RoutingInfo& /*inInfo*/, RoutingInfo& /*outInfo*/)
151{
152 return kNotImplemented;
153}
154
155//------------------------------------------------------------------------
156tresult PLUGIN_API Component::activateBus (MediaType type, BusDirection dir, int32 index,
157 TBool state)
158{
159 if (index < 0)
160 return kInvalidArgument;
161 BusList* busList = getBusList (type, dir);
162 if (busList == nullptr)
163 return kInvalidArgument;
164 if (index >= static_cast<int32> (busList->size ()))
165 return kInvalidArgument;
166
167 Bus* bus = busList->at (index);
168 bus->setActive (state);
169 return kResultTrue;
170}
171
172//------------------------------------------------------------------------
173tresult PLUGIN_API Component::setActive (TBool /*state*/)
174{
175 return kResultOk;
176}
177
178//------------------------------------------------------------------------
179tresult PLUGIN_API Component::setState (IBStream* /*state*/)
180{
181 return kNotImplemented;
182}
183
184//------------------------------------------------------------------------
185tresult PLUGIN_API Component::getState (IBStream* /*state*/)
186{
187 return kNotImplemented;
188}
189
190//------------------------------------------------------------------------
191tresult Component::renameBus (MediaType type, BusDirection dir, int32 index,
192 const String128 newName)
193{
194 if (index < 0)
195 return kInvalidArgument;
196 BusList* busList = getBusList (type, dir);
197 if (busList == nullptr)
198 return kInvalidArgument;
199 if (index >= static_cast<int32> (busList->size ()))
200 return kInvalidArgument;
201
202 Bus* bus = busList->at (index);
203 bus->setName (newName);
204 return kResultTrue;
205}
206
207//------------------------------------------------------------------------
208// Helpers Implementation
209//------------------------------------------------------------------------
210tresult getSpeakerChannelIndex (SpeakerArrangement arrangement, uint64 speaker, int32& channel)
211{
212 channel = SpeakerArr::getSpeakerIndex (speaker, arrangement);
213 return (channel < 0) == true ? kResultFalse : kResultTrue;
214}
215} // namespace Vst
216} // namespace Steinberg
T at(T... args)
bool isValid() const
Checks if the UID data is valid.
Definition funknown.cpp:192
The basic interface of all interfaces.
Definition funknown.h:375
Base class for streams.
Definition ibstream.h:30
List of Busses.
Definition vstbus.h:150
Basic Bus object.
Definition vstbus.h:58
void setActive(TBool state)
Activates the bus.
Definition vstbus.h:68
void setName(const std::u16string &newName)
Sets a new name for this bus.
Definition vstbus.h:75
virtual bool getInfo(BusInfo &)
Gets the BusInfo of this bus.
Definition vstbus.cpp:51
tresult PLUGIN_API initialize(FUnknown *context) SMTG_OVERRIDE
The host passes a number of interfaces as context to initialize the plug-in class.
tresult PLUGIN_API terminate() SMTG_OVERRIDE
This function is called before the plug-in is unloaded and can be used for cleanups.
int32 PLUGIN_API getBusCount(MediaType type, BusDirection dir) SMTG_OVERRIDE
Called after the plug-in is initialized.
tresult PLUGIN_API getState(IBStream *state) SMTG_OVERRIDE
Retrieves complete state of component.
tresult PLUGIN_API getRoutingInfo(RoutingInfo &inInfo, RoutingInfo &outInfo) SMTG_OVERRIDE
Retrieves routing information (to be implemented when more than one regular input or output bus exist...
tresult PLUGIN_API setState(IBStream *state) SMTG_OVERRIDE
Sets complete state of component.
tresult PLUGIN_API setActive(TBool state) SMTG_OVERRIDE
Activates / deactivates the component.
tresult PLUGIN_API initialize(FUnknown *context) SMTG_OVERRIDE
The host passes a number of interfaces as context to initialize the plug-in class.
tresult PLUGIN_API setIoMode(IoMode mode) SMTG_OVERRIDE
Called before 'initialize' to set the component usage (optional).
tresult PLUGIN_API activateBus(MediaType type, BusDirection dir, int32 index, TBool state) SMTG_OVERRIDE
Called upon (de-)activating a bus in the host application.
tresult PLUGIN_API getControllerClassId(TUID classID) SMTG_OVERRIDE
Called before initializing the component to get information about the controller class.
tresult PLUGIN_API getBusInfo(MediaType type, BusDirection dir, int32 index, BusInfo &info) SMTG_OVERRIDE
Called after the plug-in is initialized.
tresult PLUGIN_API terminate() SMTG_OVERRIDE
This function is called before the plug-in is unloaded and can be used for cleanups.
tresult renameBus(MediaType type, BusDirection dir, int32 index, const String128 newName)
Renames a specific bus.
tresult removeAudioBusses()
Removes all Audio Busses.
tresult removeEventBusses()
Removes all Event Busses.
T clear(T... args)
int32 getSpeakerIndex(Speaker speaker, SpeakerArrangement arrangement)
Returns the index of a given speaker in a speaker arrangement (-1 if speaker is not part of the arran...
Definition vstspeaker.h:645
@ kOutput
output bus
@ kInput
input bus
int32 IoMode
I/O mode (see vst3IoMode)
Definition vsttypes.h:78
TChar String128[128]
128 character UTF-16 string
Definition vsttypes.h:69
tresult getSpeakerChannelIndex(SpeakerArrangement arrangement, uint64 speaker, int32 &channel)
Gets the channel index of a given speaker in a arrangement, returns kResultFalse if speaker not part ...
int32 BusDirection
bus direction (in/out)
Definition vsttypes.h:76
uint64 SpeakerArrangement
Bitset of speakers.
Definition vsttypes.h:104
int32 MediaType
media type (audio/event)
Definition vsttypes.h:75
Routing Information: When the plug-in supports multiple I/O busses, a host may want to know how the b...
T size(T... args)
BusInfo: This is the structure used with getBusInfo, informing the host about what is a specific give...
MediaType mediaType
Media type - has to be a value of MediaTypes.
BusDirection direction
input or output BusDirections