digitalmars.D - How would I write a VST plugin in D?
- Christian Schüler <Christian_member pathlink.com> Apr 18 2005
- "Lynn Allan" <l_d_allan adelphia.net> Apr 19 2005
- Benji Smith <dlanguage xxagg.com> Apr 21 2005
- pragma <pragma_member pathlink.com> Apr 19 2005
Been recently thinking about writing a VST plugin in D. A VST plugin is a .dll for use with Cubase or other music software. It has a specially named C function as entry point: AEffect *main( audioMasterCallback audioMaster ); where AEffect is a struct, and audioMasterCallback is a typedef for a function. 1) How do I get these definitions into D? The VST SDK comes with an "aeffect.h" that defines these types and some enums. 2) How do I build a dll with D? 3) I need to compile a "main" function with different parameters than just (argc, argv). VisualC accepts an arbitrary "main" when compiling a .dll, but GCC does not. Therefore, a common workaround with GCC is to call the entry point something different, like "main_plugin", and change the export name with a .def file into "main". Can D do one of these (compile an arbitrary main function or handle a .def file)? 4) While the VST API is a C-API, in C++ you can derive from the AEffect struct to add member functions, which helps in organising (instead of having a bunch of static callback functions floating somewhere). Is this possible in D? 5) A "serious" plugin would need SSE code. I read DMD has it as inline assembler, but this means writing a complete loop in assembler. SSE-intrinsics (that is, specially named functions that compile to SSE-instructions) would be more of a convenience. Thanks, Christian
Apr 18 2005
Christian, This won't help you with D, sorry ... But I would appreciate hearing about your experience with VST plugin development. I've been working on a "skin/personality" to the open source Audacity audio editor that is specialized for speech rather than music. I would like to learn how to create several plug-ins for Audacity, and hadn't found any examples or tutorials on how to do that (didn't look that hard, however) "Christian Schüler" <Christian_member pathlink.com> wrote in message news:d41f9m$24c7$1 digitaldaemon.com...Been recently thinking about writing a VST plugin in D. A VST plugin is a .dll for use with Cubase or other music software. It has a specially named C function as entry point:
Apr 19 2005
Lynn Allan wrote:But I would appreciate hearing about your experience with VST plugin development
Yeah, me too. I've been interested in tinkering with some DSP algorithms (purely as a learning exercise), and I'd love to read about your experience writing VST plugins. --BenjiSmith
Apr 21 2005
In article <d41f9m$24c7$1 digitaldaemon.com>, Christian Schüler says...Been recently thinking about writing a VST plugin in D. A VST plugin is a .dll for use with Cubase or other music software. It has a specially named C function as entry point: AEffect *main( audioMasterCallback audioMaster ); where AEffect is a struct, and audioMasterCallback is a typedef for a function.
Personally I have no experience in writing plugins for VST, but I used to be an avid Cubase user. I still have a copy of version 5 floating around here someplace. :)1) How do I get these definitions into D? The VST SDK comes with an "aeffect.h" that defines these types and some enums.
You'll first want to convert the headers into D code "headers", that will perform the same task. The main D page should cover 99% of the things you'll need to do: http://www.digitalmars.com/d/ctod.html Just stay faithful to the byte layout of structs, and the intention of the preprocessor directives, and you'll do fine. If you're linking against a provided .obj or .lib file, make sure they're in OMF format. You'll know the second it can't link under dmd/optlink. (there is a conversion utility to cover this problem)2) How do I build a dll with D?
Again, it's all up on the webpage. http://www.digitalmars.com/d/dll.html The first section, "Dlls with a C interface" will apply to your use.3) I need to compile a "main" function with different parameters than just (argc, argv). VisualC accepts an arbitrary "main" when compiling a .dll, but GCC does not. Therefore, a common workaround with GCC is to call the entry point something different, like "main_plugin", and change the export name with a .def file into "main". Can D do one of these (compile an arbitrary main function or handle a .def file)?
DMD uses a .def file which supports an "exports" listing. The syntax supports what you're trying to do here. http://www.digitalmars.com/ctg/ctgDefFiles.html#exports4) While the VST API is a C-API, in C++ you can derive from the AEffect struct to add member functions, which helps in organising (instead of having a bunch of static callback functions floating somewhere). Is this possible in D?
I think you're stuck with structs, callbacks and function pointers. D does allow methods on structs, but they're non-virtual. Fortunately, D does have a good function pointer syntax, and placing these inside a struct should help you get the flexibility you crave.5) A "serious" plugin would need SSE code. I read DMD has it as inline assembler, but this means writing a complete loop in assembler. SSE-intrinsics (that is, specially named functions that compile to SSE-instructions) would be more of a convenience.
I believe that you are correct that D does not have SSE intrinsic support. You're also correct that the only available workaround in D is to use an asm{} block and code in things manually. At least D offers you the 'naked' keyword, which should help reduce overhead should you write functions to encapsulate common operations. Another workaround would be to use a C compiler that has the support you need, and roll a good SSE library that you could import into D. - EricAnderton at yahoo
Apr 19 2005









Benji Smith <dlanguage xxagg.com> 