LMMS
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) 2021, 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//------------------------------------------------------------------------
52
53//------------------------------------------------------------------------
55{
56 return ComponentBase::initialize (context);
57}
58
59//------------------------------------------------------------------------
61{
62 // remove all busses
64
66}
67
68//------------------------------------------------------------------------
70{
71 if (type == kAudio)
72 return dir == kInput ? &audioInputs : &audioOutputs;
73 else 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//------------------------------------------------------------------------
104
105//------------------------------------------------------------------------
107{
108 if (controllerClass.isValid ())
109 {
110 controllerClass.toTUID (classID);
111 return kResultTrue;
112 }
113 return kResultFalse;
114}
115
116//------------------------------------------------------------------------
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//------------------------------------------------------------------------
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//------------------------------------------------------------------------
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//------------------------------------------------------------------------
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//------------------------------------------------------------------------
211{
212 channel = SpeakerArr::getSpeakerIndex (speaker, arrangement);
213 return (channel < 0) == true ? kResultFalse : kResultTrue;
214}
215} // namespace Vst
216} // namespace Steinberg
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
Definition funknown.h:361
Definition ibstream.h:30
Definition vstbus.h:55
void setActive(TBool state)
Definition vstbus.h:65
void setName(String newName)
Definition vstbus.h:68
virtual bool getInfo(BusInfo &)
Definition vstbus.cpp:51
Definition vstbus.h:142
tresult PLUGIN_API initialize(FUnknown *context) SMTG_OVERRIDE
Definition vstcomponentbase.cpp:56
tresult PLUGIN_API terminate() SMTG_OVERRIDE
Definition vstcomponentbase.cpp:68
int32 PLUGIN_API getBusCount(MediaType type, BusDirection dir) SMTG_OVERRIDE
Definition vstcomponent.cpp:123
BusList eventInputs
Definition vstcomponent.h:100
tresult PLUGIN_API getState(IBStream *state) SMTG_OVERRIDE
Definition vstcomponent.cpp:185
BusList audioInputs
Definition vstcomponent.h:98
tresult PLUGIN_API getRoutingInfo(RoutingInfo &inInfo, RoutingInfo &outInfo) SMTG_OVERRIDE
Definition vstcomponent.cpp:150
tresult PLUGIN_API setState(IBStream *state) SMTG_OVERRIDE
Definition vstcomponent.cpp:179
tresult PLUGIN_API setActive(TBool state) SMTG_OVERRIDE
Definition vstcomponent.cpp:173
FUID controllerClass
Definition vstcomponent.h:97
tresult PLUGIN_API initialize(FUnknown *context) SMTG_OVERRIDE
Definition vstcomponent.cpp:54
tresult PLUGIN_API setIoMode(IoMode mode) SMTG_OVERRIDE
Definition vstcomponent.cpp:117
tresult PLUGIN_API activateBus(MediaType type, BusDirection dir, int32 index, TBool state) SMTG_OVERRIDE
Definition vstcomponent.cpp:156
tresult PLUGIN_API getControllerClassId(TUID classID) SMTG_OVERRIDE
Definition vstcomponent.cpp:106
tresult PLUGIN_API getBusInfo(MediaType type, BusDirection dir, int32 index, BusInfo &info) SMTG_OVERRIDE
Definition vstcomponent.cpp:130
BusList eventOutputs
Definition vstcomponent.h:101
BusList audioOutputs
Definition vstcomponent.h:99
BusList * getBusList(MediaType type, BusDirection dir)
Definition vstcomponent.cpp:69
tresult PLUGIN_API terminate() SMTG_OVERRIDE
Definition vstcomponent.cpp:60
Component()
Definition vstcomponent.cpp:45
tresult removeAllBusses()
Definition vstcomponent.cpp:97
tresult renameBus(MediaType type, BusDirection dir, int32 index, const String128 newName)
Definition vstcomponent.cpp:191
tresult removeAudioBusses()
Definition vstcomponent.cpp:79
tresult removeEventBusses()
Definition vstcomponent.cpp:88
struct backing_store_struct * info
Definition jmemsys.h:183
int32 getSpeakerIndex(Speaker speaker, SpeakerArrangement arrangement)
Definition vstspeaker.h:495
Definition ivstattributes.h:28
@ kOutput
output bus
Definition ivstcomponent.h:76
@ kInput
input bus
Definition ivstcomponent.h:75
int32 IoMode
I/O mode (see vst3IoMode).
Definition vsttypes.h:72
TChar String128[128]
128 character UTF-16 string
Definition vsttypes.h:63
tresult getSpeakerChannelIndex(SpeakerArrangement arrangement, uint64 speaker, int32 &channel)
Definition vstcomponent.cpp:210
@ kAudio
audio
Definition ivstcomponent.h:66
@ kEvent
events
Definition ivstcomponent.h:67
int32 BusDirection
bus direction (in/out)
Definition vsttypes.h:70
uint64 SpeakerArrangement
Bitset of speakers.
Definition vsttypes.h:98
int32 MediaType
media type (audio/event)
Definition vsttypes.h:69
Definition baseiids.cpp:43
unsigned long long uint64
Definition ftypes.h:67
int int32
Definition ftypes.h:50
int8 TUID[16]
plain UID type
Definition funknown.h:210
@ kResultOk
Definition funknown.h:193
@ kInvalidArgument
Definition funknown.h:196
@ kNotImplemented
Definition funknown.h:197
@ kResultFalse
Definition funknown.h:195
@ kResultTrue
Definition funknown.h:194
uint8 TBool
Definition ftypes.h:89
int32 tresult
Definition ftypes.h:76
Definition ivstcomponent.h:93
Definition ivstcomponent.h:136