ASPiK SDK
vst3plugin.h
1 // --- header
2 
3 
4 #ifndef __VST3Plugin__
5 #define __VST3Plugin__
6 
7 #// --- VST3
8 #include "public.sdk/source/vst/vstsinglecomponenteffect.h"
9 #include "pluginterfaces/vst/ivstparameterchanges.h"
10 
11 // --- MIDI EVENTS
12 #include "pluginterfaces/vst/ivstevents.h"
13 
14 // --- WString Support
15 #include "pluginterfaces/base/ustring.h"
16 
17 // --- our plugin core object
18 #include "plugincore.h"
19 #include "plugingui.h"
20 
21 #if MAC
22 #include <CoreFoundation/CoreFoundation.h>
23 #else
24 #include <windows.h>
25 extern void* hInstance; // VSTGUI hInstance
26 #endif
27 
28 #include <vector>
29 
30 namespace Steinberg {
31 namespace Vst {
32 namespace ASPiK {
33 /*
34  The Processor object here ALSO contains the Edit Controller component since these
35  are combined as SingleComponentEffect; see documentation
36 */
37 class VSTParamUpdateQueue;
38 class GUIPluginConnector;
40 class VSTMIDIEventQueue;
41 
53 class VST3Plugin : public SingleComponentEffect, public IMidiMapping
54 {
55 public:
56  // --- constructor
57  VST3Plugin();
58 
59  // --- destructor
60  ~VST3Plugin();
61 
62  /*** IAudioProcessor Interface ***/
64  tresult PLUGIN_API initialize(FUnknown* context) override;
65 
67  tresult PLUGIN_API setBusArrangements(SpeakerArrangement* inputs, int32 numIns, SpeakerArrangement* outputs, int32 numOuts) override;
68 
70  tresult PLUGIN_API canProcessSampleSize(int32 symbolicSampleSize) override;
71 
73  tresult PLUGIN_API setupProcessing(ProcessSetup& newSetup) override;
74 
76  tresult PLUGIN_API setActive(TBool state) override;
77 
79  // These get/set the RackAFX variables
80  tresult PLUGIN_API setState(IBStream* fileStream) override;
81  tresult PLUGIN_API getState(IBStream* fileStream) override;
82 
84  // Update the GUI control variables
85  bool doControlUpdate(ProcessData& data);
86 
88  tresult PLUGIN_API process(ProcessData& data) override;
89 
91  virtual tresult PLUGIN_API getMidiControllerAssignment(int32 busIndex, int16 channel, CtrlNumber midiControllerNumber, ParamID& id/*out*/) override;
92 
94  IPlugView* PLUGIN_API createView(const char* _name) override;
95 
97  tresult PLUGIN_API terminate() override;
98 
100  virtual tresult receiveText(const char8* text) override;
101 
103  tresult PLUGIN_API setParamNormalizedFromFile(ParamID tag, ParamValue value);
104 
106  tresult PLUGIN_API setComponentState(IBStream* fileStream) override;
107 
109  void updateMeters(ProcessData& data, bool forceOff = false);
110 
112  static FUnknown* createInstance(void* context) {return (IAudioProcessor*)new VST3Plugin(); }
113 
115  bool addUnit (Unit* unit);
116 
118  bool addProgramList (ProgramList* list);
119  ProgramList* getProgramList(ProgramListID listId) const;
120  tresult notifyPogramListChange(ProgramListID listId, int32 programIndex = kAllProgramInvalid);
121 
122  tresult PLUGIN_API setParamNormalized (ParamID tag, ParamValue value) override;
123  virtual int32 PLUGIN_API getProgramListCount() override;
124  virtual tresult PLUGIN_API getProgramListInfo(int32 listIndex, ProgramListInfo& info /*out*/) override;
125  virtual tresult PLUGIN_API getProgramName(ProgramListID listId, int32 programIndex, String128 name /*out*/) override;
126  virtual tresult PLUGIN_API getProgramInfo(ProgramListID listId, int32 programIndex, CString attributeId /*in*/, String128 attributeValue /*out*/) override;
127  virtual tresult PLUGIN_API hasProgramPitchNames(ProgramListID listId, int32 programIndex) override;
128  virtual tresult PLUGIN_API getProgramPitchName(ProgramListID listId, int32 programIndex, int16 midiPitch, String128 name /*out*/) override;
129  virtual tresult setProgramName(ProgramListID listId, int32 programIndex, const String128 name /*in*/) override;
130 
132  virtual void PLUGIN_API update(FUnknown* changedUnknown, int32 message) override ;
133 
134  // --- latency support
135  uint32 m_uLatencyInSamples = 0;
136 
138  virtual uint32 PLUGIN_API getLatencySamples() override {
139  return m_uLatencyInSamples; }
140 
142  virtual uint32 PLUGIN_API getTailSamples() override ;
143 
145  void updateHostInfo(ProcessData& data, HostInfo* hostInfo);
146 
147  static FUID* getFUID();
148  static const char* getPluginName();
149  static const char* getVendorName();
150  static const char* getVendorURL();
151  static const char* getVendorEmail();
152  static CString getPluginType();
153 
154  // --- define the IMidiMapping interface
155  OBJ_METHODS(VST3Plugin, SingleComponentEffect)
156  DEFINE_INTERFACES
157  DEF_INTERFACE(IMidiMapping)
158  DEF_INTERFACE(IUnitInfo)
159  END_DEFINE_INTERFACES(SingleComponentEffect)
160  REFCOUNT_METHODS(SingleComponentEffect)
161 
162 
163 private:
164  // --- our plugin core and interfaces
165  PluginCore* pluginCore = nullptr;
166  GUIPluginConnector* guiPluginConnector = nullptr;
167  PluginHostConnector* pluginHostConnector = nullptr;
168  VSTMIDIEventQueue* midiEventQueue = nullptr;
169  bool plugInSideBypass = false;
170  bool hasSidechain = false;
171 
172 protected:
173  // --- sample accurate parameter automation
175  unsigned int sampleAccuracy = 1;
176  bool enableSAAVST3 = false;
177 
178  // --- IUnitInfo and factory Preset support
179  typedef std::vector<IPtr<ProgramList> > ProgramListVector;
180  typedef std::map<ProgramListID, ProgramListVector::size_type> ProgramIndexMap;
181  typedef std::vector<IPtr<Unit> > UnitVector;
182  UnitVector units;
183  ProgramListVector programLists;
184  ProgramIndexMap programIndexMap;
185  UnitID selectedUnit;
186 
187 #if defined _WINDOWS || defined _WINDLL
188  // --- getMyDLLDirectory()
189  // returns the directory where the .component resides
190  char* getMyDLLDirectory(UString cPluginName)
191  {
192  HMODULE hmodule = GetModuleHandle(cPluginName);
193 
194  TCHAR dir[MAX_PATH];
195  memset(&dir[0], 0, MAX_PATH*sizeof(TCHAR));
196  dir[MAX_PATH-1] = '\0';
197 
198  if(hmodule)
199  GetModuleFileName(hmodule, &dir[0], MAX_PATH);
200  else
201  return nullptr;
202 
203  // convert to UString
204  UString DLLPath(&dir[0], MAX_PATH);
205 
206  char* pFullPath = new char[MAX_PATH];
207  char* pDLLRoot = new char[MAX_PATH];
208 
209  DLLPath.toAscii(pFullPath, MAX_PATH);
210 
211  size_t nLenDir = strlen(pFullPath);
212  size_t nLenDLL = wcslen(cPluginName) + 1; // +1 is for trailing backslash
213  memcpy(pDLLRoot, pFullPath, nLenDir-nLenDLL);
214  pDLLRoot[nLenDir-nLenDLL] = '\0';
215 
216  delete [] pFullPath;
217 
218  // caller must delete this after use
219  return pDLLRoot;
220  }
221 #endif
222 
223 #if MAC
224  // --- getMyComponentDirectory()
225  // returns the directory where the .component resides
226  char* getMyComponentDirectory(CFStringRef bundleID)
227  {
228  if (bundleID != nullptr)
229  {
230  CFBundleRef helixBundle = CFBundleGetBundleWithIdentifier( bundleID );
231  if(helixBundle != nullptr)
232  {
233  CFURLRef bundleURL = CFBundleCopyBundleURL ( helixBundle );
234  if(bundleURL != nullptr)
235  {
236  CFURLRef componentFolderPathURL = CFURLCreateCopyDeletingLastPathComponent(nullptr, bundleURL);
237 
238  CFStringRef myComponentPath = CFURLCopyFileSystemPath(componentFolderPathURL, kCFURLPOSIXPathStyle);
239  CFRelease(componentFolderPathURL);
240 
241  if(myComponentPath != nullptr)
242  {
243  int nSize = CFStringGetLength(myComponentPath);
244  char* path = new char[nSize+1];
245  memset(path, 0, (nSize+1)*sizeof(char));
246 
247  bool success = CFStringGetCString(myComponentPath, path, nSize+1, kCFStringEncodingASCII);
248  CFRelease(myComponentPath);
249 
250  if(success) return path;
251  else return nullptr;
252  }
253  CFRelease(bundleURL);
254  }
255  }
256  CFRelease(bundleID);
257  }
258  return nullptr;
259  }
260 #endif
261 
262 };
263 
277 class VSTParamUpdateQueue : public IParameterUpdateQueue
278 {
279 protected:
280  unsigned int bufferSize = 0;
281  ParamValue initialValue = 0.0;
282  ParamValue previousValue = 0.0;
283  ParamValue maxValue = 0.0;
284  ParamValue minValue = 0.0;
285 
286  // --- Store slope and b so that it needs to be calculated only once.
287  ParamValue slope;
288  ParamValue yIntercept;
289 
290  // --- Controls granularity
291  unsigned int* sampleAccuracy = nullptr;
292  int queueIndex = 0;
293  int queueSize = 0;
294  IParamValueQueue* parameterQueue = nullptr;
295  int x1, x2 = 0;
296  double y1, y2 = 0;
297  bool dirtyBit = false;
298  int sampleOffset = 0;
299 
300 public:
301  VSTParamUpdateQueue(void);
302  virtual ~VSTParamUpdateQueue(void){}
303  void initialize(ParamValue _initialValue, ParamValue _minValue, ParamValue _maxValue, unsigned int* _sampleAccuracy);
304  void setParamValueQueue(IParamValueQueue* _paramValueQueue, unsigned int _bufferSize);
305  void setSlope();
306  ParamValue interpolate(int x1, int x2, ParamValue y1, ParamValue y2, int x);
307  int needsUpdate(int x, ParamValue &value);
308 
309  // --- IParameterUpdateQueue
310  unsigned int getParameterIndex();
311  bool getValueAtOffset(long int _sampleOffset, double _previousValue, double& _nextValue);
312  bool getNextValue(double& _nextValue);
313 };
314 
315 
316 
336 {
337 public:
338  PluginHostConnector(VST3Plugin* _editController) {editController = _editController;}
339  virtual ~PluginHostConnector(){}
340 
346  virtual void sendHostMessage(const HostMessageInfo& hostMessageInfo)
347  {
348  switch(hostMessageInfo.hostMessage)
349  {
350  case sendGUIUpdate:
351  {
352  GUIUpdateData guiUpdateData = hostMessageInfo.guiUpdateData;
353 
354  for(unsigned int i = 0; i < guiUpdateData.guiParameters.size(); i++)
355  {
356  GUIParameter guiParam = guiUpdateData.guiParameters[i];
357  if(editController)
358  {
359  ParamValue normalizedValue = editController->plainParamToNormalized(guiParam.controlID, guiParam.actualValue);
360  editController->setParamNormalized(guiParam.controlID, normalizedValue);
361  }
362  }
363 
364  // --- clean up
365  for (unsigned int i = 0; i < guiUpdateData.guiParameters.size(); i++)
366  guiUpdateData.guiParameters.pop_back();
367 
368  break;
369  }
370  default:
371  break;
372  }
373  }
374 
375 protected:
376  VST3Plugin* editController = nullptr;
377 };
378 
379 // --- GUI -> Plugin interface
394 class CustomViewController : public ICustomView
395 {
396 public:
398  CustomViewController(ICustomView* _customViewIF) { customViewIF = _customViewIF; }
399  virtual ~CustomViewController() {}
400 
402  virtual void updateView()
403  {
404  if (customViewIF)
405  customViewIF->updateView();
406  }
407 
409  virtual void pushDataValue(double data)
410  {
411  if (customViewIF)
412  customViewIF->pushDataValue(data);
413  }
414 
416  virtual void sendMessage(void* data)
417  {
418  if (customViewIF)
419  customViewIF->sendMessage(data);
420  }
421 
423  void setCustomViewPtr(ICustomView* _customViewIF) { customViewIF = _customViewIF; }
424 
426  const ICustomView* getCustomViewPtr() { return customViewIF; }
427 
429  void clearCustomViewPtr() { customViewIF = nullptr; }
430 
431 
432 private:
433  ICustomView* customViewIF = nullptr;
434 };
435 
457 {
458 public:
460  GUIPluginConnector(PluginCore* _pluginCore, VST3Plugin* _editController)
461  {
462  pluginCore = _pluginCore;
463  editController = _editController;
464  }
465 
468  {
469  for (customViewControllerMap::const_iterator it = customSubControllerMap.begin(), end = customSubControllerMap.end(); it != end; ++it)
470  {
471  delete it->second;
472  }
473  for (customViewControllerMap::const_iterator it = customViewMap.begin(), end = customViewMap.end(); it != end; ++it)
474  {
475  delete it->second;
476  }
477  }
478 
480  virtual void parameterChanged(int32_t controlID, double actualValue, double normalizedValue)
481  {
482  if(pluginCore)
483  pluginCore->guiParameterChanged(controlID, actualValue);
484 
485  if(!editController) return;
486 
487  // --- set parameter on object
488  editController->setParamNormalized(controlID, normalizedValue);
489 
490  // --- perform the operation
491  editController->performEdit(controlID, normalizedValue);
492  }
493 
495  virtual double getNormalizedPluginParameter(int32_t controlID)
496  {
497  if(!editController) return 0.0;
498 
499  Parameter* param = editController->getParameterObject(controlID);
500 
501  if(!param) return 0.0;
502 
503  return param->getNormalized();
504  }
505 
507  virtual bool registerSubcontroller(std::string subcontrollerName, ICustomView* customViewConnector)
508  {
509  // --- do we have this in our map already?
510  CustomViewController* pCVC = nullptr;
511 
512  customViewControllerMap::const_iterator it = customSubControllerMap.find(subcontrollerName);
513  if (it != customSubControllerMap.end())
514  {
515  pCVC = it->second;
516  pCVC->setCustomViewPtr(customViewConnector);
517  }
518  else
519  {
520  pCVC = new CustomViewController(customViewConnector);
521  customSubControllerMap.insert(std::make_pair(subcontrollerName, pCVC));
522  }
523 
524  MessageInfo info(PLUGINGUI_REGISTER_SUBCONTROLLER);
525  info.inMessageString = subcontrollerName;
526  info.inMessageData = pCVC;
527 
528  if (pluginCore && pluginCore->processMessage(info))
529  return true;
530 
531  return false;
532  }
533 
535  virtual bool deRregisterSubcontroller(ICustomView* customViewConnector)
536  {
537  CustomViewController* pCVC = getCustomSubController(customViewConnector);
538  if (pCVC)
539  {
540  pCVC->clearCustomViewPtr();
541 
542  MessageInfo info(PLUGINGUI_DE_REGISTER_SUBCONTROLLER);
543  info.inMessageString = "";
544  info.inMessageData = pCVC;
545 
546  if (pluginCore && pluginCore->processMessage(info))
547  return true;
548  }
549 
550  return false;
551  }
552 
554  virtual bool registerCustomView(std::string customViewName, ICustomView* customViewConnector)
555  {
556  // --- do we have this in our map already?
557  CustomViewController* pCVC = nullptr;
558 
559  customViewControllerMap::const_iterator it = customViewMap.find(customViewName);
560  if (it != customViewMap.end())
561  {
562  pCVC = it->second;
563  pCVC->setCustomViewPtr(customViewConnector);
564  }
565  else
566  {
567  pCVC = new CustomViewController(customViewConnector);
568  customViewMap.insert(std::make_pair(customViewName, pCVC));
569  }
570 
571  MessageInfo info(PLUGINGUI_REGISTER_CUSTOMVIEW);
572  info.inMessageString = customViewName;
573  info.inMessageData = pCVC;
574 
575  if(pluginCore && pluginCore->processMessage(info))
576  return true;
577 
578  return false;
579  }
580 
582  virtual bool deRegisterCustomView(ICustomView* customViewConnector)
583  {
584  CustomViewController* pCVC = getCustomViewController(customViewConnector);
585  if (pCVC)
586  {
587  // --- clear it
588  pCVC->clearCustomViewPtr();
589 
590  MessageInfo info(PLUGINGUI_DE_REGISTER_CUSTOMVIEW);
591  info.inMessageString = "";
592  info.inMessageData = pCVC;
593 
594  if (pluginCore && pluginCore->processMessage(info))
595  return true;
596  }
597 
598  return false;
599  }
600 
602  virtual bool guiDidOpen()
603  {
604  if(!pluginCore) return false;
605  MessageInfo info(PLUGINGUI_DIDOPEN);
606  return pluginCore->processMessage(info);
607  }
608 
610  virtual bool guiWillClose()
611  {
612  if(!pluginCore) return false;
613 
614  for (customViewControllerMap::const_iterator it = customViewMap.begin(), end = customViewMap.end(); it != end; ++it)
615  {
616  it->second->clearCustomViewPtr();
617  }
618  for (customViewControllerMap::const_iterator it = customSubControllerMap.begin(), end = customSubControllerMap.end(); it != end; ++it)
619  {
620  it->second->clearCustomViewPtr();
621  }
622 
623  MessageInfo info(PLUGINGUI_WILLCLOSE);
624  return pluginCore->processMessage(info);
625  }
626 
628  virtual bool guiTimerPing()
629  {
630  if(!pluginCore) return false;
631  MessageInfo info(PLUGINGUI_TIMERPING);
632  return pluginCore->processMessage(info);
633  }
634 
636  virtual bool checkNonBoundValueChange(int tag, float normalizedValue)
637  {
638  if(!pluginCore) return false;
639 
640  // --- do any additional stuff here
641  // --- dispatch non-bound value changes directly to receiver
642 
643  return false;
644  }
645 
646 protected:
647  PluginCore* pluginCore = nullptr;
648  VST3Plugin* editController = nullptr;
649 
650  // --- this is for supporting the persistent interface pointer for the core object
651  // and is required by ASPiK Specifications
652  typedef std::map<std::string, CustomViewController*> customViewControllerMap;
653  customViewControllerMap customViewMap;
654 
657  {
658  for (customViewControllerMap::const_iterator it = customViewMap.begin(), end = customViewMap.end(); it != end; ++it)
659  {
660  if (it->second->getCustomViewPtr() == customViewConnector)
661  return it->second;
662  }
663 
664  return nullptr;
665  }
666 
668 
671  {
672  for (customViewControllerMap::const_iterator it = customSubControllerMap.begin(), end = customSubControllerMap.end(); it != end; ++it)
673  {
674  if (it->second->getCustomViewPtr() == customViewConnector)
675  return it->second;
676  }
677 
678  return nullptr;
679  }
680 
681 };
682 
698 class VSTMIDIEventQueue : public IMidiEventQueue
699 {
700 public:
701  VSTMIDIEventQueue(PluginCore* _pluginCore)
702  {
703  pluginCore = _pluginCore;
704  };
705 
706  virtual ~VSTMIDIEventQueue(){}
707 
708 public:
710  void setEventList(IEventList* _inputEvents)
711  {
712  inputEvents = _inputEvents;
713  currentEventIndex = 0;
714  }
715 
717  virtual unsigned int getEventCount()
718  {
719  if (inputEvents)
720  return inputEvents->getEventCount();
721 
722  return 0;
723  }
724 
726  virtual bool fireMidiEvents(unsigned int sampleOffset)
727  {
728  if (!inputEvents)
729  return false;
730 
731  Event e = { 0 };
732  bool eventOccurred = false;
733  bool haveEvents = false;
734  if (inputEvents->getEvent(currentEventIndex, e) == kResultTrue)
735  haveEvents = true;
736  else
737  return false;
738 
739  const unsigned char MIDI_NOTE_OFF = 0x80;
740  const unsigned char MIDI_NOTE_ON = 0x90;
741  const unsigned char MIDI_POLY_PRESSURE = 0xA0;
742 
743  while (haveEvents)
744  {
745  if (inputEvents->getEvent(currentEventIndex, e) == kResultTrue)
746  {
747  if (e.sampleOffset != sampleOffset)
748  return false;
749 
750  // --- process Note On or Note Off messages
751  switch (e.type)
752  {
753  // --- NOTE ON
754  case Event::kNoteOnEvent:
755  {
756  midiEvent event;
757  event.midiMessage = (unsigned int)MIDI_NOTE_ON;
758  event.midiChannel = (unsigned int)e.noteOn.channel;
759  event.midiData1 = (unsigned int)e.noteOn.pitch;
760  event.midiData2 = (unsigned int)(127.0*e.noteOn.velocity);
761  event.midiSampleOffset = e.sampleOffset;
762  eventOccurred = true;
763 
764  // --- send to core for processing
765  if(pluginCore)
767  break;
768  }
769 
770  // --- NOTE OFF
771  case Event::kNoteOffEvent:
772  {
773  // --- get the channel/note/vel
774  midiEvent event;
775  event.midiMessage = (unsigned int)MIDI_NOTE_OFF;
776  event.midiChannel = (unsigned int)e.noteOff.channel;
777  event.midiData1 = (unsigned int)e.noteOff.pitch;
778  event.midiData2 = (unsigned int)(127.0*e.noteOff.velocity);
779  event.midiSampleOffset = e.sampleOffset;
780  eventOccurred = true;
781 
782  // --- send to core for processing
783  if(pluginCore)
785 
786  break;
787  }
788 
789  // --- polyphonic aftertouch 0xAn
790  case Event::kPolyPressureEvent:
791  {
792  midiEvent event;
793  event.midiMessage = (unsigned int)MIDI_POLY_PRESSURE;
794  event.midiChannel = (unsigned int)e.polyPressure.channel;
795  event.midiData1 = (unsigned int)e.polyPressure.pitch;
796  event.midiData2 = (unsigned int)(127.0*e.polyPressure.pressure);
797  event.midiSampleOffset = e.sampleOffset;
798  eventOccurred = true;
799 
800  // --- send to core for processing
801  if(pluginCore)
803 
804  break;
805  }
806  } // switch
807 
808  // --- have next event?
809  if (inputEvents->getEvent(currentEventIndex + 1, e) == kResultTrue)
810  {
811  if (e.sampleOffset == sampleOffset)
812  {
813  // --- avance current index
815  }
816  else
817  haveEvents = false;
818  }
819  else
820  haveEvents = false;
821  }
822  }
823 
824  return eventOccurred;
825  }
826 
827 protected:
828  PluginCore* pluginCore = nullptr;
829  IEventList* inputEvents = nullptr;
830  unsigned int currentEventIndex = 0;
831 };
832 
844 class VST3UpdateHandler: public FObject
845 {
846 public:
847  VST3UpdateHandler(VSTGUI::ControlUpdateReceiver* _receiver, VST3Plugin* _editController){ receiver = _receiver; editController = _editController; }
848  ~VST3UpdateHandler(){}
849 
850  virtual void PLUGIN_API update (FUnknown* changedUnknown, int32 message)
851  {
852  if(message == IDependent::kChanged && receiver && editController)
853  {
854  double normalizedValue = editController->getParamNormalized (receiver->getControlID());
855  receiver->updateControlsWithNormalizedValue(normalizedValue);
856  }
857  }
858 
859 private:
860  VSTGUI::ControlUpdateReceiver* receiver = nullptr;
861  VST3Plugin* editController = nullptr;
862 
863 };
864 
865 
877 class PluginEditor: public CPluginView, public VSTGUI::PluginGUI, public IGUIWindowFrame
878 {
879 public:
880  PluginEditor(VSTGUI::UTF8StringPtr _xmlFile, PluginCore* _pluginCore, GUIPluginConnector* _guiPluginConnector, PluginHostConnector* _pluginHostConnector, VST3Plugin* editController);
881  virtual ~PluginEditor();
882 
883  // --- aet of update handlers, specific to VST3: this will allow us to
884  // remotely update the GUI in a threadsafe and VST-approved manner
885  typedef std::map<int32_t, VST3UpdateHandler*> UpdaterHandlerMap;
886  UpdaterHandlerMap updateHandlers;
887 
888  //---from IPlugView------- VST3 Specific
889  IPlugFrame* plugFrame;
890  const ViewRect& getRect() const { return rect; }
891  void setRect(const ViewRect& r) { rect = r; }
892  bool isAttached() const { return systemWindow != 0; }
893  virtual void attachedToParent() override {}
894  virtual void removedFromParent() override {}
895 
896  virtual tresult PLUGIN_API attached(void* parent, FIDString type) override;
897  virtual tresult PLUGIN_API removed() override;
898  virtual tresult PLUGIN_API onWheel(float distance) override { return kResultFalse; }
899 
900  virtual tresult PLUGIN_API isPlatformTypeSupported(FIDString type) override;
901  virtual tresult PLUGIN_API onSize(ViewRect* newSize) override;
902  virtual tresult PLUGIN_API getSize(ViewRect* size) override;
903 
904  virtual tresult PLUGIN_API onFocus(TBool /*state*/) override { return kResultFalse; }
905  virtual tresult PLUGIN_API setFrame(IPlugFrame* frame) override;// { plugFrame = frame; return kResultTrue; }
906  virtual tresult PLUGIN_API canResize() override{ return kResultTrue; }
907  virtual tresult PLUGIN_API checkSizeConstraint(ViewRect* rect) override
908  {
909  if (showGUIEditor)
910  return kResultTrue;
911 
912  // --- clamp it
913  ViewRect viewRect = getRect();
914  rect->right = viewRect.right;
915  rect->bottom = viewRect.bottom;
916 
917  return kResultFalse;
918  }
919 
920  virtual bool setWindowFrameSize(double left = 0, double top = 0, double right = 0, double bottom = 0) override //CRect* newSize)
921  {
922  ViewRect vr(0, 0, right, bottom);
923  setRect(vr);
924  if (plugFrame)
925  plugFrame->resizeView(this, &vr);
926  return true;
927  }
928 
929  virtual bool getWindowFrameSize(double& left, double& top, double& right, double& bottom) override
930  {
931  ViewRect viewRect = getRect();
932  left = 0.0;
933  top = 0.0;
934  right = viewRect.getWidth();
935  bottom = viewRect.getHeight();
936  return true;
937  }
938 
939 protected:
940  PluginCore* pluginCore = nullptr;
943  VST3Plugin* editController = nullptr;
944 };
945 
946 
947 
948 }}} // namespaces
949 
950 #endif
951 
952 
953 
954 
955 
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:579
Information that includes the message code as well as the message data.
Definition: pluginstructures.h:705
static const char * getPluginName()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1396
unsigned int sampleAccuracy
sample accurate parameter automation
Definition: vst3plugin.h:180
Attribute value smashed down into a union.
Definition: pluginstructures.h:900
bool doControlUpdate(ProcessData &data)
Find and issue Control Changes.
Definition: vst3plugin.cpp:623
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:346
virtual tresult setProgramName(ProgramListID listId, int32 programIndex, const String128 name) override
Set preset name.
Definition: vst3plugin.cpp:1250
ProgramList * getProgramList(ProgramListID listId) const
part of the IUnitInfo support for presets; generally no user editable code here.
Definition: vst3plugin.cpp:1143
void setEventList(IEventList *_inputEvents)
Definition: vst3plugin.h:710
tresult PLUGIN_API canProcessSampleSize(int32 symbolicSampleSize) override
Client queries us for our supported sample lengths.
Definition: vst3plugin.cpp:409
tresult notifyPogramListChange(ProgramListID listId, int32 programIndex=kAllProgramInvalid)
If list changes; should not be called as we only have one program list.
Definition: vst3plugin.cpp:1160
The PluginGUI object that maintains the entire GUI operation and has #defines to use with AAX...
Definition: plugingui.h:410
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:483
bool getValueAtOffset(long int _sampleOffset, double _previousValue, double &_nextValue)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1698
virtual tresult PLUGIN_API getProgramInfo(ProgramListID listId, int32 programIndex, CString attributeId, String128 attributeValue) override
Only used for presets.
Definition: vst3plugin.cpp:1272
virtual tresult PLUGIN_API getProgramPitchName(ProgramListID listId, int32 programIndex, int16 midiPitch, String128 name) override
Not Used.
Definition: vst3plugin.cpp:1316
Interface for VST3 parameter value update queue (sample accurate automation)
Definition: pluginstructures.h:1583
std::vector< GUIParameter > guiParameters
list of updates
Definition: pluginstructures.h:461
The CustomViewController is part of the safe ICustomView feature in ASPiK. The CustomViewController m...
Definition: AAXPluginParameters.h:527
The GUIPluginConnector interface creates a safe message mechanism for the GUI to issue requests to th...
Definition: vst3plugin.h:463
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:1946
CustomViewController(ICustomView *_customViewIF)
Definition: vst3plugin.h:398
VST3Plugin * editController
the VST3
Definition: vst3plugin.h:655
The VSTMIDIEventQueue interface queues incoming MIDI messages and blasts them out during the buffer p...
Definition: vst3plugin.h:705
GUIPluginConnector * guiPluginConnector
GUI Plugin interface.
Definition: vst3plugin.h:948
virtual bool processMIDIEvent(midiEvent &event)
process a MIDI event
Definition: plugincore.cpp:415
uint32_t midiData1
BYTE data 1 as UINT.
Definition: pluginstructures.h:643
VST3Plugin * editController
our parent plugin
Definition: vst3plugin.h:383
IPlugView *PLUGIN_API createView(const char *_name) override
creates the custom GUI view
Definition: vst3plugin.cpp:923
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:996
void updateHostInfo(ProcessData &data, HostInfo *hostInfo)
update the incoming host data for the plugin core
Definition: vst3plugin.cpp:704
virtual bool guiTimerPing()
Definition: vst3plugin.h:628
uint32_t controlID
ID value.
Definition: pluginstructures.h:352
The VST3Plugin object is the ASPiK plugin shell for the VST3 API.
Definition: vst3plugin.h:58
bool showGUIEditor
show the GUI designer
Definition: plugingui.h:507
virtual bool processMessage(MessageInfo &messageInfo)
For Custom View and Custom Sub-Controller Operations.
Definition: plugincore.cpp:355
tresult PLUGIN_API terminate() override
object destroyer
Definition: vst3plugin.cpp:306
virtual double getNormalizedPluginParameter(int32_t controlID)
Definition: vst3plugin.h:495
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:520
void updateControlsWithNormalizedValue(float normalizedValue, CControl *control=nullptr)
Definition: plugingui.h:198
virtual ~PluginEditor()
ASPiK support VST3 GUI - this wraps the ASPiK GUI so that it conforms to the IPlugView interface...
Definition: vst3plugin.cpp:1768
uint32 m_uLatencyInSamples
set in constructor with plugin
Definition: vst3plugin.h:140
virtual uint32 PLUGIN_API getTailSamples() override
Returns the tail-time in samples.
Definition: vst3plugin.cpp:456
int needsUpdate(int x, ParamValue &value)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1637
const ICustomView * getCustomViewPtr()
Definition: vst3plugin.h:426
uint32_t midiMessage
BYTE message as UINT.
Definition: pluginstructures.h:641
virtual void updateView()
Definition: vst3plugin.h:402
unsigned int currentEventIndex
index of current event
Definition: vst3plugin.h:837
virtual bool registerCustomView(std::string customViewName, ICustomView *customViewConnector)
Definition: vst3plugin.h:554
VSTParamUpdateQueue ** m_pParamUpdateQueueArray
sample accurate parameter automation
Definition: vst3plugin.h:179
CustomViewController * getCustomSubController(ICustomView *customViewConnector)
Definition: vst3plugin.h:677
CustomViewController * getCustomViewController(ICustomView *customViewConnector)
Definition: vst3plugin.h:663
Information about a GUI update message; this is for sending GUI control information from the plugin c...
Definition: pluginstructures.h:443
std::map< std::string, CustomViewController * > customViewControllerMap
map of custom view controllers
Definition: vst3plugin.h:652
Custom interface so that GUI can pass information to plugin shell in a thread-safe manner...
Definition: pluginstructures.h:1473
The CustomViewController is part of the safe ICustomView feature in ASPiK. The CustomViewController m...
Definition: vst3plugin.h:401
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:971
static const char * getVendorURL()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1428
GUIPluginConnector(PluginCore *_pluginCore, VST3Plugin *_editController)
Definition: vst3plugin.h:460
VSTParamUpdateQueue(void)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1481
virtual bool fireMidiEvents(unsigned int sampleOffset)
Definition: vst3plugin.h:726
virtual bool deRegisterCustomView(ICustomView *customViewConnector)
Definition: vst3plugin.h:582
virtual tresult PLUGIN_API getProgramListInfo(int32 listIndex, ProgramListInfo &info) override
Get information about our preset list.
Definition: vst3plugin.cpp:1198
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:1983
Custom View interface to allow plugin core to create safe communication channels with GUI custom view...
Definition: pluginstructures.h:1395
VST3Plugin()
object constructor: because of class factory, do NOT use this for init; use initialize() instead ...
Definition: vst3plugin.cpp:36
virtual bool guiWillClose()
Definition: vst3plugin.h:610
virtual void pushDataValue(double data)
Definition: vst3plugin.h:409
Definition: pluginstructures.h:485
virtual ~GUIPluginConnector()
Definition: vst3plugin.h:467
Double buffered queue for MIDI messages.
Definition: pluginstructures.h:1561
virtual bool guiParameterChanged(int32_t controlID, double actualValue)
has nothing to do with actual variable or updated variable (binding)
Definition: plugincore.cpp:326
IEventList * inputEvents
the current event list for this buffer cycle
Definition: vst3plugin.h:836
virtual void parameterChanged(int32_t controlID, double actualValue, double normalizedValue)
Definition: vst3plugin.h:480
The GUIPluginConnector interface creates a safe message mechanism for the GUI to issue requests to th...
Definition: AAXPluginParameters.h:587
virtual int32 PLUGIN_API getProgramListCount() override
We have one list for our one set of presets.
Definition: vst3plugin.cpp:1180
virtual uint32 PLUGIN_API getLatencySamples() override
Definition: vst3plugin.h:138
void initialize(ParamValue _initialValue, ParamValue _minValue, ParamValue _maxValue, unsigned int *_sampleAccuracy)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1507
virtual tresult PLUGIN_API getProgramName(ProgramListID listId, int32 programIndex, String128 name) override
Get preset name.
Definition: vst3plugin.cpp:1224
void setParamValueQueue(IParamValueQueue *_paramValueQueue, unsigned int _bufferSize)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1528
virtual bool setWindowFrameSize(double left=0, double top=0, double right=0, double bottom=0) override
Definition: vst3plugin.h:920
virtual bool deRregisterSubcontroller(ICustomView *customViewConnector)
Definition: vst3plugin.h:535
virtual void sendMessage(void *data)
Definition: vst3plugin.h:416
static FUID * getFUID()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1376
The ControlUpdateReceiver object is the connection mechanism between PluginParameter objects and thei...
Definition: plugingui.h:83
PluginCore * pluginCore
the core object
Definition: vst3plugin.h:835
void * inMessageData
incoming message data (interpretation depends on message)
Definition: pluginstructures.h:733
tresult PLUGIN_API setParamNormalizedFromFile(ParamID tag, ParamValue value)
helper function for setComponentState()
Definition: vst3plugin.cpp:1042
tresult PLUGIN_API setupProcessing(ProcessSetup &newSetup) override
we get information about sample rate, bit-depth, etc...
Definition: vst3plugin.cpp:430
static CString getPluginType()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1460
static const char * getVendorEmail()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1444
PluginEditor(VSTGUI::UTF8StringPtr _xmlFile, PluginCore *_pluginCore, GUIPluginConnector *_guiPluginConnector, PluginHostConnector *_pluginHostConnector, VST3Plugin *editController)
ASPiK support VST3 GUI - this wraps the ASPiK GUI so that it conforms to the IPlugView interface...
Definition: vst3plugin.cpp:1747
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:2005
tresult PLUGIN_API initialize(FUnknown *context) override
object initializer
Definition: vst3plugin.cpp:71
virtual unsigned int getEventCount()
Definition: vst3plugin.h:717
Definition: channelformats.h:32
The PluginHostConnector implements the IPluginHostConnector interface for the plugin shell object...
Definition: vst3plugin.h:342
void setCustomViewPtr(ICustomView *_customViewIF)
Definition: vst3plugin.h:423
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.h for the VST defines for kPitchBend, kCtrlModWheel, etc... for each MIDI Channel in our Event Bus.
Definition: vst3plugin.cpp:875
The PluginCore object is the default PluginBase derived object for ASPiK projects. Note that you are fre to change the name of this object (as long as you change it in the compiler settings, etc...)
Definition: plugincore.h:43
void setSlope()
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1548
virtual bool getWindowFrameSize(double &left, double &top, double &right, double &bottom) override
Definition: vst3plugin.h:929
virtual void sendMessage(void *data)
Definition: pluginstructures.h:1416
void clearCustomViewPtr()
Definition: vst3plugin.h:429
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:1901
Information that defines a single GUI parameter&#39;s possible values and ID.
Definition: pluginstructures.h:331
virtual bool registerSubcontroller(std::string subcontrollerName, ICustomView *customViewConnector)
Definition: vst3plugin.h:507
~VST3Plugin()
object destructor: because of class factory, do NOT use this for destruction; use terminate() instead...
Definition: vst3plugin.cpp:52
bool addProgramList(ProgramList *list)
part of the IUnitInfo support for presets; generally no user editable code here.
Definition: vst3plugin.cpp:1123
tresult PLUGIN_API process(ProcessData &data) override
the VST3 audio processing function
Definition: vst3plugin.cpp:733
PluginCore * pluginCore
the core
Definition: vst3plugin.h:947
PluginCore * pluginCore
the core object
Definition: vst3plugin.h:654
Custom interface to allow resizing of GUI window; this is mainly used for the GUI designer...
Definition: pluginstructures.h:1430
double actualValue
actual value
Definition: pluginstructures.h:353
Information from the host that is updated on each buffer process cycle; includes BPM, time signature, SMPTE and other data. The values in the stock structure are consistent across most APIs, however others may be added (commnted out here)
Definition: pluginstructures.h:973
ParamValue interpolate(int x1, int x2, ParamValue y1, ParamValue y2, int x)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1616
virtual bool checkNonBoundValueChange(int tag, float normalizedValue)
Definition: vst3plugin.h:636
virtual void updateView()=0
virtual tresult PLUGIN_API hasProgramPitchNames(ProgramListID listId, int32 programIndex) override
Not Used.
Definition: vst3plugin.cpp:1294
PluginHostConnector * pluginHostConnector
Plugin Host interface.
Definition: vst3plugin.h:949
static FUnknown * createInstance(void *context)
Definition: vst3plugin.h:112
std::string inMessageString
incoming message data as a std::string (interpretation depends on message)
Definition: pluginstructures.h:736
Custom interface to send the plugin shell a message from plugin core.
Definition: pluginstructures.h:1543
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:1069
The PluginHostConnector implements the IPluginHostConnector interface for the plugin shell object...
Definition: AAXPluginParameters.h:467
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:1801
void updateMeters(ProcessData &data, bool forceOff=false)
update the outbound VST3 parameters that correspond to plugin meter variables
Definition: vst3plugin.cpp:836
static const char * getVendorName()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1412
bool getNextValue(double &_nextValue)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1723
bool enableSAAVST3
sample accurate parameter automation
Definition: vst3plugin.h:181
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:1784
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:357
customViewControllerMap customSubControllerMap
map of custom sub-controllers
Definition: vst3plugin.h:674
The VSTParamUpdateQueue object maintains a parameter update queue for one ASPiK PluginParameter objec...
Definition: vst3plugin.h:284
virtual void PLUGIN_API update(FUnknown *changedUnknown, int32 message) override
Toggle preset.
Definition: vst3plugin.cpp:1337
int32_t getControlID()
Definition: plugingui.h:297
virtual void pushDataValue(double data)
Definition: pluginstructures.h:1406
bool addUnit(Unit *unit)
IUnitInfo handler.
Definition: vst3plugin.cpp:1359
Information about a MIDI event.
Definition: pluginstructures.h:561
unsigned int getParameterIndex()
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1682
VST3Plugin * editController
parent VST3
Definition: vst3plugin.h:950
virtual bool guiDidOpen()
Definition: vst3plugin.h:602