vstaudioeffect.cpp

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // Project     : VST SDK
00003 // Version     : 3.0
00004 //
00005 // Category    : Helpers
00006 // Filename    : vstaudioeffect.cpp
00007 // Created by  : Steinberg, 04/2005
00008 // Modified    : $Date: 2008/01/15 15:00:26 $
00009 // Description : Basic Audio Effect 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 "vstaudioeffect.h"
00037 
00038 namespace Steinberg {
00039 namespace Vst {
00040 
00041 //------------------------------------------------------------------------
00042 // AudioBus
00043 //------------------------------------------------------------------------
00044 AudioBus::AudioBus (const TChar* name, BusType busType, int32 flags, SpeakerArrangement arr)
00045 : Bus (name, busType, flags)
00046 , speakerArr (arr)
00047 {}
00048 
00049 //------------------------------------------------------------------------
00050 bool AudioBus::getInfo (BusInfo& info)
00051 {
00052         info.channelCount = SpeakerArr::getChannelCount (speakerArr);
00053         return Bus::getInfo (info);
00054 }
00055 
00056 //------------------------------------------------------------------------
00057 // AudioEffect
00058 //------------------------------------------------------------------------
00059 AudioEffect::AudioEffect ()
00060 {
00061         processSetup.maxSamplesPerBlock = 1024;
00062         processSetup.processMode = Vst::kRealtime;
00063         processSetup.sampleRate = 44100.0;
00064         processSetup.symbolicSampleSize = Vst::kSample32;
00065 }
00066 
00067 //------------------------------------------------------------------------
00068 tresult PLUGIN_API AudioEffect::queryInterface (const char* iid, void** obj)
00069 {
00070         QUERY_INTERFACE (iid, obj, IAudioProcessor::iid, IAudioProcessor)
00071         return Component::queryInterface (iid, obj);
00072 }
00073 
00074 //------------------------------------------------------------------------
00075 AudioBus* AudioEffect::addAudioInput (const TChar* name, SpeakerArrangement arr, 
00076                                                                           BusType busType, int32 flags)
00077 {
00078         AudioBus* newBus = new AudioBus (name, busType, flags, arr);
00079         audioInputs.append (newBus);
00080         return newBus;
00081 }
00082 
00083 //------------------------------------------------------------------------
00084 AudioBus* AudioEffect::addAudioOutput (const TChar* name, SpeakerArrangement arr, 
00085                                                                            BusType busType, int32 flags)
00086 {
00087         AudioBus* newBus = new AudioBus (name, busType, flags, arr);
00088         audioOutputs.append (newBus);
00089         return newBus;
00090 }
00091 
00092 //------------------------------------------------------------------------
00093 EventBus* AudioEffect::addEventInput (const TChar* name, int32 channels, 
00094                                                                           BusType busType, int32 flags)
00095 {
00096         EventBus* newBus = new EventBus (name, busType, flags, channels);
00097         eventInputs.append (newBus);
00098         return newBus;
00099 }
00100 
00101 //------------------------------------------------------------------------
00102 EventBus* AudioEffect::addEventOutput (const TChar* name, int32 channels, 
00103                                                                            BusType busType, int32 flags)
00104 {
00105         EventBus* newBus = new EventBus (name, busType, flags, channels);
00106         eventOutputs.append (newBus);
00107         return newBus;
00108 }
00109 
00110 //------------------------------------------------------------------------
00111 tresult PLUGIN_API AudioEffect::setBusArrangements (SpeakerArrangement* inputs, int32 numIns, 
00112                                                                                                         SpeakerArrangement* outputs, int32 numOuts)
00113 {
00114         int32 counter = 0;
00115         LIST_FOREACH (AudioBus, bus, audioInputs)
00116                 if (counter < numIns)
00117                         bus->setArrangement (inputs[counter]);
00118                 counter++;
00119         LIST_ENDFOR
00120 
00121         counter = 0;
00122         LIST_FOREACH (AudioBus, bus, audioOutputs)
00123                 if (counter < numOuts)
00124                         bus->setArrangement (outputs[counter]);
00125                 counter++;
00126         LIST_ENDFOR
00127 
00128         return kResultTrue;
00129 }
00130 
00131 //------------------------------------------------------------------------
00132 tresult PLUGIN_API AudioEffect::getBusArrangement (BusDirection dir, int32 busIndex, SpeakerArrangement& arr)
00133 {
00134         BusList* busList = getBusList (kAudio, dir);
00135         AudioBus* audioBus = busList ? (AudioBus*)busList->at (busIndex) : 0;
00136         if (audioBus)
00137         {
00138                 arr = audioBus->getArrangement ();
00139                 return kResultTrue;
00140         }
00141         return kResultFalse;
00142 }
00143 
00144 //------------------------------------------------------------------------
00145 tresult PLUGIN_API AudioEffect::setupProcessing (ProcessSetup& newSetup)
00146 {
00147         if (newSetup.symbolicSampleSize != kSample32)
00148                 return kResultFalse;
00149 
00150         processSetup = newSetup;
00151         return kResultOk;
00152 }
00153 
00154 //------------------------------------------------------------------------
00155 tresult PLUGIN_API AudioEffect::setProcessing (TBool state)
00156 {
00157         return kNotImplemented;
00158 }
00159 
00160 //------------------------------------------------------------------------
00161 tresult PLUGIN_API AudioEffect::canProcessSampleSize (int32 symbolicSampleSize)
00162 {
00163         return symbolicSampleSize == kSample32 ? kResultTrue : kResultFalse;
00164 }
00165 
00166 //------------------------------------------------------------------------
00167 tresult PLUGIN_API AudioEffect::process (ProcessData& data)
00168 {
00169         return kNotImplemented;
00170 }
00171 
00172 } // namespace Vst
00173 } // namespace Steinberg
Empty

Copyright ©2008 Steinberg Media Technologies. All Rights Reserved.