ASPiK SDK
Loading...
Searching...
No Matches
vst3plugin.h
1// --- header
2#ifndef __VST3Plugin__
3#define __VST3Plugin__
4
5// --- VST3
6#include "public.sdk/source/vst/vstsinglecomponenteffect.h"
7#include "pluginterfaces/vst/ivstparameterchanges.h"
8
9// --- MIDI EVENTS
10#include "pluginterfaces/vst/ivstevents.h"
11
12// --- WString Support
13#include "pluginterfaces/base/ustring.h"
14
15// --- our plugin core object
16#include "plugincore.h"
17#include "plugingui.h"
18
19// --- windows.h bug
20#define ENABLE_WINDOWS_H 1
21
22#if MAC
23#include <CoreFoundation/CoreFoundation.h>
24#else
25#ifdef ENABLE_WINDOWS_H
26 #include <windows.h>
27#endif
28extern void* hInstance; // VSTGUI hInstance
29#endif
30
31#include <vector>
32
33namespace Steinberg {
34namespace Vst {
35namespace ASPiK {
36/*
37 The Processor object here ALSO contains the Edit Controller component since these
38 are combined as SingleComponentEffect; see documentation
39*/
40class VSTParamUpdateQueue;
43class VSTMIDIEventQueue;
44
45// --- sets up proxy MIDI CC parameters for one MIDI channel (these are shared across ALL MIDI channels)
46// IF you want to have separate CC's decoded on separated channels, you need to duplicate this 15 (more) times
47// see: https://forums.steinberg.net/t/vst3-and-midi-cc-pitfall/201879
48//
49// --- this sets up proxy parameters for the 128 MIDI CC [0, 127] + aftertouch [128] + pitchbend [129]
50// thus the range of 130 IDs, from 1000 to 1129
51const ParamID baseCCParamID = 1000; // *** VST3 MIDI CC Proxy Variables STATRT Channel 0, shared with all other channels
52const ParamID baseCCParamIDEnd = 1129; // *** VST3 MIDI CC Proxy Variables END Channel 0, shared with all other channels
53
54// --- MIDI helpers; replace with your own if needed
55const unsigned char CONTROL_CHANGE = 0xB0;
56const unsigned char CHANNEL_PRESSURE = 0xD0;
57const unsigned char PITCH_BEND = 0xE0;
58
70class VST3Plugin : public SingleComponentEffect, public IMidiMapping
71{
72public:
73 // --- constructor
74 VST3Plugin();
75
76 // --- destructor
78
79 /*** IAudioProcessor Interface ***/
81 tresult PLUGIN_API initialize(FUnknown* context) override;
82
84 tresult PLUGIN_API setBusArrangements(SpeakerArrangement* inputs, int32 numIns, SpeakerArrangement* outputs, int32 numOuts) override;
85
87 tresult PLUGIN_API canProcessSampleSize(int32 symbolicSampleSize) override;
88
90 tresult PLUGIN_API setupProcessing(ProcessSetup& newSetup) override;
91
93 tresult PLUGIN_API setActive(TBool state) override;
94
96 // These get/set the plugin variables
97 tresult PLUGIN_API setState(IBStream* fileStream) override;
98 tresult PLUGIN_API getState(IBStream* fileStream) override;
99
101 // Update the GUI control variables
102 bool doControlUpdate(ProcessData& data);
103
105 tresult PLUGIN_API process(ProcessData& data) override;
106
108 virtual tresult PLUGIN_API getMidiControllerAssignment(int32 busIndex, int16 channel, CtrlNumber midiControllerNumber, ParamID& id/*out*/) override;
109
110 // --- issue a MIDI CC message from a proxy parameter value
111 // see: https://forums.steinberg.net/t/vst3-and-midi-cc-pitfall/201879
112 bool issueMIDICCProxyMessage(ParamID proxyParamID, ParamValue proxyParamValue);
113
114 // --- helper function for the proxy method
115 inline void unipolarDoubleToMIDI14_bit(double unipolarValue, uint32_t& midiDataLSB, uint32_t& midiDataMSB)
116 {
117 // --- convert to 16-bit unsigned short
118 unsigned short shValue = (unsigned short)(unipolarValue * (double)(0x4000));
119 unsigned short shd1 = shValue & 0x007F;
120
121 // --- shift back by 1
122 unsigned short shd2 = shValue << 1;
123
124 // --- split into MSB, LSB
125 shd2 = shd2 & 0x7F00;
126
127 // --- shift MSB back to fill LSB position
128 shd2 = shd2 >> 8;
129
130 // --- copy into unsigned ints, fill lower portions
131 midiDataLSB = shd1;
132 midiDataMSB = shd2;
133 }
134
136 IPlugView* PLUGIN_API createView(const char* _name) override;
137
139 tresult PLUGIN_API terminate() override;
140
142 virtual tresult receiveText(const char8* text) override;
143
145 tresult PLUGIN_API setParamNormalizedFromFile(ParamID tag, ParamValue value);
146
148 tresult PLUGIN_API setComponentState(IBStream* fileStream) override;
149
151 void updateMeters(ProcessData& data, bool forceOff = false);
152
154 static FUnknown* createInstance(void* context) {return (IAudioProcessor*)new VST3Plugin(); }
155
156 tresult PLUGIN_API setParamNormalized(ParamID tag, ParamValue value) override;
157
159 virtual tresult PLUGIN_API getProgramName(ProgramListID listId, int32 programIndex, String128 name /*out*/) override;
160
162 virtual void PLUGIN_API update(FUnknown* changedUnknown, int32 message) override ;
163
164 // --- latency support
166
168 virtual uint32 PLUGIN_API getLatencySamples() override {
169 return m_uLatencyInSamples; }
170
172 virtual uint32 PLUGIN_API getTailSamples() override ;
173
175 void updateHostInfo(ProcessData& data, HostInfo* hostInfo);
176
177 static FUID* getFUID();
178 static const char* getPluginName();
179 static const char* getVendorName();
180 static const char* getVendorURL();
181 static const char* getVendorEmail();
182 static CString getPluginType();
183
184 // --- define the IMidiMapping interface
185 OBJ_METHODS(VST3Plugin, SingleComponentEffect)
186 DEFINE_INTERFACES
187 DEF_INTERFACE(IMidiMapping)
188 DEF_INTERFACE(IUnitInfo)
189 END_DEFINE_INTERFACES(SingleComponentEffect)
190 REFCOUNT_METHODS(SingleComponentEffect)
191
192
193private:
194 // --- our plugin core and interfaces
195 PluginCore* pluginCore = nullptr;
196 GUIPluginConnector* guiPluginConnector = nullptr;
197 PluginHostConnector* pluginHostConnector = nullptr;
198 VSTMIDIEventQueue* midiEventQueue = nullptr;
199 bool plugInSideBypass = false;
200 bool hasSidechain = false;
201
202protected:
203 // --- sample accurate parameter automation
205 unsigned int sampleAccuracy = 1;
206 bool enableSAAVST3 = false;
207
208 // --- IUnitInfo and factory Preset support
209 typedef std::vector<IPtr<ProgramList> > ProgramListVector;
210 typedef std::map<ProgramListID, ProgramListVector::size_type> ProgramIndexMap;
211 typedef std::vector<IPtr<Unit> > UnitVector;
212 UnitVector units;
213 ProgramListVector programLists;
214 ProgramIndexMap programIndexMap;
215 UnitID selectedUnit;
216
217
218#if defined _WINDOWS || defined _WINDLL
219#ifdef ENABLE_WINDOWS_H
220 wchar_t* convertCharArrayToLPCWSTR(const char* charArray)
221 {
222 wchar_t* wString = new wchar_t[4096];
223 MultiByteToWideChar(CP_ACP, 0, charArray, -1, wString, 4096);
224 return wString;
225 }
226
227 // --- getMyDLLDirectory()
228 // returns the directory where the .component resides
229 char* getMyDLLDirectory(const char* cPluginName)
230 {
231 wchar_t* piName = convertCharArrayToLPCWSTR(cPluginName);
232 if (!piName) return nullptr;
233
234 HMODULE hmodule = GetModuleHandle(piName);
235 delete[] piName;
236 TCHAR dir[MAX_PATH];
237 memset(&dir[0], 0, MAX_PATH*sizeof(TCHAR));
238 dir[MAX_PATH-1] = '\0';
239
240 if(hmodule)
241 GetModuleFileName(hmodule, &dir[0], MAX_PATH);
242 else
243 return nullptr;
244
245 char fullPath[MAX_PATH];
246 size_t nNumCharConverted;
247 wcstombs_s(&nNumCharConverted, fullPath, MAX_PATH, dir, MAX_PATH);
248 char* pDLLRoot = new char[MAX_PATH];
249 size_t nLenDir = strlen(fullPath);
250 size_t nLenDLL = strlen(cPluginName); // +1 is for trailing backslash
251 memcpy(pDLLRoot, fullPath, nLenDir-nLenDLL);
252 pDLLRoot[nLenDir-nLenDLL] = '\0';
253
254 // caller must delete this after use
255 return pDLLRoot;
256 }
257#endif
258#endif
259#if MAC
260 // --- getMyComponentDirectory()
261 // returns the directory where the .component resides
262 char* getMyComponentDirectory(CFStringRef bundleID)
263 {
264 if (bundleID != nullptr)
265 {
266 CFBundleRef helixBundle = CFBundleGetBundleWithIdentifier( bundleID );
267 if(helixBundle != nullptr)
268 {
269 CFURLRef bundleURL = CFBundleCopyBundleURL ( helixBundle );
270 if(bundleURL != nullptr)
271 {
272 CFURLRef componentFolderPathURL = CFURLCreateCopyDeletingLastPathComponent(nullptr, bundleURL);
273
274 CFStringRef myComponentPath = CFURLCopyFileSystemPath(componentFolderPathURL, kCFURLPOSIXPathStyle);
275 CFRelease(componentFolderPathURL);
276
277 if(myComponentPath != nullptr)
278 {
279 int nSize = CFStringGetLength(myComponentPath);
280 char* path = new char[nSize+1];
281 memset(path, 0, (nSize+1)*sizeof(char));
282
283 bool success = CFStringGetCString(myComponentPath, path, nSize+1, kCFStringEncodingASCII);
284 CFRelease(myComponentPath);
285
286 if(success) return path;
287 else return nullptr;
288 }
289 CFRelease(bundleURL);
290 }
291 }
292 CFRelease(bundleID);
293 }
294 return nullptr;
295 }
296#endif
297
298};
299
314{
315protected:
316 unsigned int bufferSize = 0;
317 ParamValue initialValue = 0.0;
318 ParamValue previousValue = 0.0;
319 ParamValue maxValue = 0.0;
320 ParamValue minValue = 0.0;
321
322 // --- Store slope and b so that it needs to be calculated only once.
323 ParamValue slope;
324 ParamValue yIntercept;
325
326 // --- Controls granularity
327 unsigned int* sampleAccuracy = nullptr;
328 int queueIndex = 0;
329 int queueSize = 0;
330 IParamValueQueue* parameterQueue = nullptr;
331 int x1, x2 = 0;
332 double y1, y2 = 0;
333 bool dirtyBit = false;
334 int sampleOffset = 0;
335
336public:
338 virtual ~VSTParamUpdateQueue(void){}
339 void initialize(ParamValue _initialValue, ParamValue _minValue, ParamValue _maxValue, unsigned int* _sampleAccuracy);
340 void setParamValueQueue(IParamValueQueue* _paramValueQueue, unsigned int _bufferSize);
341 void setSlope();
342 ParamValue interpolate(int x1, int x2, ParamValue y1, ParamValue y2, int x);
343 int needsUpdate(int x, ParamValue &value);
344
345 // --- IParameterUpdateQueue
346 unsigned int getParameterIndex();
347 bool getValueAtOffset(long int _sampleOffset, double _previousValue, double& _nextValue);
348 bool getNextValue(double& _nextValue);
349};
350
351
352
372{
373public:
374 PluginHostConnector(VST3Plugin* _editController) {editController = _editController;}
375 virtual ~PluginHostConnector(){}
376
382 virtual void sendHostMessage(const HostMessageInfo& hostMessageInfo)
383 {
384 switch(hostMessageInfo.hostMessage)
385 {
386 case sendGUIUpdate:
387 {
388 GUIUpdateData guiUpdateData = hostMessageInfo.guiUpdateData;
389
390 for(unsigned int i = 0; i < guiUpdateData.guiParameters.size(); i++)
391 {
392 GUIParameter guiParam = guiUpdateData.guiParameters[i];
394 {
395 ParamValue normalizedValue = editController->plainParamToNormalized(guiParam.controlID, guiParam.actualValue);
396 editController->setParamNormalized(guiParam.controlID, normalizedValue);
397 }
398 }
399
400 // --- clean up
401 for (unsigned int i = 0; i < guiUpdateData.guiParameters.size(); i++)
402 guiUpdateData.guiParameters.pop_back();
403
404 break;
405 }
406 default:
407 break;
408 }
409 }
410
411protected:
413};
414
415// --- GUI -> Plugin interface
431{
432public:
434 CustomViewController(ICustomView* _customViewIF) { customViewIF = _customViewIF; }
435 virtual ~CustomViewController() {}
436
438 virtual void updateView()
439 {
440 if (customViewIF)
441 customViewIF->updateView();
442 }
443
445 virtual void pushDataValue(double data)
446 {
447 if (customViewIF)
448 customViewIF->pushDataValue(data);
449 }
450
452 virtual void sendMessage(void* data)
453 {
454 if (customViewIF)
455 customViewIF->sendMessage(data);
456 }
457
459 void setCustomViewPtr(ICustomView* _customViewIF) { customViewIF = _customViewIF; }
460
462 const ICustomView* getCustomViewPtr() { return customViewIF; }
463
465 void clearCustomViewPtr() { customViewIF = nullptr; }
466
467
468private:
469 ICustomView* customViewIF = nullptr;
470};
471
493{
494public:
496 GUIPluginConnector(PluginCore* _pluginCore, VST3Plugin* _editController)
497 {
498 pluginCore = _pluginCore;
499 editController = _editController;
500 }
501
504 {
505 for (customViewControllerMap::const_iterator it = customSubControllerMap.begin(), end = customSubControllerMap.end(); it != end; ++it)
506 {
507 delete it->second;
508 }
509 for (customViewControllerMap::const_iterator it = customViewMap.begin(), end = customViewMap.end(); it != end; ++it)
510 {
511 delete it->second;
512 }
513 }
514
516 virtual void parameterChanged(int32_t controlID, double actualValue, double normalizedValue)
517 {
518 if(pluginCore)
519 pluginCore->guiParameterChanged(controlID, actualValue);
520
521 if(!editController) return;
522
523 // --- set parameter on object
524 editController->setParamNormalized(controlID, normalizedValue);
525
526 // --- perform the operation
527 editController->performEdit(controlID, normalizedValue);
528 }
529
531 virtual double getNormalizedPluginParameter(int32_t controlID)
532 {
533 if(!editController) return 0.0;
534
535 Parameter* param = editController->getParameterObject(controlID);
536 if(!param) return 0.0;
537
538 return param->getNormalized();
539 }
540
542 virtual double getActualPluginParameter(int32_t controlID)
543 {
544 if (!editController) return 0.0;
545
546 Parameter* param = editController->getParameterObject(controlID);
547 if (!param) return 0.0;
548
549 // --- get normalized and convert
550 double normalizedValue = param->getNormalized();
551 return param->toPlain(normalizedValue);
552 }
553
554
556 virtual bool registerSubcontroller(std::string subcontrollerName, ICustomView* customViewConnector)
557 {
558 // --- do we have this in our map already?
559 CustomViewController* pCVC = nullptr;
560
561 customViewControllerMap::const_iterator it = customSubControllerMap.find(subcontrollerName);
562 if (it != customSubControllerMap.end())
563 {
564 pCVC = it->second;
565 pCVC->setCustomViewPtr(customViewConnector);
566 }
567 else
568 {
569 pCVC = new CustomViewController(customViewConnector);
570 customSubControllerMap.insert(std::make_pair(subcontrollerName, pCVC));
571 }
572
573 MessageInfo info(PLUGINGUI_REGISTER_SUBCONTROLLER);
574 info.inMessageString = subcontrollerName;
575 info.inMessageData = pCVC;
576
578 return true;
579
580 return false;
581 }
582
584 virtual bool deRregisterSubcontroller(ICustomView* customViewConnector)
585 {
586 CustomViewController* pCVC = getCustomSubController(customViewConnector);
587 if (pCVC)
588 {
589 pCVC->clearCustomViewPtr();
590
591 MessageInfo info(PLUGINGUI_DE_REGISTER_SUBCONTROLLER);
592 info.inMessageString = "";
593 info.inMessageData = pCVC;
594
596 return true;
597 }
598
599 return false;
600 }
601
603 virtual bool registerCustomView(std::string customViewName, ICustomView* customViewConnector)
604 {
605 // --- do we have this in our map already?
606 CustomViewController* pCVC = nullptr;
607
608 customViewControllerMap::const_iterator it = customViewMap.find(customViewName);
609 if (it != customViewMap.end())
610 {
611 pCVC = it->second;
612 pCVC->setCustomViewPtr(customViewConnector);
613 }
614 else
615 {
616 pCVC = new CustomViewController(customViewConnector);
617 customViewMap.insert(std::make_pair(customViewName, pCVC));
618 }
619
620 MessageInfo info(PLUGINGUI_REGISTER_CUSTOMVIEW);
621 info.inMessageString = customViewName;
622 info.inMessageData = pCVC;
623
625 return true;
626
627 return false;
628 }
629
631 virtual bool deRegisterCustomView(ICustomView* customViewConnector)
632 {
633 CustomViewController* pCVC = getCustomViewController(customViewConnector);
634 if (pCVC)
635 {
636 // --- clear it
637 pCVC->clearCustomViewPtr();
638
639 MessageInfo info(PLUGINGUI_DE_REGISTER_CUSTOMVIEW);
640 info.inMessageString = "";
641 info.inMessageData = pCVC;
642
644 return true;
645 }
646
647 return false;
648 }
649
651 virtual bool guiDidOpen()
652 {
653 if(!pluginCore) return false;
654 MessageInfo info(PLUGINGUI_DIDOPEN);
655 return pluginCore->processMessage(info);
656 }
657
659 virtual bool guiWillClose()
660 {
661 if(!pluginCore) return false;
662
663 for (customViewControllerMap::const_iterator it = customViewMap.begin(), end = customViewMap.end(); it != end; ++it)
664 {
665 it->second->clearCustomViewPtr();
666 }
667 for (customViewControllerMap::const_iterator it = customSubControllerMap.begin(), end = customSubControllerMap.end(); it != end; ++it)
668 {
669 it->second->clearCustomViewPtr();
670 }
671
672 MessageInfo info(PLUGINGUI_WILLCLOSE);
673 return pluginCore->processMessage(info);
674 }
675
677 virtual bool guiTimerPing()
678 {
679 if(!pluginCore) return false;
680 MessageInfo info(PLUGINGUI_TIMERPING);
681 return pluginCore->processMessage(info);
682 }
683
685 virtual bool checkNonBoundValueChange(int tag, float normalizedValue)
686 {
687 if(!pluginCore) return false;
688
689 // --- do any additional stuff here
690 // --- dispatch non-bound value changes directly to receiver
691
692 return false;
693 }
694
695protected:
698
699 // --- this is for supporting the persistent interface pointer for the core object
700 // and is required by ASPiK Specifications
701 typedef std::map<std::string, CustomViewController*> customViewControllerMap;
702 customViewControllerMap customViewMap;
703
706 {
707 for (customViewControllerMap::const_iterator it = customViewMap.begin(), end = customViewMap.end(); it != end; ++it)
708 {
709 if (it->second->getCustomViewPtr() == customViewConnector)
710 return it->second;
711 }
712
713 return nullptr;
714 }
715
717
720 {
721 for (customViewControllerMap::const_iterator it = customSubControllerMap.begin(), end = customSubControllerMap.end(); it != end; ++it)
722 {
723 if (it->second->getCustomViewPtr() == customViewConnector)
724 return it->second;
725 }
726
727 return nullptr;
728 }
729
730};
731
748{
749public:
750 VSTMIDIEventQueue(PluginCore* _pluginCore)
751 {
752 pluginCore = _pluginCore;
753 };
754
755 virtual ~VSTMIDIEventQueue(){ clearMIDIProxyEvents(); }
756
757public:
758 // --- VST3 only for CC mess
759 void clearMIDIProxyEvents()
760 {
761 proxyMIDIEvents.clear();
762 }
763
764 void addMIDIProxyEvent(midiEvent& event)
765 {
766 proxyMIDIEvents.push_back(event);
767 }
768
770 void setEventList(IEventList* _inputEvents)
771 {
772 inputEvents = _inputEvents;
774 }
775
777 virtual unsigned int getEventCount()
778 {
779 if (inputEvents)
780 return inputEvents->getEventCount();
781
782 return 0;
783 }
784
786 virtual bool fireMidiEvents(unsigned int sampleOffset)
787 {
788 if (sampleOffset == 0 && pluginCore)
789 {
790 uint32_t count = (uint32_t)proxyMIDIEvents.size();
791 for (uint32_t i = 0; i < count; i++)
792 {
793 pluginCore->processMIDIEvent(proxyMIDIEvents[i]);
794 }
795 }
796
797 if (!inputEvents)
798 return false;
799
800 Event e = { 0 };
801 bool eventOccurred = false;
802 bool haveEvents = false;
803 if (inputEvents->getEvent(currentEventIndex, e) == kResultTrue)
804 haveEvents = true;
805 else
806 return false;
807
808 const unsigned char MIDI_NOTE_OFF = 0x80;
809 const unsigned char MIDI_NOTE_ON = 0x90;
810 const unsigned char MIDI_POLY_PRESSURE = 0xA0;
811
812 while (haveEvents)
813 {
814 if (inputEvents->getEvent(currentEventIndex, e) == kResultTrue)
815 {
816 if (e.sampleOffset != sampleOffset)
817 return false;
818
819 // --- process Note On or Note Off messages
820 switch (e.type)
821 {
822 // --- NOTE ON
823 case Event::kNoteOnEvent:
824 {
825 midiEvent event;
826 event.midiMessage = (unsigned int)MIDI_NOTE_ON;
827 event.midiChannel = (unsigned int)e.noteOn.channel;
828 event.midiData1 = (unsigned int)e.noteOn.pitch;
829 event.midiData2 = (unsigned int)(127.0*e.noteOn.velocity);
830 event.midiSampleOffset = e.sampleOffset;
831 eventOccurred = true;
832
833 // --- send to core for processing
834 if(pluginCore)
836 break;
837 }
838
839 // --- NOTE OFF
840 case Event::kNoteOffEvent:
841 {
842 // --- get the channel/note/vel
843 midiEvent event;
844 event.midiMessage = (unsigned int)MIDI_NOTE_OFF;
845 event.midiChannel = (unsigned int)e.noteOff.channel;
846 event.midiData1 = (unsigned int)e.noteOff.pitch;
847 event.midiData2 = (unsigned int)(127.0*e.noteOff.velocity);
848 event.midiSampleOffset = e.sampleOffset;
849 eventOccurred = true;
850
851 // --- send to core for processing
852 if(pluginCore)
854
855 break;
856 }
857
858 // --- polyphonic aftertouch 0xAn
859 case Event::kPolyPressureEvent:
860 {
861 midiEvent event;
862 event.midiMessage = (unsigned int)MIDI_POLY_PRESSURE;
863 event.midiChannel = (unsigned int)e.polyPressure.channel;
864 event.midiData1 = (unsigned int)e.polyPressure.pitch;
865 event.midiData2 = (unsigned int)(127.0*e.polyPressure.pressure);
866 event.midiSampleOffset = e.sampleOffset;
867 eventOccurred = true;
868
869 // --- send to core for processing
870 if(pluginCore)
872
873 break;
874 }
875 } // switch
876
877 // --- have next event?
878 if (inputEvents->getEvent(currentEventIndex + 1, e) == kResultTrue)
879 {
880 if (e.sampleOffset == sampleOffset)
881 {
882 // --- avance current index
884 }
885 else
886 {
887 haveEvents = false;
888 currentEventIndex++; // setup for next time
889 }
890 }
891 else
892 haveEvents = false;
893 }
894 }
895
896 return eventOccurred;
897 }
898
899protected:
901 IEventList* inputEvents = nullptr;
902 unsigned int currentEventIndex = 0;
903 std::vector<midiEvent> proxyMIDIEvents;
904
905};
906
918class VST3UpdateHandler: public FObject
919{
920public:
921 VST3UpdateHandler(VSTGUI::ControlUpdateReceiver* _receiver, VST3Plugin* _editController){ receiver = _receiver; editController = _editController; }
923
924 virtual void PLUGIN_API update (FUnknown* changedUnknown, int32 message)
925 {
926 if(message == IDependent::kChanged && receiver && editController)
927 {
928 double normalizedValue = editController->getParamNormalized (receiver->getControlID());
929 receiver->updateControlsWithNormalizedValue(normalizedValue);
930 }
931 }
932
933private:
934 VSTGUI::ControlUpdateReceiver* receiver = nullptr;
935 VST3Plugin* editController = nullptr;
936
937};
938
939
951class PluginEditor: public CPluginView, public VSTGUI::PluginGUI, public IGUIWindowFrame
952{
953public:
954 PluginEditor(VSTGUI::UTF8StringPtr _xmlFile, PluginCore* _pluginCore, GUIPluginConnector* _guiPluginConnector, PluginHostConnector* _pluginHostConnector, VST3Plugin* editController);
955 virtual ~PluginEditor();
956
957 // --- aet of update handlers, specific to VST3: this will allow us to
958 // remotely update the GUI in a threadsafe and VST-approved manner
959 typedef std::map<int32_t, VST3UpdateHandler*> UpdaterHandlerMap;
960 UpdaterHandlerMap updateHandlers;
961
962 //---from IPlugView------- VST3 Specific
963 IPlugFrame* plugFrame;
964 const ViewRect& getRect() const { return rect; }
965 void setRect(const ViewRect& r) { rect = r; }
966 bool isAttached() const { return systemWindow != 0; }
967 virtual void attachedToParent() override {}
968 virtual void removedFromParent() override {}
969
970 virtual tresult PLUGIN_API attached(void* parent, FIDString type) override;
971 virtual tresult PLUGIN_API removed() override;
972 virtual tresult PLUGIN_API onWheel(float distance) override { return kResultFalse; }
973
974 virtual tresult PLUGIN_API isPlatformTypeSupported(FIDString type) override;
975 virtual tresult PLUGIN_API onSize(ViewRect* newSize) override;
976 virtual tresult PLUGIN_API getSize(ViewRect* size) override;
977
978 virtual tresult PLUGIN_API onFocus(TBool /*state*/) override { return kResultFalse; }
979 virtual tresult PLUGIN_API setFrame(IPlugFrame* frame) override;// { plugFrame = frame; return kResultTrue; }
980 virtual tresult PLUGIN_API canResize() override{ return kResultFalse /*kResultTrue*/; }
981 virtual tresult PLUGIN_API checkSizeConstraint(ViewRect* rect) override
982 {
983 if (showGUIEditor)
984 return kResultTrue;
985
986 // --- clamp it
987 ViewRect viewRect = getRect();
988 rect->right = viewRect.right;
989 rect->bottom = viewRect.bottom;
990
991 return kResultFalse;
992 }
993
994 virtual bool setWindowFrameSize(double left = 0, double top = 0, double right = 0, double bottom = 0) override //CRect* newSize)
995 {
996 ViewRect vr(0, 0, right, bottom);
997 setRect(vr);
998 if (plugFrame)
999 plugFrame->resizeView(this, &vr);
1000 return true;
1001 }
1002
1003 virtual bool getWindowFrameSize(double& left, double& top, double& right, double& bottom) override
1004 {
1005 ViewRect viewRect = getRect();
1006 left = 0.0;
1007 top = 0.0;
1008 right = viewRect.getWidth();
1009 bottom = viewRect.getHeight();
1010 return true;
1011 }
1012
1013protected:
1018};
1019
1020
1021
1022}}} // namespaces
1023
1024#endif
1025
1026
1027
1028
1029
The GUIPluginConnector interface creates a safe message mechanism for the GUI to issue requests to th...
Definition: AAXPluginParameters.h:600
Custom View interface to allow plugin core to create safe communication channels with GUI custom view...
Definition: pluginstructures.h:1462
virtual void updateView()=0
virtual void pushDataValue(double data)
Definition: pluginstructures.h:1472
virtual void sendMessage(void *data)
Definition: pluginstructures.h:1482
Custom interface so that GUI can pass information to plugin shell in a thread-safe manner.
Definition: pluginstructures.h:1540
Custom interface to allow resizing of GUI window; this is mainly used for the GUI designer.
Definition: pluginstructures.h:1497
Double buffered queue for MIDI messages.
Definition: pluginstructures.h:1628
Interface for VST3 parameter value update queue (sample accurate automation)
Definition: pluginstructures.h:1650
Custom interface to send the plugin shell a message from plugin core.
Definition: pluginstructures.h:1610
The PluginCore object is the default PluginBase derived object for ASPiK projects....
Definition: plugincore.h:44
virtual bool guiParameterChanged(int32_t controlID, double actualValue)
has nothing to do with actual variable or updated variable (binding)
Definition: plugincore.cpp:517
virtual bool processMIDIEvent(midiEvent &event)
process a MIDI event
Definition: plugincore.cpp:606
virtual bool processMessage(MessageInfo &messageInfo)
For Custom View and Custom Sub-Controller Operations.
Definition: plugincore.cpp:546
The PluginHostConnector implements the IPluginHostConnector interface for the plugin shell object....
Definition: AAXPluginParameters.h:480
The CustomViewController is part of the safe ICustomView feature in ASPiK. The CustomViewController m...
Definition: vst3plugin.h:431
CustomViewController(ICustomView *_customViewIF)
Definition: vst3plugin.h:434
virtual void updateView()
Definition: vst3plugin.h:438
void clearCustomViewPtr()
Definition: vst3plugin.h:465
const ICustomView * getCustomViewPtr()
Definition: vst3plugin.h:462
virtual void sendMessage(void *data)
Definition: vst3plugin.h:452
virtual void pushDataValue(double data)
Definition: vst3plugin.h:445
void setCustomViewPtr(ICustomView *_customViewIF)
Definition: vst3plugin.h:459
The GUIPluginConnector interface creates a safe message mechanism for the GUI to issue requests to th...
Definition: vst3plugin.h:493
customViewControllerMap customSubControllerMap
map of custom sub-controllers
Definition: vst3plugin.h:716
virtual ~GUIPluginConnector()
Definition: vst3plugin.h:503
CustomViewController * getCustomSubController(ICustomView *customViewConnector)
Definition: vst3plugin.h:719
virtual bool registerSubcontroller(std::string subcontrollerName, ICustomView *customViewConnector)
Definition: vst3plugin.h:556
virtual void parameterChanged(int32_t controlID, double actualValue, double normalizedValue)
Definition: vst3plugin.h:516
virtual double getActualPluginParameter(int32_t controlID)
Definition: vst3plugin.h:542
PluginCore * pluginCore
the core object
Definition: vst3plugin.h:696
virtual bool deRregisterSubcontroller(ICustomView *customViewConnector)
Definition: vst3plugin.h:584
virtual bool deRegisterCustomView(ICustomView *customViewConnector)
Definition: vst3plugin.h:631
std::map< std::string, CustomViewController * > customViewControllerMap
map of custom view controllers
Definition: vst3plugin.h:701
VST3Plugin * editController
the VST3
Definition: vst3plugin.h:697
virtual bool guiTimerPing()
Definition: vst3plugin.h:677
virtual double getNormalizedPluginParameter(int32_t controlID)
Definition: vst3plugin.h:531
CustomViewController * getCustomViewController(ICustomView *customViewConnector)
Definition: vst3plugin.h:705
GUIPluginConnector(PluginCore *_pluginCore, VST3Plugin *_editController)
Definition: vst3plugin.h:496
virtual bool guiDidOpen()
Definition: vst3plugin.h:651
virtual bool registerCustomView(std::string customViewName, ICustomView *customViewConnector)
Definition: vst3plugin.h:603
virtual bool guiWillClose()
Definition: vst3plugin.h:659
virtual bool checkNonBoundValueChange(int tag, float normalizedValue)
Definition: vst3plugin.h:685
The VST GUI for the plugin. This is needed because VST3 requires an IPlugView GUI,...
Definition: vst3plugin.h:952
virtual bool getWindowFrameSize(double &left, double &top, double &right, double &bottom) override
Definition: vst3plugin.h:1003
PluginHostConnector * pluginHostConnector
Plugin Host interface.
Definition: vst3plugin.h:1016
virtual tresult PLUGIN_API setFrame(IPlugFrame *frame) override
ASPiK support VST3 GUI - this wraps the ASPiK GUI so that it conforms to the IPlugView interface.
Definition: vst3plugin.cpp:1825
GUIPluginConnector * guiPluginConnector
GUI Plugin interface.
Definition: vst3plugin.h:1015
virtual tresult PLUGIN_API removed() override
ASPiK support VST3 GUI - this wraps the ASPiK GUI so that it conforms to the IPlugView interface.
Definition: vst3plugin.cpp:1941
virtual ~PluginEditor()
ASPiK support VST3 GUI - this wraps the ASPiK GUI so that it conforms to the IPlugView interface.
Definition: vst3plugin.cpp:1809
virtual tresult PLUGIN_API isPlatformTypeSupported(FIDString type) override
ASPiK support VST3 GUI - this wraps the ASPiK GUI so that it conforms to the IPlugView interface.
Definition: vst3plugin.cpp:1986
PluginCore * pluginCore
the core
Definition: vst3plugin.h:1014
virtual tresult PLUGIN_API attached(void *parent, FIDString type) override
ASPiK support VST3 GUI - this wraps the ASPiK GUI so that it conforms to the IPlugView interface.
Definition: vst3plugin.cpp:1842
VST3Plugin * editController
parent VST3
Definition: vst3plugin.h:1017
virtual tresult PLUGIN_API onSize(ViewRect *newSize) override
ASPiK support VST3 GUI - this wraps the ASPiK GUI so that it conforms to the IPlugView interface.
Definition: vst3plugin.cpp:2023
virtual tresult PLUGIN_API getSize(ViewRect *size) override
ASPiK support VST3 GUI - this wraps the ASPiK GUI so that it conforms to the IPlugView interface.
Definition: vst3plugin.cpp:2045
virtual bool setWindowFrameSize(double left=0, double top=0, double right=0, double bottom=0) override
Definition: vst3plugin.h:994
The PluginHostConnector implements the IPluginHostConnector interface for the plugin shell object....
Definition: vst3plugin.h:372
virtual void sendHostMessage(const HostMessageInfo &hostMessageInfo)
process a message; by default it processes sendGUIUpdate to safely send a parameter change event but ...
Definition: vst3plugin.h:382
VST3Plugin * editController
our parent plugin
Definition: vst3plugin.h:412
The VST3Plugin object is the ASPiK plugin shell for the VST3 API.
Definition: vst3plugin.h:71
tresult PLUGIN_API setupProcessing(ProcessSetup &newSetup) override
we get information about sample rate, bit-depth, etc...
Definition: vst3plugin.cpp:587
static FUnknown * createInstance(void *context)
Definition: vst3plugin.h:154
static const char * getPluginName()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1436
bool enableSAAVST3
sample accurate parameter automation
Definition: vst3plugin.h:206
tresult PLUGIN_API setState(IBStream *fileStream) override
This is the READ part of the serialization process. We get the stream interface and use it to read fr...
Definition: vst3plugin.cpp:677
tresult PLUGIN_API initialize(FUnknown *context) override
object initializer
Definition: vst3plugin.cpp:84
tresult PLUGIN_API setParamNormalizedFromFile(ParamID tag, ParamValue value)
helper function for setComponentState()
Definition: vst3plugin.cpp:1266
tresult PLUGIN_API setComponentState(IBStream *fileStream) override
This is the serialization-read function so the GUI can be updated from a preset or startup.
Definition: vst3plugin.cpp:1220
virtual void PLUGIN_API update(FUnknown *changedUnknown, int32 message) override
Toggle preset.
Definition: vst3plugin.cpp:1377
virtual tresult PLUGIN_API getProgramName(ProgramListID listId, int32 programIndex, String128 name) override
Get preset name.
Definition: vst3plugin.cpp:1348
tresult PLUGIN_API setParamNormalized(ParamID tag, ParamValue value) override
This is overridden for selecting a preset, this is also called when automating parameters.
Definition: vst3plugin.cpp:1293
static const char * getVendorName()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1452
~VST3Plugin()
object destructor: because of class factory, do NOT use this for destruction; use terminate() instead
Definition: vst3plugin.cpp:65
VSTParamUpdateQueue ** m_pParamUpdateQueueArray
sample accurate parameter automation
Definition: vst3plugin.h:204
IPlugView *PLUGIN_API createView(const char *_name) override
creates the custom GUI view
Definition: vst3plugin.cpp:1147
virtual uint32 PLUGIN_API getLatencySamples() override
Definition: vst3plugin.h:168
virtual uint32 PLUGIN_API getTailSamples() override
Returns the tail-time in samples.
Definition: vst3plugin.cpp:613
tresult PLUGIN_API setActive(TBool state) override
VST3 plugins may be turned on or off; you are supposed to dynamically delare stuff when activated the...
Definition: vst3plugin.cpp:640
tresult PLUGIN_API getState(IBStream *fileStream) override
This is the WRITE part of the serialization process. We get the stream interface and use it to write ...
Definition: vst3plugin.cpp:739
void updateHostInfo(ProcessData &data, HostInfo *hostInfo)
update the incoming host data for the plugin core
Definition: vst3plugin.cpp:917
tresult PLUGIN_API process(ProcessData &data) override
the VST3 audio processing function
Definition: vst3plugin.cpp:946
static CString getPluginType()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1500
virtual tresult PLUGIN_API getMidiControllerAssignment(int32 busIndex, int16 channel, CtrlNumber midiControllerNumber, ParamID &id) override
The client queries this 129 times for 130 possible control messages, see ivstsmidicontrollers....
Definition: vst3plugin.cpp:1110
static const char * getVendorURL()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1468
tresult PLUGIN_API canProcessSampleSize(int32 symbolicSampleSize) override
Client queries us for our supported sample lengths.
Definition: vst3plugin.cpp:566
VST3Plugin()
object constructor: because of class factory, do NOT use this for init; use initialize() instead
Definition: vst3plugin.cpp:36
tresult PLUGIN_API setBusArrangements(SpeakerArrangement *inputs, int32 numIns, SpeakerArrangement *outputs, int32 numOuts) override
Client queries us for our supported Busses; this is where you can modify to support mono,...
Definition: vst3plugin.cpp:420
static const char * getVendorEmail()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1484
tresult PLUGIN_API terminate() override
object destroyer
Definition: vst3plugin.cpp:369
bool issueMIDICCProxyMessage(ParamID proxyParamID, ParamValue proxyParamValue)
Find and issue Control Changes.
Definition: vst3plugin.cpp:783
static FUID * getFUID()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1416
bool doControlUpdate(ProcessData &data)
Find and issue Control Changes.
Definition: vst3plugin.cpp:831
unsigned int sampleAccuracy
sample accurate parameter automation
Definition: vst3plugin.h:205
void updateMeters(ProcessData &data, bool forceOff=false)
update the outbound VST3 parameters that correspond to plugin meter variables
Definition: vst3plugin.cpp:1071
uint32 m_uLatencyInSamples
set in constructor with plugin
Definition: vst3plugin.h:165
virtual tresult receiveText(const char8 *text) override
VST3 messaging system - not used in ASPiK but here if you want to play with messaging.
Definition: vst3plugin.cpp:1195
Little update handler object for VST-approved GUI updating.
Definition: vst3plugin.h:919
The VSTMIDIEventQueue interface queues incoming MIDI messages and blasts them out during the buffer p...
Definition: vst3plugin.h:748
virtual bool fireMidiEvents(unsigned int sampleOffset)
Definition: vst3plugin.h:786
PluginCore * pluginCore
the core object
Definition: vst3plugin.h:900
void setEventList(IEventList *_inputEvents)
Definition: vst3plugin.h:770
virtual unsigned int getEventCount()
Definition: vst3plugin.h:777
unsigned int currentEventIndex
index of current event
Definition: vst3plugin.h:902
IEventList * inputEvents
the current event list for this buffer cycle
Definition: vst3plugin.h:901
The VSTParamUpdateQueue object maintains a parameter update queue for one ASPiK PluginParameter objec...
Definition: vst3plugin.h:314
VSTParamUpdateQueue(void)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1521
ParamValue interpolate(int x1, int x2, ParamValue y1, ParamValue y2, int x)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1657
int needsUpdate(int x, ParamValue &value)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1678
void initialize(ParamValue _initialValue, ParamValue _minValue, ParamValue _maxValue, unsigned int *_sampleAccuracy)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1548
void setSlope()
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1589
bool getValueAtOffset(long int _sampleOffset, double _previousValue, double &_nextValue)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1739
bool getNextValue(double &_nextValue)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1764
unsigned int getParameterIndex()
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1723
void setParamValueQueue(IParamValueQueue *_paramValueQueue, unsigned int _bufferSize)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1569
The ControlUpdateReceiver object is the connection mechanism between PluginParameter objects and thei...
Definition: plugingui.h:90
int32_t getControlID()
Definition: plugingui.h:321
void updateControlsWithNormalizedValue(float normalizedValue, CControl *control=nullptr)
Definition: plugingui.h:212
The PluginGUI object that maintains the entire GUI operation and has #defines to use with AAX,...
Definition: plugingui.h:441
bool showGUIEditor
show the GUI designer
Definition: plugingui.h:540
base class interface file for ASPiK plugincore object
interface file for ASPiK GUI object
Information that defines a single GUI parameter's possible values and ID.
Definition: pluginstructures.h:332
double actualValue
actual value
Definition: pluginstructures.h:353
uint32_t controlID
ID value.
Definition: pluginstructures.h:352
Information about a GUI update message; this is for sending GUI control information from the plugin c...
Definition: pluginstructures.h:444
std::vector< GUIParameter > guiParameters
list of updates
Definition: pluginstructures.h:461
Information from the host that is updated on each buffer process cycle; includes BPM,...
Definition: pluginstructures.h:974
Definition: pluginstructures.h:486
Information that includes the message code as well as the message data.
Definition: pluginstructures.h:706
void * inMessageData
incoming message data (interpretation depends on message)
Definition: pluginstructures.h:733
std::string inMessageString
incoming message data as a std::string (interpretation depends on message)
Definition: pluginstructures.h:736
Information about a MIDI event.
Definition: pluginstructures.h:562
uint32_t midiData1
BYTE data 1 as UINT.
Definition: pluginstructures.h:643
uint32_t midiMessage
BYTE message as UINT.
Definition: pluginstructures.h:641