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 
47 // static const ProgramListID kProgramListId = 1; ///< no programs are used in the unit.
48 
49 
50 
62 class VST3Plugin : public SingleComponentEffect, public IMidiMapping
63 {
64 public:
65  // --- constructor
66  VST3Plugin();
67 
68  // --- destructor
69  ~VST3Plugin();
70 
71  /*** IAudioProcessor Interface ***/
73  tresult PLUGIN_API initialize(FUnknown* context) override;
74 
76  tresult PLUGIN_API setBusArrangements(SpeakerArrangement* inputs, int32 numIns, SpeakerArrangement* outputs, int32 numOuts) override;
77 
79  tresult PLUGIN_API canProcessSampleSize(int32 symbolicSampleSize) override;
80 
82  tresult PLUGIN_API setupProcessing(ProcessSetup& newSetup) override;
83 
85  tresult PLUGIN_API setActive(TBool state) override;
86 
88  // These get/set the plugin variables
89  tresult PLUGIN_API setState(IBStream* fileStream) override;
90  tresult PLUGIN_API getState(IBStream* fileStream) override;
91 
93  // Update the GUI control variables
94  bool doControlUpdate(ProcessData& data);
95 
97  tresult PLUGIN_API process(ProcessData& data) override;
98 
100  virtual tresult PLUGIN_API getMidiControllerAssignment(int32 busIndex, int16 channel, CtrlNumber midiControllerNumber, ParamID& id/*out*/) override;
101 
103  IPlugView* PLUGIN_API createView(const char* _name) override;
104 
106  tresult PLUGIN_API terminate() override;
107 
109  virtual tresult receiveText(const char8* text) override;
110 
112  tresult PLUGIN_API setParamNormalizedFromFile(ParamID tag, ParamValue value);
113 
115  tresult PLUGIN_API setComponentState(IBStream* fileStream) override;
116 
118  void updateMeters(ProcessData& data, bool forceOff = false);
119 
121  static FUnknown* createInstance(void* context) {return (IAudioProcessor*)new VST3Plugin(); }
122 
124  //bool addUnit (Unit* unit);
125 
127  bool addProgramList (ProgramList* list);
128  ProgramList* getProgramList(ProgramListID listId) const;
129  tresult notifyPogramListChange(ProgramListID listId, int32 programIndex = kAllProgramInvalid);
130 
131  tresult PLUGIN_API setParamNormalized (ParamID tag, ParamValue value) override;
132  virtual int32 PLUGIN_API getProgramListCount() override;
133  virtual tresult PLUGIN_API getProgramListInfo(int32 listIndex, ProgramListInfo& info /*out*/) override;
134  virtual tresult PLUGIN_API getProgramName(ProgramListID listId, int32 programIndex, String128 name /*out*/) override;
135  virtual tresult PLUGIN_API getProgramInfo(ProgramListID listId, int32 programIndex, CString attributeId /*in*/, String128 attributeValue /*out*/) override;
136  virtual tresult PLUGIN_API hasProgramPitchNames(ProgramListID listId, int32 programIndex) override;
137  virtual tresult PLUGIN_API getProgramPitchName(ProgramListID listId, int32 programIndex, int16 midiPitch, String128 name /*out*/) override;
138  virtual tresult setProgramName(ProgramListID listId, int32 programIndex, const String128 name /*in*/) override;
139 
141  virtual void PLUGIN_API update(FUnknown* changedUnknown, int32 message) override ;
142 
143  // --- latency support
144  uint32 m_uLatencyInSamples = 0;
145 
147  virtual uint32 PLUGIN_API getLatencySamples() override {
148  return m_uLatencyInSamples; }
149 
151  virtual uint32 PLUGIN_API getTailSamples() override ;
152 
154  void updateHostInfo(ProcessData& data, HostInfo* hostInfo);
155 
156  static FUID* getFUID();
157  static const char* getPluginName();
158  static const char* getVendorName();
159  static const char* getVendorURL();
160  static const char* getVendorEmail();
161  static CString getPluginType();
162 
163  // --- define the IMidiMapping interface
164  OBJ_METHODS(VST3Plugin, SingleComponentEffect)
165  DEFINE_INTERFACES
166  DEF_INTERFACE(IMidiMapping)
167  DEF_INTERFACE(IUnitInfo)
168  END_DEFINE_INTERFACES(SingleComponentEffect)
169  REFCOUNT_METHODS(SingleComponentEffect)
170 
171 
172 private:
173  // --- our plugin core and interfaces
174  PluginCore* pluginCore = nullptr;
175  GUIPluginConnector* guiPluginConnector = nullptr;
176  PluginHostConnector* pluginHostConnector = nullptr;
177  VSTMIDIEventQueue* midiEventQueue = nullptr;
178  bool plugInSideBypass = false;
179  bool hasSidechain = false;
180 
181 protected:
182  // --- sample accurate parameter automation
184  unsigned int sampleAccuracy = 1;
185  bool enableSAAVST3 = false;
186 
187  // --- IUnitInfo and factory Preset support
188  typedef std::vector<IPtr<ProgramList> > ProgramListVector;
189  typedef std::map<ProgramListID, ProgramListVector::size_type> ProgramIndexMap;
190  typedef std::vector<IPtr<Unit> > UnitVector;
191  UnitVector units;
192  ProgramListVector programLists;
193  ProgramIndexMap programIndexMap;
194  UnitID selectedUnit;
195 
196 
197 #if defined _WINDOWS || defined _WINDLL
198 #ifdef ENABLE_WINDOWS_H
199  // --- getMyDLLDirectory()
200  // returns the directory where the .component resides
201  char* getMyDLLDirectory(UString cPluginName)
202  {
203  HMODULE hmodule = GetModuleHandle(cPluginName);
204 
205  TCHAR dir[MAX_PATH];
206  memset(&dir[0], 0, MAX_PATH*sizeof(TCHAR));
207  dir[MAX_PATH-1] = '\0';
208 
209  if(hmodule)
210  GetModuleFileName(hmodule, &dir[0], MAX_PATH);
211  else
212  return nullptr;
213 
214  // convert to UString
215  UString DLLPath(&dir[0], MAX_PATH);
216 
217  char* pFullPath = new char[MAX_PATH];
218  char* pDLLRoot = new char[MAX_PATH];
219 
220  DLLPath.toAscii(pFullPath, MAX_PATH);
221 
222  size_t nLenDir = strlen(pFullPath);
223  size_t nLenDLL = wcslen(cPluginName) + 1; // +1 is for trailing backslash
224  memcpy(pDLLRoot, pFullPath, nLenDir-nLenDLL);
225  pDLLRoot[nLenDir-nLenDLL] = '\0';
226 
227  delete [] pFullPath;
228 
229  // caller must delete this after use
230  return pDLLRoot;
231  }
232 #endif
233 #endif
234 #if MAC
235  // --- getMyComponentDirectory()
236  // returns the directory where the .component resides
237  char* getMyComponentDirectory(CFStringRef bundleID)
238  {
239  if (bundleID != nullptr)
240  {
241  CFBundleRef helixBundle = CFBundleGetBundleWithIdentifier( bundleID );
242  if(helixBundle != nullptr)
243  {
244  CFURLRef bundleURL = CFBundleCopyBundleURL ( helixBundle );
245  if(bundleURL != nullptr)
246  {
247  CFURLRef componentFolderPathURL = CFURLCreateCopyDeletingLastPathComponent(nullptr, bundleURL);
248 
249  CFStringRef myComponentPath = CFURLCopyFileSystemPath(componentFolderPathURL, kCFURLPOSIXPathStyle);
250  CFRelease(componentFolderPathURL);
251 
252  if(myComponentPath != nullptr)
253  {
254  int nSize = CFStringGetLength(myComponentPath);
255  char* path = new char[nSize+1];
256  memset(path, 0, (nSize+1)*sizeof(char));
257 
258  bool success = CFStringGetCString(myComponentPath, path, nSize+1, kCFStringEncodingASCII);
259  CFRelease(myComponentPath);
260 
261  if(success) return path;
262  else return nullptr;
263  }
264  CFRelease(bundleURL);
265  }
266  }
267  CFRelease(bundleID);
268  }
269  return nullptr;
270  }
271 #endif
272 
273 };
274 
289 {
290 protected:
291  unsigned int bufferSize = 0;
292  ParamValue initialValue = 0.0;
293  ParamValue previousValue = 0.0;
294  ParamValue maxValue = 0.0;
295  ParamValue minValue = 0.0;
296 
297  // --- Store slope and b so that it needs to be calculated only once.
298  ParamValue slope;
299  ParamValue yIntercept;
300 
301  // --- Controls granularity
302  unsigned int* sampleAccuracy = nullptr;
303  int queueIndex = 0;
304  int queueSize = 0;
305  IParamValueQueue* parameterQueue = nullptr;
306  int x1, x2 = 0;
307  double y1, y2 = 0;
308  bool dirtyBit = false;
309  int sampleOffset = 0;
310 
311 public:
312  VSTParamUpdateQueue(void);
313  virtual ~VSTParamUpdateQueue(void){}
314  void initialize(ParamValue _initialValue, ParamValue _minValue, ParamValue _maxValue, unsigned int* _sampleAccuracy);
315  void setParamValueQueue(IParamValueQueue* _paramValueQueue, unsigned int _bufferSize);
316  void setSlope();
317  ParamValue interpolate(int x1, int x2, ParamValue y1, ParamValue y2, int x);
318  int needsUpdate(int x, ParamValue &value);
319 
320  // --- IParameterUpdateQueue
321  unsigned int getParameterIndex();
322  bool getValueAtOffset(long int _sampleOffset, double _previousValue, double& _nextValue);
323  bool getNextValue(double& _nextValue);
324 };
325 
326 
327 
347 {
348 public:
349  PluginHostConnector(VST3Plugin* _editController) {editController = _editController;}
350  virtual ~PluginHostConnector(){}
351 
357  virtual void sendHostMessage(const HostMessageInfo& hostMessageInfo)
358  {
359  switch(hostMessageInfo.hostMessage)
360  {
361  case sendGUIUpdate:
362  {
363  GUIUpdateData guiUpdateData = hostMessageInfo.guiUpdateData;
364 
365  for(unsigned int i = 0; i < guiUpdateData.guiParameters.size(); i++)
366  {
367  GUIParameter guiParam = guiUpdateData.guiParameters[i];
368  if(editController)
369  {
370  ParamValue normalizedValue = editController->plainParamToNormalized(guiParam.controlID, guiParam.actualValue);
371  editController->setParamNormalized(guiParam.controlID, normalizedValue);
372  }
373  }
374 
375  // --- clean up
376  for (unsigned int i = 0; i < guiUpdateData.guiParameters.size(); i++)
377  guiUpdateData.guiParameters.pop_back();
378 
379  break;
380  }
381  default:
382  break;
383  }
384  }
385 
386 protected:
388 };
389 
390 // --- GUI -> Plugin interface
406 {
407 public:
409  CustomViewController(ICustomView* _customViewIF) { customViewIF = _customViewIF; }
410  virtual ~CustomViewController() {}
411 
413  virtual void updateView()
414  {
415  if (customViewIF)
416  customViewIF->updateView();
417  }
418 
420  virtual void pushDataValue(double data)
421  {
422  if (customViewIF)
423  customViewIF->pushDataValue(data);
424  }
425 
427  virtual void sendMessage(void* data)
428  {
429  if (customViewIF)
430  customViewIF->sendMessage(data);
431  }
432 
434  void setCustomViewPtr(ICustomView* _customViewIF) { customViewIF = _customViewIF; }
435 
437  const ICustomView* getCustomViewPtr() { return customViewIF; }
438 
440  void clearCustomViewPtr() { customViewIF = nullptr; }
441 
442 
443 private:
444  ICustomView* customViewIF = nullptr;
445 };
446 
468 {
469 public:
471  GUIPluginConnector(PluginCore* _pluginCore, VST3Plugin* _editController)
472  {
473  pluginCore = _pluginCore;
474  editController = _editController;
475  }
476 
479  {
480  for (customViewControllerMap::const_iterator it = customSubControllerMap.begin(), end = customSubControllerMap.end(); it != end; ++it)
481  {
482  delete it->second;
483  }
484  for (customViewControllerMap::const_iterator it = customViewMap.begin(), end = customViewMap.end(); it != end; ++it)
485  {
486  delete it->second;
487  }
488  }
489 
491  virtual void parameterChanged(int32_t controlID, double actualValue, double normalizedValue)
492  {
493  if(pluginCore)
494  pluginCore->guiParameterChanged(controlID, actualValue);
495 
496  if(!editController) return;
497 
498  // --- set parameter on object
499  editController->setParamNormalized(controlID, normalizedValue);
500 
501  // --- perform the operation
502  editController->performEdit(controlID, normalizedValue);
503  }
504 
506  virtual double getNormalizedPluginParameter(int32_t controlID)
507  {
508  if(!editController) return 0.0;
509 
510  Parameter* param = editController->getParameterObject(controlID);
511  if(!param) return 0.0;
512 
513  return param->getNormalized();
514  }
515 
517  virtual double getActualPluginParameter(int32_t controlID)
518  {
519  if (!editController) return 0.0;
520 
521  Parameter* param = editController->getParameterObject(controlID);
522  if (!param) return 0.0;
523 
524  // --- get normalized and convert
525  double normalizedValue = param->getNormalized();
526  return param->toPlain(normalizedValue);
527  }
528 
529 
531  virtual bool registerSubcontroller(std::string subcontrollerName, ICustomView* customViewConnector)
532  {
533  // --- do we have this in our map already?
534  CustomViewController* pCVC = nullptr;
535 
536  customViewControllerMap::const_iterator it = customSubControllerMap.find(subcontrollerName);
537  if (it != customSubControllerMap.end())
538  {
539  pCVC = it->second;
540  pCVC->setCustomViewPtr(customViewConnector);
541  }
542  else
543  {
544  pCVC = new CustomViewController(customViewConnector);
545  customSubControllerMap.insert(std::make_pair(subcontrollerName, pCVC));
546  }
547 
548  MessageInfo info(PLUGINGUI_REGISTER_SUBCONTROLLER);
549  info.inMessageString = subcontrollerName;
550  info.inMessageData = pCVC;
551 
552  if (pluginCore && pluginCore->processMessage(info))
553  return true;
554 
555  return false;
556  }
557 
559  virtual bool deRregisterSubcontroller(ICustomView* customViewConnector)
560  {
561  CustomViewController* pCVC = getCustomSubController(customViewConnector);
562  if (pCVC)
563  {
564  pCVC->clearCustomViewPtr();
565 
566  MessageInfo info(PLUGINGUI_DE_REGISTER_SUBCONTROLLER);
567  info.inMessageString = "";
568  info.inMessageData = pCVC;
569 
570  if (pluginCore && pluginCore->processMessage(info))
571  return true;
572  }
573 
574  return false;
575  }
576 
578  virtual bool registerCustomView(std::string customViewName, ICustomView* customViewConnector)
579  {
580  // --- do we have this in our map already?
581  CustomViewController* pCVC = nullptr;
582 
583  customViewControllerMap::const_iterator it = customViewMap.find(customViewName);
584  if (it != customViewMap.end())
585  {
586  pCVC = it->second;
587  pCVC->setCustomViewPtr(customViewConnector);
588  }
589  else
590  {
591  pCVC = new CustomViewController(customViewConnector);
592  customViewMap.insert(std::make_pair(customViewName, pCVC));
593  }
594 
595  MessageInfo info(PLUGINGUI_REGISTER_CUSTOMVIEW);
596  info.inMessageString = customViewName;
597  info.inMessageData = pCVC;
598 
599  if(pluginCore && pluginCore->processMessage(info))
600  return true;
601 
602  return false;
603  }
604 
606  virtual bool deRegisterCustomView(ICustomView* customViewConnector)
607  {
608  CustomViewController* pCVC = getCustomViewController(customViewConnector);
609  if (pCVC)
610  {
611  // --- clear it
612  pCVC->clearCustomViewPtr();
613 
614  MessageInfo info(PLUGINGUI_DE_REGISTER_CUSTOMVIEW);
615  info.inMessageString = "";
616  info.inMessageData = pCVC;
617 
618  if (pluginCore && pluginCore->processMessage(info))
619  return true;
620  }
621 
622  return false;
623  }
624 
626  virtual bool guiDidOpen()
627  {
628  if(!pluginCore) return false;
629  MessageInfo info(PLUGINGUI_DIDOPEN);
630  return pluginCore->processMessage(info);
631  }
632 
634  virtual bool guiWillClose()
635  {
636  if(!pluginCore) return false;
637 
638  for (customViewControllerMap::const_iterator it = customViewMap.begin(), end = customViewMap.end(); it != end; ++it)
639  {
640  it->second->clearCustomViewPtr();
641  }
642  for (customViewControllerMap::const_iterator it = customSubControllerMap.begin(), end = customSubControllerMap.end(); it != end; ++it)
643  {
644  it->second->clearCustomViewPtr();
645  }
646 
647  MessageInfo info(PLUGINGUI_WILLCLOSE);
648  return pluginCore->processMessage(info);
649  }
650 
652  virtual bool guiTimerPing()
653  {
654  if(!pluginCore) return false;
655  MessageInfo info(PLUGINGUI_TIMERPING);
656  return pluginCore->processMessage(info);
657  }
658 
660  virtual bool checkNonBoundValueChange(int tag, float normalizedValue)
661  {
662  if(!pluginCore) return false;
663 
664  // --- do any additional stuff here
665  // --- dispatch non-bound value changes directly to receiver
666 
667  return false;
668  }
669 
670 protected:
671  PluginCore* pluginCore = nullptr;
673 
674  // --- this is for supporting the persistent interface pointer for the core object
675  // and is required by ASPiK Specifications
676  typedef std::map<std::string, CustomViewController*> customViewControllerMap;
677  customViewControllerMap customViewMap;
678 
681  {
682  for (customViewControllerMap::const_iterator it = customViewMap.begin(), end = customViewMap.end(); it != end; ++it)
683  {
684  if (it->second->getCustomViewPtr() == customViewConnector)
685  return it->second;
686  }
687 
688  return nullptr;
689  }
690 
692 
695  {
696  for (customViewControllerMap::const_iterator it = customSubControllerMap.begin(), end = customSubControllerMap.end(); it != end; ++it)
697  {
698  if (it->second->getCustomViewPtr() == customViewConnector)
699  return it->second;
700  }
701 
702  return nullptr;
703  }
704 
705 };
706 
723 {
724 public:
725  VSTMIDIEventQueue(PluginCore* _pluginCore)
726  {
727  pluginCore = _pluginCore;
728  };
729 
730  virtual ~VSTMIDIEventQueue(){}
731 
732 public:
734  void setEventList(IEventList* _inputEvents)
735  {
736  inputEvents = _inputEvents;
737  currentEventIndex = 0;
738  }
739 
741  virtual unsigned int getEventCount()
742  {
743  if (inputEvents)
744  return inputEvents->getEventCount();
745 
746  return 0;
747  }
748 
750  virtual bool fireMidiEvents(unsigned int sampleOffset)
751  {
752  if (!inputEvents)
753  return false;
754 
755  Event e = { 0 };
756  bool eventOccurred = false;
757  bool haveEvents = false;
758  if (inputEvents->getEvent(currentEventIndex, e) == kResultTrue)
759  haveEvents = true;
760  else
761  return false;
762 
763  const unsigned char MIDI_NOTE_OFF = 0x80;
764  const unsigned char MIDI_NOTE_ON = 0x90;
765  const unsigned char MIDI_POLY_PRESSURE = 0xA0;
766 
767  while (haveEvents)
768  {
769  if (inputEvents->getEvent(currentEventIndex, e) == kResultTrue)
770  {
771  if (e.sampleOffset != sampleOffset)
772  return false;
773 
774  // --- process Note On or Note Off messages
775  switch (e.type)
776  {
777  // --- NOTE ON
778  case Event::kNoteOnEvent:
779  {
780  midiEvent event;
781  event.midiMessage = (unsigned int)MIDI_NOTE_ON;
782  event.midiChannel = (unsigned int)e.noteOn.channel;
783  event.midiData1 = (unsigned int)e.noteOn.pitch;
784  event.midiData2 = (unsigned int)(127.0*e.noteOn.velocity);
785  event.midiSampleOffset = e.sampleOffset;
786  eventOccurred = true;
787 
788  // --- send to core for processing
789  if(pluginCore)
791  break;
792  }
793 
794  // --- NOTE OFF
795  case Event::kNoteOffEvent:
796  {
797  // --- get the channel/note/vel
798  midiEvent event;
799  event.midiMessage = (unsigned int)MIDI_NOTE_OFF;
800  event.midiChannel = (unsigned int)e.noteOff.channel;
801  event.midiData1 = (unsigned int)e.noteOff.pitch;
802  event.midiData2 = (unsigned int)(127.0*e.noteOff.velocity);
803  event.midiSampleOffset = e.sampleOffset;
804  eventOccurred = true;
805 
806  // --- send to core for processing
807  if(pluginCore)
809 
810  break;
811  }
812 
813  // --- polyphonic aftertouch 0xAn
814  case Event::kPolyPressureEvent:
815  {
816  midiEvent event;
817  event.midiMessage = (unsigned int)MIDI_POLY_PRESSURE;
818  event.midiChannel = (unsigned int)e.polyPressure.channel;
819  event.midiData1 = (unsigned int)e.polyPressure.pitch;
820  event.midiData2 = (unsigned int)(127.0*e.polyPressure.pressure);
821  event.midiSampleOffset = e.sampleOffset;
822  eventOccurred = true;
823 
824  // --- send to core for processing
825  if(pluginCore)
827 
828  break;
829  }
830  } // switch
831 
832  // --- have next event?
833  if (inputEvents->getEvent(currentEventIndex + 1, e) == kResultTrue)
834  {
835  if (e.sampleOffset == sampleOffset)
836  {
837  // --- avance current index
839  }
840  else
841  haveEvents = false;
842  }
843  else
844  haveEvents = false;
845  }
846  }
847 
848  return eventOccurred;
849  }
850 
851 protected:
852  PluginCore* pluginCore = nullptr;
853  IEventList* inputEvents = nullptr;
854  unsigned int currentEventIndex = 0;
855 };
856 
868 class VST3UpdateHandler: public FObject
869 {
870 public:
871  VST3UpdateHandler(VSTGUI::ControlUpdateReceiver* _receiver, VST3Plugin* _editController){ receiver = _receiver; editController = _editController; }
872  ~VST3UpdateHandler(){}
873 
874  virtual void PLUGIN_API update (FUnknown* changedUnknown, int32 message)
875  {
876  if(message == IDependent::kChanged && receiver && editController)
877  {
878  double normalizedValue = editController->getParamNormalized (receiver->getControlID());
879  receiver->updateControlsWithNormalizedValue(normalizedValue);
880  }
881  }
882 
883 private:
884  VSTGUI::ControlUpdateReceiver* receiver = nullptr;
885  VST3Plugin* editController = nullptr;
886 
887 };
888 
889 
901 class PluginEditor: public CPluginView, public VSTGUI::PluginGUI, public IGUIWindowFrame
902 {
903 public:
904  PluginEditor(VSTGUI::UTF8StringPtr _xmlFile, PluginCore* _pluginCore, GUIPluginConnector* _guiPluginConnector, PluginHostConnector* _pluginHostConnector, VST3Plugin* editController);
905  virtual ~PluginEditor();
906 
907  // --- aet of update handlers, specific to VST3: this will allow us to
908  // remotely update the GUI in a threadsafe and VST-approved manner
909  typedef std::map<int32_t, VST3UpdateHandler*> UpdaterHandlerMap;
910  UpdaterHandlerMap updateHandlers;
911 
912  //---from IPlugView------- VST3 Specific
913  IPlugFrame* plugFrame;
914  const ViewRect& getRect() const { return rect; }
915  void setRect(const ViewRect& r) { rect = r; }
916  bool isAttached() const { return systemWindow != 0; }
917  virtual void attachedToParent() override {}
918  virtual void removedFromParent() override {}
919 
920  virtual tresult PLUGIN_API attached(void* parent, FIDString type) override;
921  virtual tresult PLUGIN_API removed() override;
922  virtual tresult PLUGIN_API onWheel(float distance) override { return kResultFalse; }
923 
924  virtual tresult PLUGIN_API isPlatformTypeSupported(FIDString type) override;
925  virtual tresult PLUGIN_API onSize(ViewRect* newSize) override;
926  virtual tresult PLUGIN_API getSize(ViewRect* size) override;
927 
928  virtual tresult PLUGIN_API onFocus(TBool /*state*/) override { return kResultFalse; }
929  virtual tresult PLUGIN_API setFrame(IPlugFrame* frame) override;// { plugFrame = frame; return kResultTrue; }
930  virtual tresult PLUGIN_API canResize() override{ return kResultFalse /*kResultTrue*/; }
931  virtual tresult PLUGIN_API checkSizeConstraint(ViewRect* rect) override
932  {
933  if (showGUIEditor)
934  return kResultTrue;
935 
936  // --- clamp it
937  ViewRect viewRect = getRect();
938  rect->right = viewRect.right;
939  rect->bottom = viewRect.bottom;
940 
941  return kResultFalse;
942  }
943 
944  virtual bool setWindowFrameSize(double left = 0, double top = 0, double right = 0, double bottom = 0) override //CRect* newSize)
945  {
946  ViewRect vr(0, 0, right, bottom);
947  setRect(vr);
948  if (plugFrame)
949  plugFrame->resizeView(this, &vr);
950  return true;
951  }
952 
953  virtual bool getWindowFrameSize(double& left, double& top, double& right, double& bottom) override
954  {
955  ViewRect viewRect = getRect();
956  left = 0.0;
957  top = 0.0;
958  right = viewRect.getWidth();
959  bottom = viewRect.getHeight();
960  return true;
961  }
962 
963 protected:
964  PluginCore* pluginCore = nullptr;
968 };
969 
970 
971 
972 }}} // namespaces
973 
974 #endif
975 
976 
977 
978 
979 
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:641
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:1471
unsigned int sampleAccuracy
sample accurate parameter automation
Definition: vst3plugin.h:184
Attribute value smashed down into a union.
Definition: pluginstructures.h:900
bool doControlUpdate(ProcessData &data)
Find and issue Control Changes.
Definition: vst3plugin.cpp:685
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:357
virtual tresult setProgramName(ProgramListID listId, int32 programIndex, const String128 name) override
Set preset name.
Definition: vst3plugin.cpp:1325
ProgramList * getProgramList(ProgramListID listId) const
part of the IUnitInfo support for presets; generally no user editable code here.
Definition: vst3plugin.cpp:1218
void setEventList(IEventList *_inputEvents)
Definition: vst3plugin.h:734
tresult PLUGIN_API canProcessSampleSize(int32 symbolicSampleSize) override
Client queries us for our supported sample lengths.
Definition: vst3plugin.cpp:468
tresult notifyPogramListChange(ProgramListID listId, int32 programIndex=kAllProgramInvalid)
If list changes; should not be called as we only have one program list.
Definition: vst3plugin.cpp:1235
The PluginGUI object that maintains the entire GUI operation and has #defines to use with AAX...
Definition: plugingui.h:412
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:542
bool getValueAtOffset(long int _sampleOffset, double _previousValue, double &_nextValue)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1773
virtual tresult PLUGIN_API getProgramInfo(ProgramListID listId, int32 programIndex, CString attributeId, String128 attributeValue) override
Only used for presets.
Definition: vst3plugin.cpp:1347
virtual tresult PLUGIN_API getProgramPitchName(ProgramListID listId, int32 programIndex, int16 midiPitch, String128 name) override
Not Used.
Definition: vst3plugin.cpp:1391
Interface for VST3 parameter value update queue (sample accurate automation)
Definition: pluginstructures.h:1584
std::vector< GUIParameter > guiParameters
list of updates
Definition: pluginstructures.h:461
The GUIPluginConnector interface creates a safe message mechanism for the GUI to issue requests to th...
Definition: vst3plugin.h:467
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:2021
CustomViewController(ICustomView *_customViewIF)
Definition: vst3plugin.h:409
VST3Plugin * editController
the VST3
Definition: vst3plugin.h:672
The VSTMIDIEventQueue interface queues incoming MIDI messages and blasts them out during the buffer p...
Definition: vst3plugin.h:722
GUIPluginConnector * guiPluginConnector
GUI Plugin interface.
Definition: vst3plugin.h:965
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:387
IPlugView *PLUGIN_API createView(const char *_name) override
creates the custom GUI view
Definition: vst3plugin.cpp:996
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:1069
void updateHostInfo(ProcessData &data, HostInfo *hostInfo)
update the incoming host data for the plugin core
Definition: vst3plugin.cpp:764
virtual bool guiTimerPing()
Definition: vst3plugin.h:652
uint32_t controlID
ID value.
Definition: pluginstructures.h:352
The VST3Plugin object is the ASPiK plugin shell for the VST3 API.
Definition: vst3plugin.h:62
bool showGUIEditor
show the GUI designer
Definition: plugingui.h:509
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:349
virtual double getNormalizedPluginParameter(int32_t controlID)
Definition: vst3plugin.h:506
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:579
void updateControlsWithNormalizedValue(float normalizedValue, CControl *control=nullptr)
Definition: plugingui.h:200
virtual ~PluginEditor()
ASPiK support VST3 GUI - this wraps the ASPiK GUI so that it conforms to the IPlugView interface...
Definition: vst3plugin.cpp:1843
uint32 m_uLatencyInSamples
set in constructor with plugin
Definition: vst3plugin.h:144
virtual uint32 PLUGIN_API getTailSamples() override
Returns the tail-time in samples.
Definition: vst3plugin.cpp:515
int needsUpdate(int x, ParamValue &value)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1712
const ICustomView * getCustomViewPtr()
Definition: vst3plugin.h:437
uint32_t midiMessage
BYTE message as UINT.
Definition: pluginstructures.h:641
virtual void updateView()
Definition: vst3plugin.h:413
unsigned int currentEventIndex
index of current event
Definition: vst3plugin.h:854
virtual bool registerCustomView(std::string customViewName, ICustomView *customViewConnector)
Definition: vst3plugin.h:578
VSTParamUpdateQueue ** m_pParamUpdateQueueArray
sample accurate parameter automation
Definition: vst3plugin.h:183
CustomViewController * getCustomSubController(ICustomView *customViewConnector)
Definition: vst3plugin.h:694
CustomViewController * getCustomViewController(ICustomView *customViewConnector)
Definition: vst3plugin.h:680
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:676
Custom interface so that GUI can pass information to plugin shell in a thread-safe manner...
Definition: pluginstructures.h:1474
The CustomViewController is part of the safe ICustomView feature in ASPiK. The CustomViewController m...
Definition: vst3plugin.h:405
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:1044
static const char * getVendorURL()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1503
GUIPluginConnector(PluginCore *_pluginCore, VST3Plugin *_editController)
Definition: vst3plugin.h:471
VSTParamUpdateQueue(void)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1556
virtual bool fireMidiEvents(unsigned int sampleOffset)
Definition: vst3plugin.h:750
virtual bool deRegisterCustomView(ICustomView *customViewConnector)
Definition: vst3plugin.h:606
virtual tresult PLUGIN_API getProgramListInfo(int32 listIndex, ProgramListInfo &info) override
Get information about our preset list.
Definition: vst3plugin.cpp:1273
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:2058
Custom View interface to allow plugin core to create safe communication channels with GUI custom view...
Definition: pluginstructures.h:1396
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:634
virtual void pushDataValue(double data)
Definition: vst3plugin.h:420
Definition: pluginstructures.h:485
virtual ~GUIPluginConnector()
Definition: vst3plugin.h:478
Double buffered queue for MIDI messages.
Definition: pluginstructures.h:1562
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:853
virtual void parameterChanged(int32_t controlID, double actualValue, double normalizedValue)
Definition: vst3plugin.h:491
The GUIPluginConnector interface creates a safe message mechanism for the GUI to issue requests to th...
Definition: AAXPluginParameters.h:599
virtual int32 PLUGIN_API getProgramListCount() override
We have one list for our one set of presets.
Definition: vst3plugin.cpp:1255
virtual double getActualPluginParameter(int32_t controlID)
Definition: vst3plugin.h:517
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:901
virtual uint32 PLUGIN_API getLatencySamples() override
Definition: vst3plugin.h:147
void initialize(ParamValue _initialValue, ParamValue _minValue, ParamValue _maxValue, unsigned int *_sampleAccuracy)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1582
virtual tresult PLUGIN_API getProgramName(ProgramListID listId, int32 programIndex, String128 name) override
Get preset name.
Definition: vst3plugin.cpp:1299
void setParamValueQueue(IParamValueQueue *_paramValueQueue, unsigned int _bufferSize)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1603
virtual bool setWindowFrameSize(double left=0, double top=0, double right=0, double bottom=0) override
Definition: vst3plugin.h:944
virtual bool deRregisterSubcontroller(ICustomView *customViewConnector)
Definition: vst3plugin.h:559
virtual void sendMessage(void *data)
Definition: vst3plugin.h:427
static FUID * getFUID()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1451
The ControlUpdateReceiver object is the connection mechanism between PluginParameter objects and thei...
Definition: plugingui.h:85
PluginCore * pluginCore
the core object
Definition: vst3plugin.h:852
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:1115
tresult PLUGIN_API setupProcessing(ProcessSetup &newSetup) override
we get information about sample rate, bit-depth, etc...
Definition: vst3plugin.cpp:489
static CString getPluginType()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1535
static const char * getVendorEmail()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1519
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:1822
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:2080
tresult PLUGIN_API initialize(FUnknown *context) override
object initializer
Definition: vst3plugin.cpp:82
virtual unsigned int getEventCount()
Definition: vst3plugin.h:741
Definition: channelformats.h:32
The PluginHostConnector implements the IPluginHostConnector interface for the plugin shell object...
Definition: vst3plugin.h:346
void setCustomViewPtr(ICustomView *_customViewIF)
Definition: vst3plugin.h:434
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:949
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:1623
virtual bool getWindowFrameSize(double &left, double &top, double &right, double &bottom) override
Definition: vst3plugin.h:953
virtual void sendMessage(void *data)
Definition: pluginstructures.h:1417
void clearCustomViewPtr()
Definition: vst3plugin.h:440
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:1976
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:531
~VST3Plugin()
object destructor: because of class factory, do NOT use this for destruction; use terminate() instead...
Definition: vst3plugin.cpp:63
bool addProgramList(ProgramList *list)
part of the IUnitInfo support for presets; generally no user editable code here.
Definition: vst3plugin.cpp:1197
tresult PLUGIN_API process(ProcessData &data) override
the VST3 audio processing function
Definition: vst3plugin.cpp:793
PluginCore * pluginCore
the core
Definition: vst3plugin.h:964
PluginCore * pluginCore
the core object
Definition: vst3plugin.h:671
Custom interface to allow resizing of GUI window; this is mainly used for the GUI designer...
Definition: pluginstructures.h:1431
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:1691
virtual bool checkNonBoundValueChange(int tag, float normalizedValue)
Definition: vst3plugin.h:660
virtual void updateView()=0
virtual tresult PLUGIN_API hasProgramPitchNames(ProgramListID listId, int32 programIndex) override
Not Used.
Definition: vst3plugin.cpp:1369
PluginHostConnector * pluginHostConnector
Plugin Host interface.
Definition: vst3plugin.h:966
static FUnknown * createInstance(void *context)
Definition: vst3plugin.h:121
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:1544
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:1142
The PluginHostConnector implements the IPluginHostConnector interface for the plugin shell object...
Definition: AAXPluginParameters.h:479
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:1876
void updateMeters(ProcessData &data, bool forceOff=false)
update the outbound VST3 parameters that correspond to plugin meter variables
Definition: vst3plugin.cpp:910
static const char * getVendorName()
static function for VST3 clsss factory
Definition: vst3plugin.cpp:1487
Little update handler object for VST-approved GUI updating.
Definition: vst3plugin.h:868
bool getNextValue(double &_nextValue)
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1798
bool enableSAAVST3
sample accurate parameter automation
Definition: vst3plugin.h:185
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:1859
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:400
customViewControllerMap customSubControllerMap
map of custom sub-controllers
Definition: vst3plugin.h:691
The VSTParamUpdateQueue object maintains a parameter update queue for one ASPiK PluginParameter objec...
Definition: vst3plugin.h:288
virtual void PLUGIN_API update(FUnknown *changedUnknown, int32 message) override
Toggle preset.
Definition: vst3plugin.cpp:1412
int32_t getControlID()
Definition: plugingui.h:299
virtual void pushDataValue(double data)
Definition: pluginstructures.h:1407
Information about a MIDI event.
Definition: pluginstructures.h:561
unsigned int getParameterIndex()
ASPiK support for sample accurate auatomation.
Definition: vst3plugin.cpp:1757
VST3Plugin * editController
parent VST3
Definition: vst3plugin.h:967
virtual bool guiDidOpen()
Definition: vst3plugin.h:626