vstcomponent.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Project     : VST SDK
00003 // Version     : 3.0
00004 //
00005 // Category    : Helpers
00006 // Filename    : vstcomponent.cpp
00007 // Created by  : Steinberg, 04/2005
00008 // Modified    : $Date: 2008/01/09 12:51:06 $
00009 // Description : Basic VST Plug-In Implementation
00010 //
00011 //-----------------------------------------------------------------------------
00012 // LICENSE
00013 // © 2008, Steinberg Media Technologies GmbH, All Rights Reserved
00014 //-----------------------------------------------------------------------------
00015 // This Software Development Kit may not be distributed in parts or its entirety  
00016 // without prior written agreement by Steinberg Media Technologies GmbH. 
00017 // This SDK must not be used to re-engineer or manipulate any technology used  
00018 // in any Steinberg or Third-party application or software module, 
00019 // unless permitted by law.
00020 // Neither the name of the Steinberg Media Technologies nor the names of its
00021 // contributors may be used to endorse or promote products derived from this 
00022 // software without specific prior written permission.
00023 // 
00024 // THIS SDK IS PROVIDED BY STEINBERG MEDIA TECHNOLOGIES GMBH "AS IS" AND
00025 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
00026 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00027 // IN NO EVENT SHALL STEINBERG MEDIA TECHNOLOGIES GMBH BE LIABLE FOR ANY DIRECT, 
00028 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
00029 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
00030 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
00031 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
00032 // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
00033 // OF THE POSSIBILITY OF SUCH DAMAGE.
00034 //----------------------------------------------------------------------------------
00035 
00036 #include "vstcomponent.h"
00037 
00038 namespace Steinberg {
00039 namespace Vst {
00040 
00041 //------------------------------------------------------------------------
00042 // Bus
00043 //------------------------------------------------------------------------
00044 Bus::Bus (const TChar* _name, BusType _busType, int32 _flags)
00045 : busType (_busType)
00046 , name (_name)
00047 , flags (_flags)
00048 , active (false)
00049 {}
00050 
00051 //------------------------------------------------------------------------
00052 bool Bus::getInfo (BusInfo& info)
00053 {
00054         name.copyTo (info.name, USTRINGSIZE (info.name));
00055         info.busType = busType;
00056         info.flags = flags;
00057         return true;
00058 }
00059 
00060 //------------------------------------------------------------------------
00061 // EventBus
00062 //------------------------------------------------------------------------
00063 EventBus::EventBus (const TChar* name, BusType busType, int32 flags, int32 channelCount)
00064 : Bus (name, busType, flags)
00065 , channelCount (channelCount)
00066 {}
00067 
00068 //------------------------------------------------------------------------
00069 bool EventBus::getInfo (BusInfo& info)
00070 {
00071         info.channelCount = channelCount;
00072         return Bus::getInfo (info);
00073 }
00074 
00075 
00076 //------------------------------------------------------------------------
00077 // BusList
00078 //------------------------------------------------------------------------
00079 BusList::BusList (MediaType type, BusDirection dir)
00080 : type (type)
00081 , direction (dir)
00082 {}
00083 
00084 
00085 //------------------------------------------------------------------------
00086 // Component
00087 //------------------------------------------------------------------------
00088 Component::Component ()
00089 : audioInputs (kAudio, kInput)
00090 , audioOutputs (kAudio, kOutput)
00091 , eventInputs (kEvent, kInput)
00092 , eventOutputs (kEvent, kOutput)
00093 {}
00094 
00095 //------------------------------------------------------------------------
00096 tresult PLUGIN_API Component::queryInterface (const char* iid, void** obj)
00097 {
00098         QUERY_INTERFACE (iid, obj, IComponent::iid, IComponent)
00099         return ComponentBase::queryInterface (iid, obj);
00100 }
00101 
00102 //------------------------------------------------------------------------
00103 tresult PLUGIN_API Component::initialize (FUnknown* context)
00104 {
00105         return ComponentBase::initialize (context);
00106 }
00107 
00108 //------------------------------------------------------------------------
00109 tresult PLUGIN_API Component::terminate ()
00110 {
00111         // remove all busses
00112         removeAllBusses ();
00113 
00114         return ComponentBase::terminate ();
00115 }
00116 
00117 //------------------------------------------------------------------------
00118 BusList* Component::getBusList (MediaType type, BusDirection dir)
00119 {
00120         if (type == kAudio)
00121                 return dir == kInput ? &audioInputs : &audioOutputs;
00122         else if (type == kEvent)
00123                 return dir == kInput ? &eventInputs : &eventOutputs;
00124         return 0;
00125 }
00126 
00127 //------------------------------------------------------------------------
00128 tresult Component::removeAudioBusses ()
00129 {
00130         audioInputs.removeAll ();
00131         audioOutputs.removeAll ();
00132 
00133         return kResultOk;
00134 }
00135 
00136 //------------------------------------------------------------------------
00137 tresult Component::removeEventBusses ()
00138 {
00139         eventInputs.removeAll ();
00140         eventOutputs.removeAll ();
00141 
00142         return kResultOk;
00143 }
00144 
00145 //------------------------------------------------------------------------
00146 tresult Component::removeAllBusses ()
00147 {
00148         removeAudioBusses ();
00149         removeEventBusses ();
00150 
00151         return kResultOk;
00152 }
00153 
00154 //------------------------------------------------------------------------
00155 tresult PLUGIN_API Component::getControllerClassId (TUID classID)
00156 {
00157         if (controllerClass.isValid ())
00158         {
00159                 controllerClass.toTUID (classID);
00160                 return kResultTrue;
00161         }
00162         return kResultFalse;
00163 }
00164 
00165 //------------------------------------------------------------------------
00166 tresult PLUGIN_API Component::setIoMode (IoMode mode)
00167 {
00168         return kNotImplemented;
00169 }
00170 
00171 //------------------------------------------------------------------------
00172 int32 PLUGIN_API Component::getBusCount (MediaType type, BusDirection dir)
00173 {
00174         BusList* busList = getBusList (type, dir);
00175         return busList ? busList->total () : 0;
00176 }
00177 
00178 //------------------------------------------------------------------------
00179 tresult PLUGIN_API Component::getBusInfo (MediaType type, BusDirection dir, int32 index, BusInfo& info)
00180 {
00181         BusList* busList = getBusList (type, dir);
00182         Bus* bus = busList ? (Bus*)busList->at (index) : 0;
00183         if (bus)
00184         {
00185                 info.mediaType = type;
00186                 info.direction = dir;
00187                 if (bus->getInfo (info))
00188                         return kResultTrue;
00189         }
00190         return kResultFalse;
00191 }
00192 
00193 //------------------------------------------------------------------------
00194 tresult PLUGIN_API Component::getRoutingInfo (RoutingInfo& inInfo, RoutingInfo& outInfo)
00195 {
00196         return kNotImplemented;
00197 }
00198 
00199 //------------------------------------------------------------------------
00200 tresult PLUGIN_API Component::activateBus (MediaType type, BusDirection dir, int32 index, TBool state)
00201 {
00202         BusList* busList = getBusList (type, dir);
00203         Bus* bus = busList ? (Bus*)busList->at (index) : 0;
00204         if (bus)
00205         {
00206                 bus->setActive (state);
00207                 return kResultTrue;
00208         }
00209         return kResultFalse;
00210 }
00211 
00212 //------------------------------------------------------------------------
00213 tresult PLUGIN_API Component::setActive (TBool state)
00214 {
00215         return kResultOk;
00216 }
00217 
00218 //------------------------------------------------------------------------
00219 tresult PLUGIN_API Component::setState (IBStream* state)
00220 {
00221         return kNotImplemented;
00222 }
00223 
00224 //------------------------------------------------------------------------
00225 tresult PLUGIN_API Component::getState (IBStream* state)
00226 {
00227         return kNotImplemented;
00228 }
00229 
00230 } // namespace Vst
00231 } // namespace Steinberg
Empty

Copyright ©2008 Steinberg Media Technologies. All Rights Reserved.