reading the other posts around (they are few and far between, I get the feeling that cdecl isn't used much...), it seems that this is a known issue, and one that the FPC devs haven't been eager to resolve, alas.
DSP
Quote from: "duncanparsons"
reading the other posts around (they are few and far between, I get the feeling that cdecl isn't used much...), it seems that this is a known issue, and one that the FPC devs haven't been eager to resolve, alas.
DSP
What is the number of the fpc bug report describing this problem? I don't know if it has a simple test case, but if not, maybe you can create it.
library mydll;
{$mode objfpc}{$H+}
uses
Classes,
SysUtils,
Windows;
procedure DllMessage; export;
begin
MessageBox(0,PChar('Hello world from a Lazarus DLL'),PChar('Lazarus'),mb_ok)
end;
exports DllMessage;
begin
end.
library mydll;
{$mode objfpc}{$H+}
uses
Classes,
SysUtils,
Dialogs;
procedure DllMessage; export;
begin
ShowMessage('Hello world from a Lazarus DLL');
end;
exports DllMessage;
begin
end.
Dialogs is LCL. LCL needs to be initialized by using the interfaces unit and calling Application.Initialize.
I don't know if using the LCL in libraries will work, even if you intialized it properly.
library mydll;
{$mode objfpc}{$H+}
uses
Interfaces,
Classes,
SysUtils,
Dialogs;
procedure DllMessage; export;
begin
ShowMessage('Hello world from a Lazarus DLL');
end;
exports DllMessage;
begin
end.
Can you suggest a work around?
You did not add Application.Initialize
Where should I put it?
I tried between begin and end, but it causes an error. "identifier not found".
P.S. Not using LCL is probably not acceptable in a VST plugin application.
VST and Delphi go very well together.
LCL is probably not acceptable in a VST plugin application.
Quote from: "paul_H"LCL is probably not acceptable in a VST plugin application.
But the Delphi VCL is ?!?!?!?!
-Michael
Quote from: "duncanparsons"VST and Delphi go very well together.
GREAT !
Were you actually able to create a VST plugin in Dephi that has a GUI and that sends and receives MIDI and and audio data ?
-Michael
P.S. Not using LCL is probably not acceptable in a VST plugin application.
With Delphi, not only does the library application run perfectly, but if you pass the main executable's window handle to the DLL and assign it to the DLL's Application.Handle, the DLL form becomes essentially part of the main program's GUI.
Are there other libraries that could be used - gtk, etc? Would that be an option?
AFAIK LCL (like the VCL) binds into an file and shouldn't have any other dependencies (VCL packages excluded here). Does gtk have that kind of dependency?
I believe the issue here is that the LCL just doesn't work in a library. I haven't tested this on OS X or Linux, but it definitely doesn't work with Windows. The library application "runs", but the GUI is completely unresponsive.
With Delphi, not only does the library application run perfectly, but if you pass the main executable's window handle to the DLL and assign it to the DLL's Application.Handle, the DLL form becomes essentially part of the main program's GUI.
Too bad the LCL doesn't support this powerful feature. Should this be posted as a bug?
Does anyone have any experience using LCL in libraries on OS X or Linux?
Any news here? What is the latest information about using LCL in a DLL? Has it been posted as a bug? How about OSX?
Any news here? What is the latest information about using LCL in a DLL? Has it been posted as a bug? How about OSX?
See this bug report for sample code illustrating the problems using an LCL form in a DLL:
http://www.freepascal.org/mantis/view.php?id=7181
The _only_ case I could find where using an LCL form in a DLL works as expected is as follows:
- Windows only (GTK on OS X just crashes with access violation).
- Call DLL only from console app.
- Compile library with stack checking off (apparent FPC bug).
Sorry I don't have better news.
See this bug report for sample code illustrating the problems using an LCL form in a DLL:
http://www.freepascal.org/mantis/view.php?id=7181
You are looking too deep... It is just a matter of alignment which should be 16 in both application and vst.Quote from: PhilSee this bug report for sample code illustrating the problems using an LCL form in a DLL:I tried to fix the bug by myself an and soon got a clue about what might went wrong here. I need to make some changes to the customforms.inc to be sure, but unfortunately no change will compile. What do I need to include? To compile this file together with the test program.
http://www.freepascal.org/mantis/view.php?id=7181
I already tried to add the whole LCL directory to the compile path, but I got lots of errors, so there must be another way.
Christian
There is a simple repaint problem that can be solved by, Ahum, Application.ProcessMessages. And make sure the correct handle is in place (The client handle, not the VST),I am still not this far.
But the plugin does not paint ..It is a matter of the VST getting the right handle from the main program and an extra processmessages.
But the plugin does not paint ..It is a matter of the VST getting the right handle from the main program and an extra processmessages.
I have a small function that sets it in the VST if you want. But it is easy. Do it at load time.
Oh, yes, forgot to mention that.Oh .. and it took me two weeks now to track down the exception that (now I know ..) occurs on
There were a few things more that I do in that function, like masking all floating point exceptions. (Necessary for ms C(++) compiled hosts, do not forget that...)I didn't know about that. Maybe it is already done in the example code from VSTPluginwizard1.0 or Delphi ASIO & VST Packages 1.3
You may also want to examine Christian Budde's examples, these are also for FreePascal AFAIK.The Delphi ASIO & VST Packages 1.3 had no working Lazarus compatible code .. :-(
The ASIO unit most definitely works (at least my original version that pre-dates most others) but only in WIN32.Do You think it makes sense to use the 64 bit Lazarus ?
There are 64bit ASIO drivers, so yes..Is the 64 bit ASIO SDK from Steinberg also available as Pascal sources anywhere ?
Delphi ASIO and VST packages have already been ported to CodeTyphon:Thanks a lot for this hint !
http://www.pilotlogic.com/sitejoom/index.php/113-wiki/ct-packages/audio-and-video/237-pl-asiovst
You can use ct2laz to download CodeTyphon components and examples and convert them to Lazarus.
btw, it would be better to wait a few days for a new version of ct2laz which will be compatible with latest CT 6.30.
btw, it would be better to wait a few days for a new version of ct2laz which will be compatible with latest CT 6.30.New ct2laz is out. It handles latest CT 6.30+ components and examples correctly. 8)
New ct2laz is out. It handles latest CT 6.30+ components and examples correctly. 8)Thank You, I will look into it !
Do You work on VST plugins or audio software ?No, sorry. I use FFT, IFFT and direct wave synthesis for other purposes, but so far my roads did not cross with VST.
Delphi ASIO and VST packages have already been ported to CodeTyphon:Thanks a lot, avra !
http://www.pilotlogic.com/sitejoom/index.php/113-wiki/ct-packages/audio-and-video/237-pl-asiovst
You can use ct2laz to download CodeTyphon components and examples and convert them to Lazarus.
The "Delphi ASIO and VST packages" from CodeTyphon does not fully work after converting it with ct2laz.Find file "allAsioVSTRegisterIDE.pas" and replace ppr with lpr in this line:
There is a new Project type called "VST plugin" being created. It throws an error on saving, due to wrong *.ppr instead of *.lpr
And there's no working VST plugin template.If you have left default options in ct2laz, it would have downloaded and extracted both components (in "typhon" directory) and examples (in "CodeOcean" directory). I found "CodeOcean\pl_ASIOVST\samples\GUI" directory full of examples:
I found "CodeOcean\pl_ASIOVST\samples\GUI" directory full of examples:Is that what you're looking for?
AudioDataDisplay\ EQ-Graph\ EQ-Slide\ Fader Test\ ...
My TestPlugin from VST-ASIO 1.0 Delphi package works now, with both Delphi 5 and Lazarus 1.8 :DI am glad you worked it out ;)
Are you sure? PPR is CT counterpart for Lazarus LPR, and I could find PPR mentioned at one place in code as above, but CTPR is CT counterpart for Lazarus LPI and I could not find any part of pl_ASIOVST package code that mentions CTPR.Find file "allAsioVSTRegisterIDE.pas" and replace ppr with lpr in this line:I was wrong, sorry !
MainFile := AProject.CreateProjectFile('VSTPlugin1.ppr');
It is *.lpi !
Are you sure?If You convert the package yourself to Laz .. (You don't need to become a VST Plugin developer now ..)
I saw that instead of *.dpr (like Delphi) or *.lpr it saves the "library VSTPlugin1;" as *.pprIt shouldn't save ppr if you have changed source as mentioned and rebuilt IDE. Did you rebuild IDE?
Now it works, creating a new VST Plugin project.It can not magically start working on it's own. What did you do? Did you rebuild IDE or did something else? It is important for me to get proper feedback to know what to add to ct2laz CSV file, and if proposed patch was enough or not.
Did you rebuild IDE?Yes. Everything's okay now. You only need to change this *.ppr to *.lpr in ct2laz.
It can not magically start working on it's own. What did you do?I have the "VST Plugin Analyser.exe" as host.
I am glad this is clear now so I can add this new rule to CSV file of ct2laz.Did you rebuild IDE?Yes. Everything's okay now. You only need to change this *.ppr to *.lpr in ct2laz.
As I'm working on code in pl_ASIOVST, the package and Lazarus needs rebuilds.
But things are difficult. In Samplitude Music Studio 2014 32 Bit only the Delphi 5 version works.Well, I do not know if anyone else on Lazarus is familiar with VST plugins. I guess that situation will be better once pl_ASIOVST becomes available from OPM. Until then, your best chance is to report any problem in PilotLogic forum. However, they will surely not support pl_ASIOVST in Lazarus, so you will have to download latest CodeTyphon and try to see if the problems are the same, and if they are report problems to PilotLogic forum. Sometimes you wait forever for a fix, and sometime they are pretty fast like here:
In Samplitude Music Studio 2014 64 Bit all three plugins do appear, two do work.
I guess that situation will be better once pl_ASIOVST becomes available from OPM.What's OPM ? Online Package Manager ?
@PeterXYes. ASIOVST is available since last summer in OPM.
What's OPM ? Online Package Manager ?
Sorry, I heard from the "Online Package Manager" the first time ever.Quote@PeterXYes. ASIOVST is available since last summer in OPM.
What's OPM ? Online Package Manager ?
@PeterXIt's already integrated, just not installed by default. For more info, please read this: http://wiki.freepascal.org/Online_Package_Manager
Will this be integrated into the "Install / deinstall Packages" dialog of Laz IDE one day ?
It's already integrated, just not installed by default. For more info, please read this: http://wiki.freepascal.org/Online_Package_ManagerOkay, now I know more :)
I found ASIO-VST on http://packages.lazarus-ide.org/It will be fixed once pl_ASIOVST is established in new ct4laz repo and OPM starts using that version.
But there it does not contain the "samples" folder.
And also the "VST Plugin" project invented with the package fails.Already explained:
As this comes from PilotLogic, I expect there's nobody maintaning the package here for Lazarus ?
How can I contribute changes to the package ?
...your best chance is to report any problem in PilotLogic forum. However, they will surely not support pl_ASIOVST in Lazarus, so you will have to download latest CodeTyphon and try to see if the problems are the same, and if they are report problems to PilotLogic forum. Sometimes you wait forever for a fix, and sometime they are pretty fast like here:
http://www.pilotlogic.com/sitejoom/index.php/forum/audio-and-video-development/3457-the-asio-hosts-both-make-the-ide-crash-immediately
...your best chance is to report any problem in PilotLogic forum. ..Okay, I'll go that way.
I still have some trouble opening the VST plugin in my software.
Reasons not clear, might be alignment problems due to wrong compiler switches.