14#include "public.sdk/source/vst/vstbus.h"
15#include "pluginterfaces/base/ustring.h"
16#include "pluginterfaces/vst/ivstevents.h"
20#include "IPlugVST3_Defs.h"
23#ifdef CUSTOM_BUSTYPE_FUNC
24extern uint64_t GetAPIBusTypeForChannelIOConfig(
int configIdx, iplug::ERoute dir,
int busIdx,
const iplug::IOConfig* pConfig, WDL_TypedBuf<uint64_t>* APIBusTypes =
nullptr);
30#ifndef CUSTOM_BUSTYPE_FUNC
31uint64_t GetAPIBusTypeForChannelIOConfig(
int configIdx,
ERoute dir,
int busIdx,
const IOConfig* pConfig, WDL_TypedBuf<uint64_t>* APIBusTypes =
nullptr);
41 void Initialize(T* pPlug)
43 using namespace Steinberg::Vst;
45 Steinberg::Vst::String128 tmpStringBuf;
48 int configWithMostInputBuses = 0;
49 int configWithMostOutputBuses = 0;
50 MaxNBuses(ERoute::kInput, &configWithMostInputBuses);
51 int maxNOutBuses =
MaxNBuses(ERoute::kOutput, &configWithMostOutputBuses);
57 int nIn = pConfig->
NBuses(ERoute::kInput);
58 for (
auto busIdx = 0; busIdx < nIn; busIdx++)
60 uint64_t busType = GetAPIBusTypeForChannelIOConfig(configWithMostInputBuses, ERoute::kInput, busIdx, pConfig);
62 int flags = busIdx == 0 ? flags = BusInfo::BusFlags::kDefaultActive : flags = 0;
64 GetBusName(ERoute::kInput, busIdx, nIn, busName);
65 Steinberg::UString(tmpStringBuf, 128).fromAscii(busName.Get(), 128);
66 pPlug->addAudioInput(tmpStringBuf, busType, busIdx > 0 ? kAux : kMain, flags);
73 int nOut = pConfig->
NBuses(ERoute::kOutput);
75 for (
auto busIdx = 0; busIdx < nOut; busIdx++)
77 uint64_t busType = GetAPIBusTypeForChannelIOConfig(configWithMostOutputBuses, ERoute::kOutput, busIdx, pConfig);
78 int flags = busIdx == 0 ? flags = BusInfo::BusFlags::kDefaultActive : flags = 0;
80 GetBusName(ERoute::kOutput, busIdx, nOut, busName);
81 Steinberg::UString(tmpStringBuf, 128).fromAscii(busName.Get(), 128);
82 pPlug->addAudioOutput(tmpStringBuf, busType, busIdx > 0 ? kAux : kMain, flags);
89 Steinberg::UString(tmpStringBuf, 128).fromAscii(
"Dummy Output", 128);
90 pPlug->addAudioOutput(tmpStringBuf, Steinberg::Vst::SpeakerArr::kEmpty, Steinberg::Vst::BusTypes::kMain, flags);
94 pPlug->addEventInput(STR16(
"MIDI Input"), VST3_NUM_MIDI_IN_CHANS);
97 pPlug->addEventOutput(STR16(
"MIDI Output"), VST3_NUM_MIDI_OUT_CHANS);
102 void ProcessMidiOut(
IPlugQueue<SysExData>& sysExQueue,
SysExData& sysExBuf, Steinberg::Vst::IEventList* pOutputEvents, Steinberg::int32 numSamples);
106 bool SetBusArrangements(T* pPlug, Steinberg::Vst::SpeakerArrangement* pInputBusArrangements, Steinberg::int32 numInBuses, Steinberg::Vst::SpeakerArrangement* pOutputBusArrangements, Steinberg::int32 numOutBuses)
108 using namespace Steinberg::Vst;
111 if ((pPlug->GetHost() == kHostMixbus32C) || (pPlug->GetHost() == kHostArdour))
117 SetChannelConnections(ERoute::kInput, 0,
MaxNChannels(ERoute::kInput),
false);
118 SetChannelConnections(ERoute::kOutput, 0,
MaxNChannels(ERoute::kOutput),
false);
120 const int maxNInBuses =
MaxNBuses(ERoute::kInput);
121 const int maxNOutBuses =
MaxNBuses(ERoute::kOutput);
124 if(numInBuses > maxNInBuses || numOutBuses > maxNOutBuses)
127 std::vector<int> inputBuses;
128 std::vector<int> outputBuses;
130 for(
int i = 0; i< numInBuses; i++)
132 inputBuses.push_back(SpeakerArr::getChannelCount(pInputBusArrangements[i]));
135 for(
int i = 0; i< numOutBuses; i++)
137 outputBuses.push_back(SpeakerArr::getChannelCount(pOutputBusArrangements[i]));
141 Steinberg::Vst::String128 tmpStringBuf;
145 pPlug->removeAudioBusses();
148 const int nIn = pConfig->
NBuses(ERoute::kInput);
150 for (
auto inBusIdx = 0; inBusIdx < nIn; inBusIdx++)
152 const int flags = inBusIdx == 0 ? BusInfo::BusFlags::kDefaultActive : 0;
153 SpeakerArrangement arr = GetAPIBusTypeForChannelIOConfig(matchingIdx, ERoute::kInput, inBusIdx, pConfig);
156 GetBusName(ERoute::kInput, inBusIdx, nIn, busName);
157 Steinberg::UString(tmpStringBuf, 128).fromAscii(busName.Get(), 128);
158 pPlug->addAudioInput(tmpStringBuf, arr, (BusTypes) inBusIdx > 0, flags);
161 const int nOut = pConfig->
NBuses(ERoute::kOutput);
163 for(
auto outBusIdx = 0; outBusIdx < nOut; outBusIdx++)
165 int flags = outBusIdx == 0 ? BusInfo::BusFlags::kDefaultActive : 0;
166 SpeakerArrangement arr = GetAPIBusTypeForChannelIOConfig(matchingIdx, ERoute::kOutput, outBusIdx, pConfig);
169 GetBusName(ERoute::kOutput, outBusIdx, nOut, busName);
170 Steinberg::UString(tmpStringBuf, 128).fromAscii(busName.Get(), 128);
171 pPlug->addAudioOutput(tmpStringBuf, arr, (BusTypes) outBusIdx > 0, flags);
180 void AttachBuffers(
ERoute direction,
int idx,
int n, Steinberg::Vst::AudioBusBuffers& pBus,
int nFrames, Steinberg::int32 sampleSize);
181 bool SetupProcessing(
const Steinberg::Vst::ProcessSetup& setup, Steinberg::Vst::ProcessSetup& storedSetup);
182 bool CanProcessSampleSize(Steinberg::int32 symbolicSampleSize);
183 bool SetProcessing(
bool state);
186 void PrepareProcessContext(Steinberg::Vst::ProcessData& data, Steinberg::Vst::ProcessSetup& setup);
187 void ProcessParameterChanges(Steinberg::Vst::ProcessData& data,
IPlugQueue<IMidiMsg>& fromProcessor);
188 void ProcessAudio(Steinberg::Vst::ProcessData& data, Steinberg::Vst::ProcessSetup& setup,
const Steinberg::Vst::BusList& ins,
const Steinberg::Vst::BusList& outs);
195 int mMaxNChansForMainInputBus = 0;
197 Steinberg::Vst::ProcessContext mProcessContext;
199 bool mSidechainActive =
false;
The base class of an IPlug plug-in, which interacts with the different plug-in APIs.
The base class for IPlug Audio Processing.
const IOConfig * GetIOConfig(int idx) const
virtual void GetBusName(ERoute direction, int busIdx, int nBuses, WDL_String &str) const
Get the name for a particular bus.
bool IsMidiEffect() const
int MaxNBuses(ERoute direction, int *pConfigIdxWithTheMostBuses=nullptr) const
Used to determine the maximum number of input or output buses based on what was specified in the chan...
int GetIOConfigWithChanCounts(std::vector< int > &inputBuses, std::vector< int > &outputBuses)
int MaxNChannels(ERoute direction) const
A lock-free SPSC queue used to transfer data between threads based on MLQueue.h by Randy Jones based ...
Shared VST3 processor code.
bool SendMidiMsg(const IMidiMsg &msg) override
Send a single MIDI message // TODO: info about what thread should this be called on or not called on!
ERoute
Used to identify whether a bus/channel connection is an input or an output.
Encapsulates a MIDI message and provides helper functions.
An IOConfig is used to store bus info for each input/output configuration defined in the channel io s...
int NBuses(ERoute direction) const
This structure is used when queueing Sysex messages.