ASPiK SDK
vst3plugin.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 // ASPiK VST Shell File: vst3plugin.h
3 //
19 // -----------------------------------------------------------------------------
20 #ifndef __VST3Plugin__
21 #define __VST3Plugin__
22 
23 #include "public.sdk/source/vst/vstsinglecomponenteffect.h"
24 
25 // NOTE: the wrapper include here MUST:
26 // be AFTER the #include vstsinglecomponenteffect AND
27 // PRECEDE any #include that references vsteditcontroller
28 #include "public.sdk/source/vst/vst2wrapper/vst2wrapper.h"
29 
30 // --- MIDI EVENTS
31 #include "pluginterfaces/vst/ivstevents.h"
32 
33 // --- WString Support
34 #include "pluginterfaces/base/ustring.h"
35 
36 // --- our plugin core object
37 #include "plugincore.h"
38 #include "plugingui.h"
39 
40 #if MAC
41 #include <CoreFoundation/CoreFoundation.h>
42 #else
43 #include <windows.h>
44 extern void* hInstance; // VSTGUI hInstance
45 #endif
46 
47 #include <vector>
48 
49 // --- NOTE: multiple namespacing facilitates use of Steinberg::Vst:: objects as well as VSTGUI
50 namespace Steinberg {
51 namespace Vst {
52 namespace ASPiK {
53 /*
54  The Processor object here ALSO contains the Edit Controller component since these
55  are combined as SingleComponentEffect; see documentation
56 */
57 class VSTParamUpdateQueue;
58 class GUIPluginConnector;
60 class VSTMIDIEventQueue;
61 
73 class VST3Plugin : public SingleComponentEffect, public IMidiMapping
74 {
75 public:
76  // --- constructor
77  VST3Plugin();
78 
79  // --- destructor
80  ~VST3Plugin();
81 
82  /*** IAudioProcessor Interface ***/
84  tresult PLUGIN_API initialize(FUnknown* context) override;
85 
87  tresult PLUGIN_API setBusArrangements(SpeakerArrangement* inputs, int32 numIns, SpeakerArrangement* outputs, int32 numOuts) override;
88 
90  tresult PLUGIN_API canProcessSampleSize(int32 symbolicSampleSize) override;
91 
93  tresult PLUGIN_API setupProcessing(ProcessSetup& newSetup) override;
94 
96  tresult PLUGIN_API setActive(TBool state) override;
97 
99  // These get/set the RackAFX variables
100  tresult PLUGIN_API setState(IBStream* fileStream) override;
101  tresult PLUGIN_API getState(IBStream* fileStream) override;
102 
104  // Update the GUI control variables
105  bool doControlUpdate(ProcessData& data);
106 
108  tresult PLUGIN_API process(ProcessData& data) override;
109 
111  virtual tresult PLUGIN_API getMidiControllerAssignment(int32 busIndex, int16 channel, CtrlNumber midiControllerNumber, ParamID& id/*out*/) override;
112 
114  IPlugView* PLUGIN_API createView(const char* _name) override;
115 
117  tresult PLUGIN_API terminate() override;
118 
120  virtual tresult receiveText(const char8* text) override;
121 
123  tresult PLUGIN_API setParamNormalizedFromFile(ParamID tag, ParamValue value);
124 
126  tresult PLUGIN_API setComponentState(IBStream* fileStream) override;
127 
129  void updateMeters(ProcessData& data, bool forceOff = false);
130 
132  static FUnknown* createInstance(void* context) {return (IAudioProcessor*)new VST3Plugin(); }
133 
135  bool addUnit (Unit* unit);
136 
138  bool addProgramList (ProgramList* list);
139  ProgramList* getProgramList(ProgramListID listId) const;
140  tresult notifyPogramListChange(ProgramListID listId, int32 programIndex = kAllProgramInvalid);
141 
142  tresult PLUGIN_API setParamNormalized (ParamID tag, ParamValue value) override;
143  virtual int32 PLUGIN_API getProgramListCount() override;
144  virtual tresult PLUGIN_API getProgramListInfo(int32 listIndex, ProgramListInfo& info /*out*/) override;
145  virtual tresult PLUGIN_API getProgramName(ProgramListID listId, int32 programIndex, String128 name /*out*/) override;
146  virtual tresult PLUGIN_API getProgramInfo(ProgramListID listId, int32 programIndex, CString attributeId /*in*/, String128 attributeValue /*out*/) override;
147  virtual tresult PLUGIN_API hasProgramPitchNames(ProgramListID listId, int32 programIndex) override;
148  virtual tresult PLUGIN_API getProgramPitchName(ProgramListID listId, int32 programIndex, int16 midiPitch, String128 name /*out*/) override;
149  virtual tresult setProgramName(ProgramListID listId, int32 programIndex, const String128 name /*in*/) override;
150 
152  virtual void PLUGIN_API update(FUnknown* changedUnknown, int32 message) override ;
153 
154  // --- latency support
155  uint32 m_uLatencyInSamples = 0;
156 
158  virtual uint32 PLUGIN_API getLatencySamples() override {
159  return m_uLatencyInSamples; }
160 
162  virtual uint32 PLUGIN_API getTailSamples() override ;
163 
165  void updateHostInfo(ProcessData& data, HostInfo* hostInfo);
166 
167  static FUID* getFUID();
168  static const char* getPluginName();
169  static const char* getVendorName();
170  static const char* getVendorURL();
171  static const char* getVendorEmail();
172  static CString getPluginType();
173 
174  // --- define the IMidiMapping interface
175  OBJ_METHODS(VST3Plugin, SingleComponentEffect)
176  DEFINE_INTERFACES
177  DEF_INTERFACE(IMidiMapping)
178  DEF_INTERFACE(IUnitInfo)
179  END_DEFINE_INTERFACES(SingleComponentEffect)
180  REFCOUNT_METHODS(SingleComponentEffect)
181 
182 
183 private:
184  // --- our plugin core and interfaces
185  PluginCore* pluginCore = nullptr;
186  GUIPluginConnector* guiPluginConnector = nullptr;
187  PluginHostConnector* pluginHostConnector = nullptr;
188  VSTMIDIEventQueue* midiEventQueue = nullptr;
189  bool plugInSideBypass = false;
190  bool hasSidechain = false;
191 
192 protected:
193  // --- sample accurate parameter automation
195  unsigned int sampleAccuracy = 1;
196  bool enableSAAVST3 = false;
197 
198  // --- IUnitInfo and factory Preset support
199  typedef std::vector<IPtr<ProgramList> > ProgramListVector;
200  typedef std::map<ProgramListID, ProgramListVector::size_type> ProgramIndexMap;
201  typedef std::vector<IPtr<Unit> > UnitVector;
202  UnitVector units;
203  ProgramListVector programLists;
204  ProgramIndexMap programIndexMap;
205  UnitID selectedUnit;
206 
207 #if defined _WINDOWS || defined _WINDLL
208  // --- getMyDLLDirectory()
209  // returns the directory where the .component resides
210  char* getMyDLLDirectory(UString cPluginName)
211  {
212  HMODULE hmodule = GetModuleHandle(cPluginName);
213 
214  TCHAR dir[MAX_PATH];
215  memset(&dir[0], 0, MAX_PATH*sizeof(TCHAR));
216  dir[MAX_PATH-1] = '\0';
217 
218  if(hmodule)
219  GetModuleFileName(hmodule, &dir[0], MAX_PATH);
220  else
221  return nullptr;
222 
223  // convert to UString
224  UString DLLPath(&dir[0], MAX_PATH);
225 
226  char* pFullPath = new char[MAX_PATH];
227  char* pDLLRoot = new char[MAX_PATH];
228 
229  DLLPath.toAscii(pFullPath, MAX_PATH);
230 
231  size_t nLenDir = strlen(pFullPath);
232  size_t nLenDLL = wcslen(cPluginName) + 1; // +1 is for trailing backslash
233  memcpy(pDLLRoot, pFullPath, nLenDir-nLenDLL);
234  pDLLRoot[nLenDir-nLenDLL] = '\0';
235 
236  delete [] pFullPath;
237 
238  // caller must delete this after use
239  return pDLLRoot;
240  }
241 #endif
242 
243 #if MAC
244  // --- getMyComponentDirectory()
245  // returns the directory where the .component resides
246  char* getMyComponentDirectory(CFStringRef bundleID)
247  {
248  if (bundleID != nullptr)
249  {
250  CFBundleRef helixBundle = CFBundleGetBundleWithIdentifier( bundleID );
251  if(helixBundle != nullptr)
252  {
253  CFURLRef bundleURL = CFBundleCopyBundleURL ( helixBundle );
254  if(bundleURL != nullptr)
255  {
256  CFURLRef componentFolderPathURL = CFURLCreateCopyDeletingLastPathComponent(nullptr, bundleURL);
257 
258  CFStringRef myComponentPath = CFURLCopyFileSystemPath(componentFolderPathURL, kCFURLPOSIXPathStyle);
259  CFRelease(componentFolderPathURL);
260 
261  if(myComponentPath != nullptr)
262  {
263  int nSize = CFStringGetLength(myComponentPath);
264  char* path = new char[nSize+1];
265  memset(path, 0, (nSize+1)*sizeof(char));
266 
267  bool success = CFStringGetCString(myComponentPath, path, nSize+1, kCFStringEncodingASCII);
268  CFRelease(myComponentPath);
269 
270  if(success) return path;
271  else return nullptr;
272  }
273  CFRelease(bundleURL);
274  }
275  }
276  CFRelease(bundleID);
277  }
278  return nullptr;
279  }
280 #endif
281 
282 };
283 
298 {
299 protected:
300  unsigned int bufferSize = 0;
301  ParamValue initialValue = 0.0;
302  ParamValue previousValue = 0.0;
303  ParamValue maxValue = 0.0;
304  ParamValue minValue = 0.0;
305 
306  // --- Store slope and b so that it needs to be calculated only once.
307  ParamValue slope;
308  ParamValue yIntercept;
309 
310  // --- Controls granularity
311  unsigned int* sampleAccuracy = nullptr;
312  int queueIndex = 0;
313  int queueSize = 0;
314  IParamValueQueue* parameterQueue = nullptr;
315  int x1, x2 = 0;
316  double y1, y2 = 0;
317  bool dirtyBit = false;
318  int sampleOffset = 0;
319 
320 public:
321  VSTParamUpdateQueue(void);
322  virtual ~VSTParamUpdateQueue(void){}
323  void initialize(ParamValue _initialValue, ParamValue _minValue, ParamValue _maxValue, unsigned int* _sampleAccuracy);
324  void setParamValueQueue(IParamValueQueue* _paramValueQueue, unsigned int _bufferSize);
325  void setSlope();
326  ParamValue interpolate(int x1, int x2, ParamValue y1, ParamValue y2, int x);
327  int needsUpdate(int x, ParamValue &value);
328 
329  // --- IParameterUpdateQueue
330  unsigned int getParameterIndex();
331  bool getValueAtOffset(long int _sampleOffset, double _previousValue, double& _nextValue);
332  bool getNextValue(double& _nextValue);
333 };
334 
335 
336 
356 {
357 public:
358  PluginHostConnector(VST3Plugin* _editController) {editController = _editController;}
359  virtual ~PluginHostConnector(){}
360 
366  virtual void sendHostMessage(const HostMessageInfo& hostMessageInfo)
367  {
368  switch(hostMessageInfo.hostMessage)
369  {
370  case sendGUIUpdate:
371  {
372  GUIUpdateData guiUpdateData = hostMessageInfo.guiUpdateData;
373 
374  for(unsigned int i = 0; i < guiUpdateData.guiParameters.size(); i++)
375  {
376  GUIParameter guiParam = guiUpdateData.guiParameters[i];
377  if(editController)
378  {
379  ParamValue normalizedValue = editController->plainParamToNormalized(guiParam.controlID, guiParam.actualValue);
380  editController->setParamNormalized(guiParam.controlID, normalizedValue);
381  }
382  }
383 
384  // --- clean up
385  for (unsigned int i = 0; i < guiUpdateData.guiParameters.size(); i++)
386  guiUpdateData.guiParameters.pop_back();
387 
388  break;
389  }
390  default:
391  break;
392  }
393  }
394 
395 protected:
397 };
398 
399 // --- GUI -> Plugin interface
415 {
416 public:
418  CustomViewController(ICustomView* _customViewIF) { customViewIF = _customViewIF; }
419  virtual ~CustomViewController() {}
420 
422  virtual void updateView()
423  {
424  if (customViewIF)
425  customViewIF->updateView();
426  }
427 
429  virtual void pushDataValue(double data)
430  {
431  if (customViewIF)
432  customViewIF->pushDataValue(data);
433  }
434 
436  virtual void sendMessage(void* data)
437  {
438  if (customViewIF)
439  customViewIF->sendMessage(data);
440  }
441 
443  void setCustomViewPtr(ICustomView* _customViewIF) { customViewIF = _customViewIF; }
444 
446  const ICustomView* getCustomViewPtr() { return customViewIF; }
447 
449  void clearCustomViewPtr() { customViewIF = nullptr; }
450 
451 
452 private:
453  ICustomView* customViewIF = nullptr;
454 };
455 
477 {
478 public:
480  GUIPluginConnector(PluginCore* _pluginCore, VST3Plugin* _editController)
481  {
482  pluginCore = _pluginCore;
483  editController = _editController;
484  }
485 
488  {
489  for (customViewControllerMap::const_iterator it = customSubControllerMap.begin(), end = customSubControllerMap.end(); it != end; ++it)
490  {
491  delete it->second;
492  }
493  for (customViewControllerMap::const_iterator it = customViewMap.begin(), end = customViewMap.end(); it != end; ++it)
494  {
495  delete it->second;
496  }
497  }
498 
500  virtual void parameterChanged(int32_t controlID, double actualValue, double normalizedValue)
501  {
502  if(pluginCore)
503  pluginCore->guiParameterChanged(controlID, actualValue);
504 
505  if(!editController) return;
506 
507  // --- set parameter on object
508  editController->setParamNormalized(controlID, normalizedValue);
509 
510  // --- perform the operation
511  editController->performEdit(controlID, normalizedValue);
512  }
513 
515  virtual double getNormalizedPluginParameter(int32_t controlID)
516  {
517  if(!editController) return 0.0;
518 
519  Parameter* param = editController->getParameterObject(controlID);
520 
521  if(!param) return 0.0;
522 
523  return param->getNormalized();
524  }
525 
527  virtual bool registerSubcontroller(std::string subcontrollerName, ICustomView* customViewConnector)
528  {
529  // --- do we have this in our map already?
530  CustomViewController* pCVC = nullptr;
531 
532  customViewControllerMap::const_iterator it = customSubControllerMap.find(subcontrollerName);
533  if (it != customSubControllerMap.end())
534  {
535  pCVC = it->second;
536  pCVC->setCustomViewPtr(customViewConnector);
537  }
538  else
539  {
540  pCVC = new CustomViewController(customViewConnector);
541  customSubControllerMap.insert(std::make_pair(subcontrollerName, pCVC));
542  }
543 
544  MessageInfo info(PLUGINGUI_REGISTER_SUBCONTROLLER);
545  info.inMessageString = subcontrollerName;
546  info.inMessageData = pCVC;
547 
548  if (pluginCore && pluginCore->processMessage(info))
549  return true;
550 
551  return false;
552  }
553 
555  virtual bool deRregisterSubcontroller(ICustomView* customViewConnector)
556  {
557  CustomViewController* pCVC = getCustomSubController(customViewConnector);
558  if (pCVC)
559  {
560  pCVC->clearCustomViewPtr();
561 
562  MessageInfo info(PLUGINGUI_DE_REGISTER_SUBCONTROLLER);
563  info.inMessageString = "";
564  info.inMessageData = pCVC;
565 
566  if (pluginCore && pluginCore->processMessage(info))
567  return true;
568  }
569 
570  return false;
571  }
572 
574  virtual bool registerCustomView(std::string customViewName, ICustomView* customViewConnector)
575  {
576  // --- do we have this in our map already?
577  CustomViewController* pCVC = nullptr;
578 
579  customViewControllerMap::const_iterator it = customViewMap.find(customViewName);
580  if (it != customViewMap.end())
581  {
582  pCVC = it->second;
583  pCVC->setCustomViewPtr(customViewConnector);
584  }
585  else
586  {
587  pCVC = new CustomViewController(customViewConnector);
588  customViewMap.insert(std::make_pair(customViewName, pCVC));
589  }
590 
591  MessageInfo info(PLUGINGUI_REGISTER_CUSTOMVIEW);
592  info.inMessageString = customViewName;
593  info.inMessageData = pCVC;
594 
595  if(pluginCore && pluginCore->processMessage(info))
596  return true;
597 
598  return false;
599  }
600 
602  virtual bool deRegisterCustomView(ICustomView* customViewConnector)
603  {
604  CustomViewController* pCVC = getCustomViewController(customViewConnector);
605  if (pCVC)
606  {
607  // --- clear it
608  pCVC->clearCustomViewPtr();
609 
610  MessageInfo info(PLUGINGUI_DE_REGISTER_CUSTOMVIEW);
611  info.inMessageString = "";
612  info.inMessageData = pCVC;
613 
614  if (pluginCore && pluginCore->processMessage(info))
615  return true;
616  }
617 
618  return false;
619  }
620 
622  virtual bool guiDidOpen()
623  {
624  if(!pluginCore) return false;
625  MessageInfo info(PLUGINGUI_DIDOPEN);
626  return pluginCore->processMessage(info);
627  }
628 
630  virtual bool guiWillClose()
631  {
632  if(!pluginCore) return false;
633 
634  for (customViewControllerMap::const_iterator it = customViewMap.begin(), end = customViewMap.end(); it != end; ++it)
635  {
636  it->second->clearCustomViewPtr();
637  }
638  for (customViewControllerMap::const_iterator it = customSubControllerMap.begin(), end = customSubControllerMap.end(); it != end; ++it)
639  {
640  it->second->clearCustomViewPtr();
641  }
642 
643  MessageInfo info(PLUGINGUI_WILLCLOSE);
644  return pluginCore->processMessage(info);
645  }
646 
648  virtual bool guiTimerPing()
649  {
650  if(!pluginCore) return false;
651  MessageInfo info(PLUGINGUI_TIMERPING);
652  return pluginCore->processMessage(info);
653  }
654 
656  virtual bool checkNonBoundValueChange(int tag, float normalizedValue)
657  {
658  if(!pluginCore) return false;
659 
660  // --- do any additional stuff here
661  // --- dispatch non-bound value changes directly to receiver
662 
663  return false;
664  }
665 
666 protected:
667  PluginCore* pluginCore = nullptr;
669 
670  // --- this is for supporting the persistent interface pointer for the core object
671  // and is required by ASPiK Specifications
672  typedef std::map<std::string, CustomViewController*> customViewControllerMap;
673  customViewControllerMap customViewMap;
674 
677  {
678  for (customViewControllerMap::const_iterator it = customViewMap.begin(), end = customViewMap.end(); it != end; ++it)
679  {
680  if (it->second->getCustomViewPtr() == customViewConnector)
681  return it->second;
682  }
683 
684  return nullptr;
685  }
686 
688 
691  {
692  for (customViewControllerMap::const_iterator it = customSubControllerMap.begin(), end = customSubControllerMap.end(); it != end; ++it)
693  {
694  if (it->second->getCustomViewPtr() == customViewConnector)
695  return it->second;
696  }
697 
698  return nullptr;
699  }
700 
701 };
702 
719 {
720 public:
721  VSTMIDIEventQueue(PluginCore* _pluginCore)
722  {
723  pluginCore = _pluginCore;
724  };
725 
726  virtual ~VSTMIDIEventQueue(){}
727 
728 public:
730  void setEventList(IEventList* _inputEvents)
731  {
732  inputEvents = _inputEvents;
733  currentEventIndex = 0;
734  }
735 
737  virtual unsigned int getEventCount()
738  {
739  if (inputEvents)
740  return inputEvents->getEventCount();
741 
742  return 0;
743  }
744 
746  virtual bool fireMidiEvents(unsigned int sampleOffset)
747  {
748  if (!inputEvents)
749  return false;
750 
751  Event e = { 0 };
752  bool eventOccurred = false;
753  bool haveEvents = false;
754  if (inputEvents->getEvent(currentEventIndex, e) == kResultTrue)
755  haveEvents = true;
756  else
757  return false;
758 
759  const unsigned char MIDI_NOTE_OFF = 0x80;
760  const unsigned char MIDI_NOTE_ON = 0x90;
761  const unsigned char MIDI_POLY_PRESSURE = 0xA0;
762 
763  while (haveEvents)
764  {
765  if (inputEvents->getEvent(currentEventIndex, e) == kResultTrue)
766  {
767  if (e.sampleOffset != sampleOffset)
768  return false;
769 
770  // --- process Note On or Note Off messages
771  switch (e.type)
772  {
773  // --- NOTE ON
774  case Event::kNoteOnEvent:
775  {
776  midiEvent event;
777  event.midiMessage = (unsigned int)MIDI_NOTE_ON;
778  event.midiChannel = (unsigned int)e.noteOn.channel;
779  event.midiData1 = (unsigned int)e.noteOn.pitch;
780  event.midiData2 = (unsigned int)(127.0*e.noteOn.velocity);
781  event.midiSampleOffset = e.sampleOffset;
782  eventOccurred = true;
783 
784  // --- send to core for processing
785  if(pluginCore)
787  break;
788  }
789 
790  // --- NOTE OFF
791  case Event::kNoteOffEvent:
792  {
793  // --- get the channel/note/vel
794  midiEvent event;
795  event.midiMessage = (unsigned int)MIDI_NOTE_OFF;
796  event.midiChannel = (unsigned int)e.noteOff.channel;
797  event.midiData1 = (unsigned int)e.noteOff.pitch;
798  event.midiData2 = (unsigned int)(127.0*e.noteOff.velocity);
799  event.midiSampleOffset = e.sampleOffset;
800  eventOccurred = true;
801 
802  // --- send to core for processing
803  if(pluginCore)
805 
806  break;
807  }
808 
809  // --- polyphonic aftertouch 0xAn
810  case Event::kPolyPressureEvent:
811  {
812  midiEvent event;
813  event.midiMessage = (unsigned int)MIDI_POLY_PRESSURE;
814  event.midiChannel = (unsigned int)e.polyPressure.channel;
815  event.midiData1 = (unsigned int)e.polyPressure.pitch;
816  event.midiData2 = (unsigned int)(127.0*e.polyPressure.pressure);
817  event.midiSampleOffset = e.sampleOffset;
818  eventOccurred = true;
819 
820  // --- send to core for processing
821  if(pluginCore)
823 
824  break;
825  }
826  } // switch
827 
828  // --- have next event?
829  if (inputEvents->getEvent(currentEventIndex + 1, e) == kResultTrue)
830  {
831  if (e.sampleOffset == sampleOffset)
832  {
833  // --- avance current index
835  }
836  else
837  haveEvents = false;
838  }
839  else
840  haveEvents = false;
841  }
842  }
843 
844  return eventOccurred;
845  }
846 
847 protected:
848  PluginCore* pluginCore = nullptr;
849  IEventList* inputEvents = nullptr;
850  unsigned int currentEventIndex = 0;
851 };
852 
864 class VST3UpdateHandler: public FObject
865 {
866 public:
867  VST3UpdateHandler(CControlUpdateReceiver* _receiver, VST3Plugin* _editController){ receiver = _receiver; editController = _editController; }
868  ~VST3UpdateHandler(){}
869 
870  virtual void PLUGIN_API update (FUnknown* changedUnknown, int32 message)
871  {
872  if(message == IDependent::kChanged && receiver && editController)
873  {
874  double normalizedValue = editController->getParamNormalized (receiver->getControlID());
875  receiver->updateControlsWithNormalizedValue(normalizedValue);
876  }
877  }
878 
879 private:
880  CControlUpdateReceiver* receiver = nullptr;
881  VST3Plugin* editController = nullptr;
882 
883 };
884 
885 
897 class PluginEditor: public CPluginView, public PluginGUI, public IGUIWindowFrame
898 {
899 public:
900  PluginEditor(UTF8StringPtr _xmlFile, PluginCore* _pluginCore, GUIPluginConnector* _guiPluginConnector, PluginHostConnector* _pluginHostConnector, VST3Plugin* editController);
901  virtual ~PluginEditor();
902 
903  // --- aet of update handlers, specific to VST3: this will allow us to
904  // remotely update the GUI in a threadsafe and VST-approved manner
905  typedef std::map<int32_t, VST3UpdateHandler*> UpdaterHandlerMap;
906  UpdaterHandlerMap updateHandlers;
907 
908  //---from IPlugView------- VST3 Specific
909  IPlugFrame* plugFrame;
910  const ViewRect& getRect() const { return rect; }
911  void setRect(const ViewRect& r) { rect = r; }
912  bool isAttached() const { return systemWindow != 0; }
913  virtual void attachedToParent() override {}
914  virtual void removedFromParent() override {}
915 
916  virtual tresult PLUGIN_API attached(void* parent, FIDString type) override;
917  virtual tresult PLUGIN_API removed() override;
918  virtual tresult PLUGIN_API onWheel(float distance) override { return kResultFalse; }
919 
920  virtual tresult PLUGIN_API isPlatformTypeSupported(FIDString type) override;
921  virtual tresult PLUGIN_API onSize(ViewRect* newSize) override;
922  virtual tresult PLUGIN_API getSize(ViewRect* size) override;
923 
924  virtual tresult PLUGIN_API onFocus(TBool /*state*/) override { return kResultFalse; }
925  virtual tresult PLUGIN_API setFrame(IPlugFrame* frame) override;// { plugFrame = frame; return kResultTrue; }
926  virtual tresult PLUGIN_API canResize() override{ return kResultTrue; }
927  virtual tresult PLUGIN_API checkSizeConstraint(ViewRect* rect) override
928  {
929  if (showGUIEditor)
930  return kResultTrue;
931 
932  // --- clamp it
933  ViewRect viewRect = getRect();
934  rect->right = viewRect.right;
935  rect->bottom = viewRect.bottom;
936 
937  return kResultFalse;
938  }
939 
940  virtual bool setWindowFrameSize(double left = 0, double top = 0, double right = 0, double bottom = 0) override //CRect* newSize)
941  {
942  ViewRect vr(0, 0, right, bottom);
943  setRect(vr);
944  if (plugFrame)
945  plugFrame->resizeView(this, &vr);
946  return true;
947  }
948 
949  virtual bool getWindowFrameSize(double& left, double& top, double& right, double& bottom) override
950  {
951  ViewRect viewRect = getRect();
952  left = 0.0;
953  top = 0.0;
954  right = viewRect.getWidth();
955  bottom = viewRect.getHeight();
956  return true;
957  }
958 
959 protected:
960  PluginCore* pluginCore = nullptr;
964 };
965 
966 
967 
968 }}} // namespaces
969 
970 #endif
971 
972 
973 
974 
975 
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:590
Information that includes the message code as well as the message data.
Definition: pluginstructures.h:545
static const char * getPluginName()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1407
unsigned int sampleAccuracy
sample accurate parameter automation
Definition: vst3plugin.h:195
Attribute value smashed down into a union.
Definition: pluginstructures.h:666
bool doControlUpdate(ProcessData &data)
Find and issue Control Changes.
Definition: vst3plugin.cpp:634
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:366
virtual tresult setProgramName(ProgramListID listId, int32 programIndex, const String128 name) override
Set preset name.
Definition: vst3plugin.cpp:1261
ProgramList * getProgramList(ProgramListID listId) const
part of the IUnitInfo support for presets; generally no user editable code here.
Definition: vst3plugin.cpp:1154
void setEventList(IEventList *_inputEvents)
Definition: vst3plugin.h:730
tresult PLUGIN_API canProcessSampleSize(int32 symbolicSampleSize) override
Client queries us for our supported sample lengths.
Definition: vst3plugin.cpp:420
tresult notifyPogramListChange(ProgramListID listId, int32 programIndex=kAllProgramInvalid)
If list changes; should not be called as we only have one program list.
Definition: vst3plugin.cpp:1171
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:494
bool getValueAtOffset(long int _sampleOffset, double _previousValue, double &_nextValue)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1709
virtual tresult PLUGIN_API getProgramInfo(ProgramListID listId, int32 programIndex, CString attributeId, String128 attributeValue) override
Only used for presets.
Definition: vst3plugin.cpp:1283
virtual tresult PLUGIN_API getProgramPitchName(ProgramListID listId, int32 programIndex, int16 midiPitch, String128 name) override
Not Used.
Definition: vst3plugin.cpp:1327
Interface for VST3 parameter value update queue (sample accurate automation)
Definition: pluginstructures.h:1329
The GUIPluginConnector interface creates a safe message mechanism for the GUI to issue requests to th...
Definition: vst3plugin.h:476
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:1957
PluginEditor(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:1758
CustomViewController(ICustomView *_customViewIF)
Definition: vst3plugin.h:418
The VSTMIDIEventQueue interface queues incoming MIDI messages and blasts them out during the buffer p...
Definition: vst3plugin.h:718
virtual bool processMIDIEvent(midiEvent &event)
process a MIDI event
Definition: plugincore.cpp:395
uint32_t midiData1
BYTE data 1 as UINT.
Definition: pluginstructures.h:489
IPlugView *PLUGIN_API createView(const char *_name) override
creates the custom GUI view
Definition: vst3plugin.cpp:934
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:1007
interface file for ASPiK GUI object
void updateHostInfo(ProcessData &data, HostInfo *hostInfo)
update the incoming host data for the plugin core
Definition: vst3plugin.cpp:715
VST3Plugin * editController
parent VST3
Definition: vst3plugin.h:963
virtual bool guiTimerPing()
Definition: vst3plugin.h:648
uint32_t controlID
ID value.
Definition: pluginstructures.h:299
PluginCore * pluginCore
the core
Definition: vst3plugin.h:960
The VST3Plugin object is the ASPiK plugin shell for the VST3 API.
Definition: vst3plugin.h:73
virtual bool processMessage(MessageInfo &messageInfo)
For Custom View and Custom Sub-Controller Operations.
Definition: plugincore.cpp:335
tresult PLUGIN_API terminate() override
object destroyer
Definition: vst3plugin.cpp:317
virtual double getNormalizedPluginParameter(int32_t controlID)
Definition: vst3plugin.h:515
VST3Plugin * editController
our parent plugin
Definition: vst3plugin.h:396
GUIPluginConnector * guiPluginConnector
GUI Plugin interface.
Definition: vst3plugin.h:961
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:531
virtual ~PluginEditor()
ASPiK support VST3 GUI - this wraps the ASPiK GUI so that it conforms to the IPlugView interface...
Definition: vst3plugin.cpp:1779
uint32 m_uLatencyInSamples
set in constructor with plugin
Definition: vst3plugin.h:155
virtual uint32 PLUGIN_API getTailSamples() override
Returns the tail-time in samples.
Definition: vst3plugin.cpp:467
int needsUpdate(int x, ParamValue &value)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1648
const ICustomView * getCustomViewPtr()
Definition: vst3plugin.h:446
uint32_t midiMessage
BYTE message as UINT.
Definition: pluginstructures.h:487
virtual void updateView()
Definition: vst3plugin.h:422
unsigned int currentEventIndex
index of current event
Definition: vst3plugin.h:850
IEventList * inputEvents
the current event list for this buffer cycle
Definition: vst3plugin.h:849
virtual bool registerCustomView(std::string customViewName, ICustomView *customViewConnector)
Definition: vst3plugin.h:574
CustomViewController * getCustomSubController(ICustomView *customViewConnector)
Definition: vst3plugin.h:690
CustomViewController * getCustomViewController(ICustomView *customViewConnector)
Definition: vst3plugin.h:676
Information about a GUI update message; this is for sending GUI control information from the plugin c...
Definition: pluginstructures.h:368
PluginHostConnector * pluginHostConnector
Plugin Host interface.
Definition: vst3plugin.h:962
std::map< std::string, CustomViewController * > customViewControllerMap
map of custom view controllers
Definition: vst3plugin.h:672
Custom interface so that GUI can pass information to plugin shell in a thread-safe manner...
Definition: pluginstructures.h:1219
The CustomViewController is part of the safe ICustomView feature in ASPiK. The CustomViewController m...
Definition: vst3plugin.h:414
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:982
static const char * getVendorURL()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1439
GUIPluginConnector(PluginCore *_pluginCore, VST3Plugin *_editController)
Definition: vst3plugin.h:480
VSTParamUpdateQueue(void)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1492
virtual bool fireMidiEvents(unsigned int sampleOffset)
Definition: vst3plugin.h:746
virtual bool deRegisterCustomView(ICustomView *customViewConnector)
Definition: vst3plugin.h:602
virtual tresult PLUGIN_API getProgramListInfo(int32 listIndex, ProgramListInfo &info) override
Get information about our preset list.
Definition: vst3plugin.cpp:1209
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:1994
Custom View interface to allow plugin core to create safe communication channels with GUI custom view...
Definition: pluginstructures.h:1141
VST3Plugin()
object constructor: because of class factory, do NOT use this for init; use initialize() instead ...
Definition: vst3plugin.cpp:70
virtual bool guiWillClose()
Definition: vst3plugin.h:630
virtual void pushDataValue(double data)
Definition: vst3plugin.h:429
Definition: pluginstructures.h:397
virtual ~GUIPluginConnector()
Definition: vst3plugin.h:487
Double buffered queue for MIDI messages.
Definition: pluginstructures.h:1307
virtual bool guiParameterChanged(int32_t controlID, double actualValue)
has nothing to do with actual variable or updated variable (binding)
Definition: plugincore.cpp:306
virtual void parameterChanged(int32_t controlID, double actualValue, double normalizedValue)
Definition: vst3plugin.h:500
The GUIPluginConnector interface creates a safe message mechanism for the GUI to issue requests to th...
Definition: AAXPluginParameters.h:500
virtual int32 PLUGIN_API getProgramListCount() override
We have one list for our one set of presets.
Definition: vst3plugin.cpp:1191
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:897
VST3Plugin * editController
the VST3
Definition: vst3plugin.h:668
virtual uint32 PLUGIN_API getLatencySamples() override
Definition: vst3plugin.h:158
void initialize(ParamValue _initialValue, ParamValue _minValue, ParamValue _maxValue, unsigned int *_sampleAccuracy)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1518
virtual tresult PLUGIN_API getProgramName(ProgramListID listId, int32 programIndex, String128 name) override
Get preset name.
Definition: vst3plugin.cpp:1235
void setParamValueQueue(IParamValueQueue *_paramValueQueue, unsigned int _bufferSize)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1539
virtual bool setWindowFrameSize(double left=0, double top=0, double right=0, double bottom=0) override
Definition: vst3plugin.h:940
virtual bool deRregisterSubcontroller(ICustomView *customViewConnector)
Definition: vst3plugin.h:555
virtual void sendMessage(void *data)
Definition: vst3plugin.h:436
static FUID * getFUID()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1387
void * inMessageData
incoming message data (interpretation depends on message)
Definition: pluginstructures.h:559
tresult PLUGIN_API setParamNormalizedFromFile(ParamID tag, ParamValue value)
helper function for setComponentState()
Definition: vst3plugin.cpp:1053
PluginCore * pluginCore
the core object
Definition: vst3plugin.h:667
std::vector< GUIParameter > guiParameters
list of updates
Definition: pluginstructures.h:373
tresult PLUGIN_API setupProcessing(ProcessSetup &newSetup) override
we get information about sample rate, bit-depth, etc...
Definition: vst3plugin.cpp:441
static CString getPluginType()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1471
static const char * getVendorEmail()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1455
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:2016
tresult PLUGIN_API initialize(FUnknown *context) override
object initializer
Definition: vst3plugin.cpp:105
virtual unsigned int getEventCount()
Definition: vst3plugin.h:737
Definition: channelformats.h:32
The PluginHostConnector implements the IPluginHostConnector interface for the plugin shell object...
Definition: vst3plugin.h:355
void setCustomViewPtr(ICustomView *_customViewIF)
Definition: vst3plugin.h:443
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:886
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:1559
virtual bool getWindowFrameSize(double &left, double &top, double &right, double &bottom) override
Definition: vst3plugin.h:949
virtual void sendMessage(void *data)
Definition: pluginstructures.h:1162
void clearCustomViewPtr()
Definition: vst3plugin.h:449
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:1912
Information that defines a single GUI parameter&#39;s possible values and ID.
Definition: pluginstructures.h:291
virtual bool registerSubcontroller(std::string subcontrollerName, ICustomView *customViewConnector)
Definition: vst3plugin.h:527
~VST3Plugin()
object destructor: because of class factory, do NOT use this for destruction; use terminate() instead...
Definition: vst3plugin.cpp:86
bool addProgramList(ProgramList *list)
part of the IUnitInfo support for presets; generally no user editable code here.
Definition: vst3plugin.cpp:1134
tresult PLUGIN_API process(ProcessData &data) override
the VST3 audio processing function
Definition: vst3plugin.cpp:744
Custom interface to allow resizing of GUI window; this is mainly used for the GUI designer...
Definition: pluginstructures.h:1176
base class interface file for ASPiK plugincore object
double actualValue
actual value
Definition: pluginstructures.h:300
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:729
ParamValue interpolate(int x1, int x2, ParamValue y1, ParamValue y2, int x)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1627
customViewControllerMap customSubControllerMap
map of custom sub-controllers
Definition: vst3plugin.h:687
virtual bool checkNonBoundValueChange(int tag, float normalizedValue)
Definition: vst3plugin.h:656
virtual void updateView()=0
virtual tresult PLUGIN_API hasProgramPitchNames(ProgramListID listId, int32 programIndex) override
Not Used.
Definition: vst3plugin.cpp:1305
static FUnknown * createInstance(void *context)
Definition: vst3plugin.h:132
std::string inMessageString
incoming message data as a std::string (interpretation depends on message)
Definition: pluginstructures.h:562
Custom interface to send the plugin shell a message from plugin core.
Definition: pluginstructures.h:1289
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:1080
The PluginHostConnector implements the IPluginHostConnector interface for the plugin shell object...
Definition: AAXPluginParameters.h:380
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:1812
void updateMeters(ProcessData &data, bool forceOff=false)
update the outbound VST3 parameters that correspond to plugin meter variables
Definition: vst3plugin.cpp:847
VSTParamUpdateQueue ** m_pParamUpdateQueueArray
sample accurate parameter automation
Definition: vst3plugin.h:194
static const char * getVendorName()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1423
Little update handler object for VST-approved GUI updating.
Definition: vst3plugin.h:864
bool getNextValue(double &_nextValue)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1734
bool enableSAAVST3
sample accurate parameter automation
Definition: vst3plugin.h:196
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:1795
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:368
PluginCore * pluginCore
the core object
Definition: vst3plugin.h:848
The VSTParamUpdateQueue object maintains a parameter update queue for one ASPiK PluginParameter objec...
Definition: vst3plugin.h:297
virtual void PLUGIN_API update(FUnknown *changedUnknown, int32 message) override
Toggle preset.
Definition: vst3plugin.cpp:1348
virtual void pushDataValue(double data)
Definition: pluginstructures.h:1152
bool addUnit(Unit *unit)
IUnitInfo handler.
Definition: vst3plugin.cpp:1370
Information about a MIDI event.
Definition: pluginstructures.h:449
unsigned int getParameterIndex()
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1693
virtual bool guiDidOpen()
Definition: vst3plugin.h:622