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 // --- windows.h bug
22 // #define ENABLE_WINDOWS_H 1
23 
24 #if MAC
25 #include <CoreFoundation/CoreFoundation.h>
26 #else
27 #ifdef ENABLE_WINDOWS_H
28  #include <windows.h>
29 #endif
30 extern void* hInstance; // VSTGUI hInstance
31 #endif
32 
33 #include <vector>
34 
35 namespace Steinberg {
36 namespace Vst {
37 namespace ASPiK {
38 /*
39  The Processor object here ALSO contains the Edit Controller component since these
40  are combined as SingleComponentEffect; see documentation
41 */
42 class VSTParamUpdateQueue;
43 class GUIPluginConnector;
45 class VSTMIDIEventQueue;
46 
58 class VST3Plugin : public SingleComponentEffect, public IMidiMapping
59 {
60 public:
61  // --- constructor
62  VST3Plugin();
63 
64  // --- destructor
65  ~VST3Plugin();
66 
67  /*** IAudioProcessor Interface ***/
69  tresult PLUGIN_API initialize(FUnknown* context) override;
70 
72  tresult PLUGIN_API setBusArrangements(SpeakerArrangement* inputs, int32 numIns, SpeakerArrangement* outputs, int32 numOuts) override;
73 
75  tresult PLUGIN_API canProcessSampleSize(int32 symbolicSampleSize) override;
76 
78  tresult PLUGIN_API setupProcessing(ProcessSetup& newSetup) override;
79 
81  tresult PLUGIN_API setActive(TBool state) override;
82 
84  // These get/set the plugin variables
85  tresult PLUGIN_API setState(IBStream* fileStream) override;
86  tresult PLUGIN_API getState(IBStream* fileStream) override;
87 
89  // Update the GUI control variables
90  bool doControlUpdate(ProcessData& data);
91 
93  tresult PLUGIN_API process(ProcessData& data) override;
94 
96  virtual tresult PLUGIN_API getMidiControllerAssignment(int32 busIndex, int16 channel, CtrlNumber midiControllerNumber, ParamID& id/*out*/) override;
97 
99  IPlugView* PLUGIN_API createView(const char* _name) override;
100 
102  tresult PLUGIN_API terminate() override;
103 
105  virtual tresult receiveText(const char8* text) override;
106 
108  tresult PLUGIN_API setParamNormalizedFromFile(ParamID tag, ParamValue value);
109  tresult PLUGIN_API setParamNormalized (ParamID tag, ParamValue value) override;
110 
112  tresult PLUGIN_API setComponentState(IBStream* fileStream) override;
113 
115  void updateMeters(ProcessData& data, bool forceOff = false);
116 
118  static FUnknown* createInstance(void* context) {return (IAudioProcessor*)new VST3Plugin(); }
119 
121  bool addUnit (Unit* unit);
122  tresult PLUGIN_API getUnitInfo (int32 unitIndex, UnitInfo& info /*out*/) override;
123 
125  bool addProgramList (ProgramList* list);
126  ProgramList* getProgramList(ProgramListID listId) const;
127  tresult notifyPogramListChange(ProgramListID listId, int32 programIndex = kAllProgramInvalid);
128  virtual int32 PLUGIN_API getProgramListCount() override;
129  virtual tresult PLUGIN_API getProgramListInfo(int32 listIndex, ProgramListInfo& info /*out*/) override;
130  virtual tresult PLUGIN_API getProgramName(ProgramListID listId, int32 programIndex, String128 name /*out*/) override;
131  virtual tresult PLUGIN_API getProgramInfo(ProgramListID listId, int32 programIndex, CString attributeId /*in*/, String128 attributeValue /*out*/) override;
132  virtual tresult PLUGIN_API hasProgramPitchNames(ProgramListID listId, int32 programIndex) override;
133  virtual tresult PLUGIN_API getProgramPitchName(ProgramListID listId, int32 programIndex, int16 midiPitch, String128 name /*out*/) override;
134  virtual tresult setProgramName(ProgramListID listId, int32 programIndex, const String128 name /*in*/) override;
135 
137  virtual void PLUGIN_API update(FUnknown* changedUnknown, int32 message) override ;
138 
139  // --- latency support
140  uint32 m_uLatencyInSamples = 0;
141 
143  virtual uint32 PLUGIN_API getLatencySamples() override {
144  return m_uLatencyInSamples; }
145 
147  virtual uint32 PLUGIN_API getTailSamples() override ;
148 
150  void updateHostInfo(ProcessData& data, HostInfo* hostInfo);
151 
152  static FUID* getFUID();
153  static const char* getPluginName();
154  static const char* getVendorName();
155  static const char* getVendorURL();
156  static const char* getVendorEmail();
157  static CString getPluginType();
158 
159  // --- define the IMidiMapping interface
160  OBJ_METHODS(VST3Plugin, SingleComponentEffect)
161  DEFINE_INTERFACES
162  DEF_INTERFACE(IMidiMapping)
163  DEF_INTERFACE(IUnitInfo)
164  END_DEFINE_INTERFACES(SingleComponentEffect)
165  REFCOUNT_METHODS(SingleComponentEffect)
166 
167 
168 private:
169  // --- our plugin core and interfaces
170  PluginCore* pluginCore = nullptr;
171  GUIPluginConnector* guiPluginConnector = nullptr;
172  PluginHostConnector* pluginHostConnector = nullptr;
173  VSTMIDIEventQueue* midiEventQueue = nullptr;
174  bool plugInSideBypass = false;
175  bool hasSidechain = false;
176 
177 protected:
178  // --- sample accurate parameter automation
180  unsigned int sampleAccuracy = 1;
181  bool enableSAAVST3 = false;
182 
183  // --- IUnitInfo and factory Preset support
184  typedef std::vector<IPtr<ProgramList> > ProgramListVector;
185  typedef std::map<ProgramListID, ProgramListVector::size_type> ProgramIndexMap;
186  typedef std::vector<IPtr<Unit> > UnitVector;
187  UnitVector units;
188  ProgramListVector programLists;
189  ProgramIndexMap programIndexMap;
190  UnitID selectedUnit;
191 
192 
193 #if defined _WINDOWS || defined _WINDLL
194 #ifdef ENABLE_WINDOWS_H
195  // --- getMyDLLDirectory()
196  // returns the directory where the .component resides
197  char* getMyDLLDirectory(UString cPluginName)
198  {
199  HMODULE hmodule = GetModuleHandle(cPluginName);
200 
201  TCHAR dir[MAX_PATH];
202  memset(&dir[0], 0, MAX_PATH*sizeof(TCHAR));
203  dir[MAX_PATH-1] = '\0';
204 
205  if(hmodule)
206  GetModuleFileName(hmodule, &dir[0], MAX_PATH);
207  else
208  return nullptr;
209 
210  // convert to UString
211  UString DLLPath(&dir[0], MAX_PATH);
212 
213  char* pFullPath = new char[MAX_PATH];
214  char* pDLLRoot = new char[MAX_PATH];
215 
216  DLLPath.toAscii(pFullPath, MAX_PATH);
217 
218  size_t nLenDir = strlen(pFullPath);
219  size_t nLenDLL = wcslen(cPluginName) + 1; // +1 is for trailing backslash
220  memcpy(pDLLRoot, pFullPath, nLenDir-nLenDLL);
221  pDLLRoot[nLenDir-nLenDLL] = '\0';
222 
223  delete [] pFullPath;
224 
225  // caller must delete this after use
226  return pDLLRoot;
227  }
228 #endif
229 #endif
230 #if MAC
231  // --- getMyComponentDirectory()
232  // returns the directory where the .component resides
233  char* getMyComponentDirectory(CFStringRef bundleID)
234  {
235  if (bundleID != nullptr)
236  {
237  CFBundleRef helixBundle = CFBundleGetBundleWithIdentifier( bundleID );
238  if(helixBundle != nullptr)
239  {
240  CFURLRef bundleURL = CFBundleCopyBundleURL ( helixBundle );
241  if(bundleURL != nullptr)
242  {
243  CFURLRef componentFolderPathURL = CFURLCreateCopyDeletingLastPathComponent(nullptr, bundleURL);
244 
245  CFStringRef myComponentPath = CFURLCopyFileSystemPath(componentFolderPathURL, kCFURLPOSIXPathStyle);
246  CFRelease(componentFolderPathURL);
247 
248  if(myComponentPath != nullptr)
249  {
250  int nSize = CFStringGetLength(myComponentPath);
251  char* path = new char[nSize+1];
252  memset(path, 0, (nSize+1)*sizeof(char));
253 
254  bool success = CFStringGetCString(myComponentPath, path, nSize+1, kCFStringEncodingASCII);
255  CFRelease(myComponentPath);
256 
257  if(success) return path;
258  else return nullptr;
259  }
260  CFRelease(bundleURL);
261  }
262  }
263  CFRelease(bundleID);
264  }
265  return nullptr;
266  }
267 #endif
268 
269 };
270 
285 {
286 protected:
287  unsigned int bufferSize = 0;
288  ParamValue initialValue = 0.0;
289  ParamValue previousValue = 0.0;
290  ParamValue maxValue = 0.0;
291  ParamValue minValue = 0.0;
292 
293  // --- Store slope and b so that it needs to be calculated only once.
294  ParamValue slope;
295  ParamValue yIntercept;
296 
297  // --- Controls granularity
298  unsigned int* sampleAccuracy = nullptr;
299  int queueIndex = 0;
300  int queueSize = 0;
301  IParamValueQueue* parameterQueue = nullptr;
302  int x1, x2 = 0;
303  double y1, y2 = 0;
304  bool dirtyBit = false;
305  int sampleOffset = 0;
306 
307 public:
308  VSTParamUpdateQueue(void);
309  virtual ~VSTParamUpdateQueue(void){}
310  void initialize(ParamValue _initialValue, ParamValue _minValue, ParamValue _maxValue, unsigned int* _sampleAccuracy);
311  void setParamValueQueue(IParamValueQueue* _paramValueQueue, unsigned int _bufferSize);
312  void setSlope();
313  ParamValue interpolate(int x1, int x2, ParamValue y1, ParamValue y2, int x);
314  int needsUpdate(int x, ParamValue &value);
315 
316  // --- IParameterUpdateQueue
317  unsigned int getParameterIndex();
318  bool getValueAtOffset(long int _sampleOffset, double _previousValue, double& _nextValue);
319  bool getNextValue(double& _nextValue);
320 };
321 
322 
323 
343 {
344 public:
345  PluginHostConnector(VST3Plugin* _editController) {editController = _editController;}
346  virtual ~PluginHostConnector(){}
347 
353  virtual void sendHostMessage(const HostMessageInfo& hostMessageInfo)
354  {
355  switch(hostMessageInfo.hostMessage)
356  {
357  case sendGUIUpdate:
358  {
359  GUIUpdateData guiUpdateData = hostMessageInfo.guiUpdateData;
360 
361  for(unsigned int i = 0; i < guiUpdateData.guiParameters.size(); i++)
362  {
363  GUIParameter guiParam = guiUpdateData.guiParameters[i];
364  if(editController)
365  {
366  ParamValue normalizedValue = editController->plainParamToNormalized(guiParam.controlID, guiParam.actualValue);
367  editController->setParamNormalized(guiParam.controlID, normalizedValue);
368  }
369  }
370 
371  // --- clean up
372  for (unsigned int i = 0; i < guiUpdateData.guiParameters.size(); i++)
373  guiUpdateData.guiParameters.pop_back();
374 
375  break;
376  }
377  default:
378  break;
379  }
380  }
381 
382 protected:
384 };
385 
386 // --- GUI -> Plugin interface
402 {
403 public:
405  CustomViewController(ICustomView* _customViewIF) { customViewIF = _customViewIF; }
406  virtual ~CustomViewController() {}
407 
409  virtual void updateView()
410  {
411  if (customViewIF)
412  customViewIF->updateView();
413  }
414 
416  virtual void pushDataValue(double data)
417  {
418  if (customViewIF)
419  customViewIF->pushDataValue(data);
420  }
421 
423  virtual void sendMessage(void* data)
424  {
425  if (customViewIF)
426  customViewIF->sendMessage(data);
427  }
428 
430  void setCustomViewPtr(ICustomView* _customViewIF) { customViewIF = _customViewIF; }
431 
433  const ICustomView* getCustomViewPtr() { return customViewIF; }
434 
436  void clearCustomViewPtr() { customViewIF = nullptr; }
437 
438 
439 private:
440  ICustomView* customViewIF = nullptr;
441 };
442 
464 {
465 public:
467  GUIPluginConnector(PluginCore* _pluginCore, VST3Plugin* _editController)
468  {
469  pluginCore = _pluginCore;
470  editController = _editController;
471  }
472 
475  {
476  for (customViewControllerMap::const_iterator it = customSubControllerMap.begin(), end = customSubControllerMap.end(); it != end; ++it)
477  {
478  delete it->second;
479  }
480  for (customViewControllerMap::const_iterator it = customViewMap.begin(), end = customViewMap.end(); it != end; ++it)
481  {
482  delete it->second;
483  }
484  }
485 
487  virtual void parameterChanged(int32_t controlID, double actualValue, double normalizedValue)
488  {
489  if(pluginCore)
490  pluginCore->guiParameterChanged(controlID, actualValue);
491 
492  if(!editController) return;
493 
494  // --- set parameter on object
495  editController->setParamNormalized(controlID, normalizedValue);
496 
497  // --- perform the operation
498  editController->performEdit(controlID, normalizedValue);
499  }
500 
502  virtual double getNormalizedPluginParameter(int32_t controlID)
503  {
504  if(!editController) return 0.0;
505 
506  Parameter* param = editController->getParameterObject(controlID);
507 
508  if(!param) return 0.0;
509 
510  return param->getNormalized();
511  }
512 
514  virtual bool registerSubcontroller(std::string subcontrollerName, ICustomView* customViewConnector)
515  {
516  // --- do we have this in our map already?
517  CustomViewController* pCVC = nullptr;
518 
519  customViewControllerMap::const_iterator it = customSubControllerMap.find(subcontrollerName);
520  if (it != customSubControllerMap.end())
521  {
522  pCVC = it->second;
523  pCVC->setCustomViewPtr(customViewConnector);
524  }
525  else
526  {
527  pCVC = new CustomViewController(customViewConnector);
528  customSubControllerMap.insert(std::make_pair(subcontrollerName, pCVC));
529  }
530 
531  MessageInfo info(PLUGINGUI_REGISTER_SUBCONTROLLER);
532  info.inMessageString = subcontrollerName;
533  info.inMessageData = pCVC;
534 
535  if (pluginCore && pluginCore->processMessage(info))
536  return true;
537 
538  return false;
539  }
540 
542  virtual bool deRregisterSubcontroller(ICustomView* customViewConnector)
543  {
544  CustomViewController* pCVC = getCustomSubController(customViewConnector);
545  if (pCVC)
546  {
547  pCVC->clearCustomViewPtr();
548 
549  MessageInfo info(PLUGINGUI_DE_REGISTER_SUBCONTROLLER);
550  info.inMessageString = "";
551  info.inMessageData = pCVC;
552 
553  if (pluginCore && pluginCore->processMessage(info))
554  return true;
555  }
556 
557  return false;
558  }
559 
561  virtual bool registerCustomView(std::string customViewName, ICustomView* customViewConnector)
562  {
563  // --- do we have this in our map already?
564  CustomViewController* pCVC = nullptr;
565 
566  customViewControllerMap::const_iterator it = customViewMap.find(customViewName);
567  if (it != customViewMap.end())
568  {
569  pCVC = it->second;
570  pCVC->setCustomViewPtr(customViewConnector);
571  }
572  else
573  {
574  pCVC = new CustomViewController(customViewConnector);
575  customViewMap.insert(std::make_pair(customViewName, pCVC));
576  }
577 
578  MessageInfo info(PLUGINGUI_REGISTER_CUSTOMVIEW);
579  info.inMessageString = customViewName;
580  info.inMessageData = pCVC;
581 
582  if(pluginCore && pluginCore->processMessage(info))
583  return true;
584 
585  return false;
586  }
587 
589  virtual bool deRegisterCustomView(ICustomView* customViewConnector)
590  {
591  CustomViewController* pCVC = getCustomViewController(customViewConnector);
592  if (pCVC)
593  {
594  // --- clear it
595  pCVC->clearCustomViewPtr();
596 
597  MessageInfo info(PLUGINGUI_DE_REGISTER_CUSTOMVIEW);
598  info.inMessageString = "";
599  info.inMessageData = pCVC;
600 
601  if (pluginCore && pluginCore->processMessage(info))
602  return true;
603  }
604 
605  return false;
606  }
607 
609  virtual bool guiDidOpen()
610  {
611  if(!pluginCore) return false;
612  MessageInfo info(PLUGINGUI_DIDOPEN);
613  return pluginCore->processMessage(info);
614  }
615 
617  virtual bool guiWillClose()
618  {
619  if(!pluginCore) return false;
620 
621  for (customViewControllerMap::const_iterator it = customViewMap.begin(), end = customViewMap.end(); it != end; ++it)
622  {
623  it->second->clearCustomViewPtr();
624  }
625  for (customViewControllerMap::const_iterator it = customSubControllerMap.begin(), end = customSubControllerMap.end(); it != end; ++it)
626  {
627  it->second->clearCustomViewPtr();
628  }
629 
630  MessageInfo info(PLUGINGUI_WILLCLOSE);
631  return pluginCore->processMessage(info);
632  }
633 
635  virtual bool guiTimerPing()
636  {
637  if(!pluginCore) return false;
638  MessageInfo info(PLUGINGUI_TIMERPING);
639  return pluginCore->processMessage(info);
640  }
641 
643  virtual bool checkNonBoundValueChange(int tag, float normalizedValue)
644  {
645  if(!pluginCore) return false;
646 
647  // --- do any additional stuff here
648  // --- dispatch non-bound value changes directly to receiver
649 
650  return false;
651  }
652 
653 protected:
654  PluginCore* pluginCore = nullptr;
656 
657  // --- this is for supporting the persistent interface pointer for the core object
658  // and is required by ASPiK Specifications
659  typedef std::map<std::string, CustomViewController*> customViewControllerMap;
660  customViewControllerMap customViewMap;
661 
664  {
665  for (customViewControllerMap::const_iterator it = customViewMap.begin(), end = customViewMap.end(); it != end; ++it)
666  {
667  if (it->second->getCustomViewPtr() == customViewConnector)
668  return it->second;
669  }
670 
671  return nullptr;
672  }
673 
675 
678  {
679  for (customViewControllerMap::const_iterator it = customSubControllerMap.begin(), end = customSubControllerMap.end(); it != end; ++it)
680  {
681  if (it->second->getCustomViewPtr() == customViewConnector)
682  return it->second;
683  }
684 
685  return nullptr;
686  }
687 
688 };
689 
706 {
707 public:
708  VSTMIDIEventQueue(PluginCore* _pluginCore)
709  {
710  pluginCore = _pluginCore;
711  };
712 
713  virtual ~VSTMIDIEventQueue(){}
714 
715 public:
717  void setEventList(IEventList* _inputEvents)
718  {
719  inputEvents = _inputEvents;
720  currentEventIndex = 0;
721  }
722 
724  virtual unsigned int getEventCount()
725  {
726  if (inputEvents)
727  return inputEvents->getEventCount();
728 
729  return 0;
730  }
731 
733  virtual bool fireMidiEvents(unsigned int sampleOffset)
734  {
735  if (!inputEvents)
736  return false;
737 
738  Event e = { 0 };
739  bool eventOccurred = false;
740  bool haveEvents = false;
741  if (inputEvents->getEvent(currentEventIndex, e) == kResultTrue)
742  haveEvents = true;
743  else
744  return false;
745 
746  const unsigned char MIDI_NOTE_OFF = 0x80;
747  const unsigned char MIDI_NOTE_ON = 0x90;
748  const unsigned char MIDI_POLY_PRESSURE = 0xA0;
749 
750  while (haveEvents)
751  {
752  if (inputEvents->getEvent(currentEventIndex, e) == kResultTrue)
753  {
754  if (e.sampleOffset != sampleOffset)
755  return false;
756 
757  // --- process Note On or Note Off messages
758  switch (e.type)
759  {
760  // --- NOTE ON
761  case Event::kNoteOnEvent:
762  {
763  midiEvent event;
764  event.midiMessage = (unsigned int)MIDI_NOTE_ON;
765  event.midiChannel = (unsigned int)e.noteOn.channel;
766  event.midiData1 = (unsigned int)e.noteOn.pitch;
767  event.midiData2 = (unsigned int)(127.0*e.noteOn.velocity);
768  event.midiSampleOffset = e.sampleOffset;
769  eventOccurred = true;
770 
771  // --- send to core for processing
772  if(pluginCore)
774  break;
775  }
776 
777  // --- NOTE OFF
778  case Event::kNoteOffEvent:
779  {
780  // --- get the channel/note/vel
781  midiEvent event;
782  event.midiMessage = (unsigned int)MIDI_NOTE_OFF;
783  event.midiChannel = (unsigned int)e.noteOff.channel;
784  event.midiData1 = (unsigned int)e.noteOff.pitch;
785  event.midiData2 = (unsigned int)(127.0*e.noteOff.velocity);
786  event.midiSampleOffset = e.sampleOffset;
787  eventOccurred = true;
788 
789  // --- send to core for processing
790  if(pluginCore)
792 
793  break;
794  }
795 
796  // --- polyphonic aftertouch 0xAn
797  case Event::kPolyPressureEvent:
798  {
799  midiEvent event;
800  event.midiMessage = (unsigned int)MIDI_POLY_PRESSURE;
801  event.midiChannel = (unsigned int)e.polyPressure.channel;
802  event.midiData1 = (unsigned int)e.polyPressure.pitch;
803  event.midiData2 = (unsigned int)(127.0*e.polyPressure.pressure);
804  event.midiSampleOffset = e.sampleOffset;
805  eventOccurred = true;
806 
807  // --- send to core for processing
808  if(pluginCore)
810 
811  break;
812  }
813  } // switch
814 
815  // --- have next event?
816  if (inputEvents->getEvent(currentEventIndex + 1, e) == kResultTrue)
817  {
818  if (e.sampleOffset == sampleOffset)
819  {
820  // --- avance current index
822  }
823  else
824  haveEvents = false;
825  }
826  else
827  haveEvents = false;
828  }
829  }
830 
831  return eventOccurred;
832  }
833 
834 protected:
835  PluginCore* pluginCore = nullptr;
836  IEventList* inputEvents = nullptr;
837  unsigned int currentEventIndex = 0;
838 };
839 
851 class VST3UpdateHandler: public FObject
852 {
853 public:
854  VST3UpdateHandler(VSTGUI::ControlUpdateReceiver* _receiver, VST3Plugin* _editController){ receiver = _receiver; editController = _editController; }
855  ~VST3UpdateHandler(){}
856 
857  virtual void PLUGIN_API update (FUnknown* changedUnknown, int32 message)
858  {
859  if(message == IDependent::kChanged && receiver && editController)
860  {
861  double normalizedValue = editController->getParamNormalized (receiver->getControlID());
862  receiver->updateControlsWithNormalizedValue(normalizedValue);
863  }
864  }
865 
866 private:
867  VSTGUI::ControlUpdateReceiver* receiver = nullptr;
868  VST3Plugin* editController = nullptr;
869 
870 };
871 
872 
884 class PluginEditor: public CPluginView, public VSTGUI::PluginGUI, public IGUIWindowFrame
885 {
886 public:
887  PluginEditor(VSTGUI::UTF8StringPtr _xmlFile, PluginCore* _pluginCore, GUIPluginConnector* _guiPluginConnector, PluginHostConnector* _pluginHostConnector, VST3Plugin* editController);
888  virtual ~PluginEditor();
889 
890  // --- aet of update handlers, specific to VST3: this will allow us to
891  // remotely update the GUI in a threadsafe and VST-approved manner
892  typedef std::map<int32_t, VST3UpdateHandler*> UpdaterHandlerMap;
893  UpdaterHandlerMap updateHandlers;
894 
895  //---from IPlugView------- VST3 Specific
896  IPlugFrame* plugFrame;
897  const ViewRect& getRect() const { return rect; }
898  void setRect(const ViewRect& r) { rect = r; }
899  bool isAttached() const { return systemWindow != 0; }
900  virtual void attachedToParent() override {}
901  virtual void removedFromParent() override {}
902 
903  virtual tresult PLUGIN_API attached(void* parent, FIDString type) override;
904  virtual tresult PLUGIN_API removed() override;
905  virtual tresult PLUGIN_API onWheel(float distance) override { return kResultFalse; }
906 
907  virtual tresult PLUGIN_API isPlatformTypeSupported(FIDString type) override;
908  virtual tresult PLUGIN_API onSize(ViewRect* newSize) override;
909  virtual tresult PLUGIN_API getSize(ViewRect* size) override;
910 
911  virtual tresult PLUGIN_API onFocus(TBool /*state*/) override { return kResultFalse; }
912  virtual tresult PLUGIN_API setFrame(IPlugFrame* frame) override;// { plugFrame = frame; return kResultTrue; }
913  virtual tresult PLUGIN_API canResize() override{ return kResultTrue; }
914  virtual tresult PLUGIN_API checkSizeConstraint(ViewRect* rect) override
915  {
916  if (showGUIEditor)
917  return kResultTrue;
918 
919  // --- clamp it
920  ViewRect viewRect = getRect();
921  rect->right = viewRect.right;
922  rect->bottom = viewRect.bottom;
923 
924  return kResultFalse;
925  }
926 
927  virtual bool setWindowFrameSize(double left = 0, double top = 0, double right = 0, double bottom = 0) override //CRect* newSize)
928  {
929  ViewRect vr(0, 0, right, bottom);
930  setRect(vr);
931  if (plugFrame)
932  plugFrame->resizeView(this, &vr);
933  return true;
934  }
935 
936  virtual bool getWindowFrameSize(double& left, double& top, double& right, double& bottom) override
937  {
938  ViewRect viewRect = getRect();
939  left = 0.0;
940  top = 0.0;
941  right = viewRect.getWidth();
942  bottom = viewRect.getHeight();
943  return true;
944  }
945 
946 protected:
947  PluginCore* pluginCore = nullptr;
951 };
952 
953 
954 
955 }}} // namespaces
956 
957 #endif
958 
959 
960 
961 
962 
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:607
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:1454
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:651
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:353
virtual tresult setProgramName(ProgramListID listId, int32 programIndex, const String128 name) override
Set preset name.
Definition: vst3plugin.cpp:1287
ProgramList * getProgramList(ProgramListID listId) const
part of the IUnitInfo support for presets; generally no user editable code here.
Definition: vst3plugin.cpp:1180
void setEventList(IEventList *_inputEvents)
Definition: vst3plugin.h:717
tresult PLUGIN_API canProcessSampleSize(int32 symbolicSampleSize) override
Client queries us for our supported sample lengths.
Definition: vst3plugin.cpp:434
tresult notifyPogramListChange(ProgramListID listId, int32 programIndex=kAllProgramInvalid)
If list changes; should not be called as we only have one program list.
Definition: vst3plugin.cpp:1197
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:508
bool getValueAtOffset(long int _sampleOffset, double _previousValue, double &_nextValue)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1756
virtual tresult PLUGIN_API getProgramInfo(ProgramListID listId, int32 programIndex, CString attributeId, String128 attributeValue) override
Only used for presets.
Definition: vst3plugin.cpp:1309
virtual tresult PLUGIN_API getProgramPitchName(ProgramListID listId, int32 programIndex, int16 midiPitch, String128 name) override
Not Used.
Definition: vst3plugin.cpp:1353
Interface for VST3 parameter value update queue (sample accurate automation)
Definition: pluginstructures.h:1583
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:2004
CustomViewController(ICustomView *_customViewIF)
Definition: vst3plugin.h:405
The VSTMIDIEventQueue interface queues incoming MIDI messages and blasts them out during the buffer p...
Definition: vst3plugin.h:705
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
IPlugView *PLUGIN_API createView(const char *_name) override
creates the custom GUI view
Definition: vst3plugin.cpp:960
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:1033
interface file for ASPiK GUI object
void updateHostInfo(ProcessData &data, HostInfo *hostInfo)
update the incoming host data for the plugin core
Definition: vst3plugin.cpp:730
VST3Plugin * editController
parent VST3
Definition: vst3plugin.h:950
virtual bool guiTimerPing()
Definition: vst3plugin.h:635
uint32_t controlID
ID value.
Definition: pluginstructures.h:352
PluginCore * pluginCore
the core
Definition: vst3plugin.h:947
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:303
virtual double getNormalizedPluginParameter(int32_t controlID)
Definition: vst3plugin.h:502
VST3Plugin * editController
our parent plugin
Definition: vst3plugin.h:383
GUIPluginConnector * guiPluginConnector
GUI Plugin interface.
Definition: vst3plugin.h:948
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:545
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:1826
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:481
int needsUpdate(int x, ParamValue &value)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1695
const ICustomView * getCustomViewPtr()
Definition: vst3plugin.h:433
uint32_t midiMessage
BYTE message as UINT.
Definition: pluginstructures.h:641
virtual void updateView()
Definition: vst3plugin.h:409
unsigned int currentEventIndex
index of current event
Definition: vst3plugin.h:837
IEventList * inputEvents
the current event list for this buffer cycle
Definition: vst3plugin.h:836
virtual bool registerCustomView(std::string customViewName, ICustomView *customViewConnector)
Definition: vst3plugin.h:561
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
PluginHostConnector * pluginHostConnector
Plugin Host interface.
Definition: vst3plugin.h:949
std::map< std::string, CustomViewController * > customViewControllerMap
map of custom view controllers
Definition: vst3plugin.h:659
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:1008
static const char * getVendorURL()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1486
GUIPluginConnector(PluginCore *_pluginCore, VST3Plugin *_editController)
Definition: vst3plugin.h:467
VSTParamUpdateQueue(void)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1539
virtual bool fireMidiEvents(unsigned int sampleOffset)
Definition: vst3plugin.h:733
virtual bool deRegisterCustomView(ICustomView *customViewConnector)
Definition: vst3plugin.h:589
virtual tresult PLUGIN_API getProgramListInfo(int32 listIndex, ProgramListInfo &info) override
Get information about our preset list.
Definition: vst3plugin.cpp:1235
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:2041
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:617
virtual void pushDataValue(double data)
Definition: vst3plugin.h:416
Definition: pluginstructures.h:485
virtual ~GUIPluginConnector()
Definition: vst3plugin.h:474
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
virtual void parameterChanged(int32_t controlID, double actualValue, double normalizedValue)
Definition: vst3plugin.h:487
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:1217
The VST GUI for the plugin. This is needed because VST3 requires an IPlugView GUI, which is VST3 specific (involves VST3 SDK files)
Definition: vst3plugin.h:884
VST3Plugin * editController
the VST3
Definition: vst3plugin.h:655
virtual uint32 PLUGIN_API getLatencySamples() override
Definition: vst3plugin.h:143
void initialize(ParamValue _initialValue, ParamValue _minValue, ParamValue _maxValue, unsigned int *_sampleAccuracy)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1565
virtual tresult PLUGIN_API getProgramName(ProgramListID listId, int32 programIndex, String128 name) override
Get preset name.
Definition: vst3plugin.cpp:1261
void setParamValueQueue(IParamValueQueue *_paramValueQueue, unsigned int _bufferSize)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1586
virtual bool setWindowFrameSize(double left=0, double top=0, double right=0, double bottom=0) override
Definition: vst3plugin.h:927
virtual bool deRregisterSubcontroller(ICustomView *customViewConnector)
Definition: vst3plugin.h:542
virtual void sendMessage(void *data)
Definition: vst3plugin.h:423
static FUID * getFUID()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1434
The ControlUpdateReceiver object is the connection mechanism between PluginParameter objects and thei...
Definition: plugingui.h:83
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:1079
PluginCore * pluginCore
the core object
Definition: vst3plugin.h:654
std::vector< GUIParameter > guiParameters
list of updates
Definition: pluginstructures.h:461
tresult PLUGIN_API setupProcessing(ProcessSetup &newSetup) override
we get information about sample rate, bit-depth, etc...
Definition: vst3plugin.cpp:455
static CString getPluginType()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1518
static const char * getVendorEmail()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1502
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:1805
tresult PLUGIN_API getUnitInfo(int32 unitIndex, UnitInfo &info) override
IUnitInfo handler.
Definition: vst3plugin.cpp:1413
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:2063
tresult PLUGIN_API initialize(FUnknown *context) override
object initializer
Definition: vst3plugin.cpp:71
virtual unsigned int getEventCount()
Definition: vst3plugin.h:724
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:430
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:913
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:1606
virtual bool getWindowFrameSize(double &left, double &top, double &right, double &bottom) override
Definition: vst3plugin.h:936
virtual void sendMessage(void *data)
Definition: pluginstructures.h:1416
void clearCustomViewPtr()
Definition: vst3plugin.h:436
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:1959
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:514
~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:1160
tresult PLUGIN_API process(ProcessData &data) override
the VST3 audio processing function
Definition: vst3plugin.cpp:759
Custom interface to allow resizing of GUI window; this is mainly used for the GUI designer...
Definition: pluginstructures.h:1430
base class interface file for ASPiK plugincore object
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:1674
customViewControllerMap customSubControllerMap
map of custom sub-controllers
Definition: vst3plugin.h:674
virtual bool checkNonBoundValueChange(int tag, float normalizedValue)
Definition: vst3plugin.h:643
virtual void updateView()=0
virtual tresult PLUGIN_API hasProgramPitchNames(ProgramListID listId, int32 programIndex) override
Not Used.
Definition: vst3plugin.cpp:1331
static FUnknown * createInstance(void *context)
Definition: vst3plugin.h:118
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:1106
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:1859
void updateMeters(ProcessData &data, bool forceOff=false)
update the outbound VST3 parameters that correspond to plugin meter variables
Definition: vst3plugin.cpp:874
VSTParamUpdateQueue ** m_pParamUpdateQueueArray
sample accurate parameter automation
Definition: vst3plugin.h:179
static const char * getVendorName()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1470
Little update handler object for VST-approved GUI updating.
Definition: vst3plugin.h:851
bool getNextValue(double &_nextValue)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1781
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:1842
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:354
PluginCore * pluginCore
the core object
Definition: vst3plugin.h:835
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:1374
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:1396
Information about a MIDI event.
Definition: pluginstructures.h:561
unsigned int getParameterIndex()
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1740
virtual bool guiDidOpen()
Definition: vst3plugin.h:609