Recent

Author Topic: Interfaces/Polymorphism  (Read 2859 times)

simone

  • Sr. Member
  • ****
  • Posts: 358
Re: Interfaces/Polymorphism
« Reply #30 on: December 27, 2019, 10:40:15 am »
You can try using the composition instead of inheritance. Or try using some design patterns. In the absence of more specific information, I cannot give you more concrete suggestions.
Microsoft Windows 10 64 bit - Lazarus 2.0.10

syntonica

  • Full Member
  • ***
  • Posts: 120
Re: Interfaces/Polymorphism
« Reply #31 on: December 27, 2019, 11:10:02 am »
You can try using the composition instead of inheritance. Or try using some design patterns. In the absence of more specific information, I cannot give you more concrete suggestions.
Thanks! That's okay. It would take more than one reply to try to explain how the VST framework works. It's not pretty, even on a good day. At its core, it's plain C with structs, but with a C++ overlay that adds a number of function pointers and opcodes and that all communicates back and forth with a host. I'm still sorting it all out...

I've noticed that I'm running into issues with automatic coercion, so that's my next project. For Ints vs Singles, it's far, far better than the C++ experience in that it works as expected. My C-code is littered with casts that should be unnecessary.  However, with pointers... ugh... That might be where my issue lies. Maybe. I'm still trying to figure out how one LFO is modulating TWO parameters...  %)

syntonica

  • Full Member
  • ***
  • Posts: 120
Re: Interfaces/Polymorphism
« Reply #32 on: December 28, 2019, 02:20:00 am »
I'm still trying to figure out how one LFO is modulating TWO parameters...
Duplicating a bug in the original code (missing break statement) takes talent!  :D

Looking at all the weird issues I've been seeing with junk values and missing members all seem to be pointing to one thing. Somehow, my plugin instance or managed members are being refcounted to zero and disposed of.  It would explain why a pointer is fine one line but completely invalid with a different value 10 lines later. The only thing I can do is create an instance of my plugin class and hand it off to the host.

Is there a way to turn refcounting off?  I already manage my memory in both C++ and Obj-C and 95% of what I create needs to be persistent for the lifetime of the plugin and is already set to be released in the destructor methods.

syntonica

  • Full Member
  • ***
  • Posts: 120
Re: Interfaces/Polymorphism
« Reply #33 on: December 28, 2019, 02:27:36 am »
This is the code that is exposed to the host to instantiate a plugin (error checking removed for clarity):
Code: Pascal  [Select][+][-]
  1. function VSTPluginMain(audioMaster: TAudioMasterCallbackFunc): PAEffect; cdecl; export;
  2.   begin
  3.     {error check}
  4.     eff := MyEffect.Create(audioMaster);
  5.     {error check}
  6.     Result := eff.Effect;
  7.   end;
  8.  
PAEffect is a pointer to a record containing a reference to the created plugin.

 

TinyPortal © 2005-2018