Delphi ASIO & VST sourceforge project

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi to all..!

I've discovered the SVN version of the SDK and I think this is a great treasure for anyone who wants to develop VST's in DELPHI.

Currently I'm trying to run one of the Synth's VST, they compile flawlessly but I got an Access Violation Error when I try to play a note.
I'm in Delphi XE2 and this happens in 32 and 64 bit.

I don't think this is a UNICODE problem, since I suppose they're all fixed in the SVN version, but I can't understand what it could be. The error happens in this function:

Code: Select all

function TVoiceList.Add(SineSynthVoice: TSineSynthVoice): Integer;
begin
 Result := FCount;
 if Result = FCapacity then Grow;
 FList^[Result] := SineSynthVoice; //THIS IS THE LINE THAT GIVES PROBLEMS
 Inc(FCount);
 if SineSynthVoice <> nil then Notify(SineSynthVoice, lnAdded);
end;
I'm lost and I can't figure it out. :-(


Paolo

Post

FOUND!!!!
I had to rescribe the class VoiceList, that is really similar to a TObjectList.

I inherited the old methods and I forced the typecast for some functions (to avoid using "is" in the other part I think). This is the new shorter class.

With a simple replace, it could compile all the other Synth examples (in 64 BIT!!!)
:-)

Code: Select all

unit VoiceList;

interface
uses
  Classes, RTLConsts, Contnrs, SineSynthVoice;

type
  TVoiceList = class(TObjectList)
  private

  protected
    function Get(Index: Integer): TSineSynthVoice;
    procedure Put(Index: Integer; SineSynthVoice: TSineSynthVoice);
    procedure Notify(SineSynthVoice: TSineSynthVoice; Action: TListNotification);virtual;
  public

    function Add(SineSynthVoice: TSineSynthVoice): Integer;

    function Expand: TVoiceList;
    function Extract(SineSynthVoice: TSineSynthVoice): TSineSynthVoice;
    function First: TSineSynthVoice;
    function IndexOf(SineSynthVoice: TSineSynthVoice): Integer;
    procedure Insert(Index: Integer; SineSynthVoice: TSineSynthVoice);
    function Last: TSineSynthVoice;
    function Remove(SineSynthVoice: TSineSynthVoice): Integer;
     procedure Assign(ListA: TVoiceList; AOperator: TListAssignOp; ListB: TVoiceList);

    property Items[Index: Integer]: TSineSynthVoice read Get write Put; default;

  end;

implementation

{ TVoiceList }




function TVoiceList.Add(SineSynthVoice: TSineSynthVoice): Integer;
begin
Result:= inherited Add(SineSynthVoice);
end;

function TVoiceList.Expand: TVoiceList;
begin
 Result:=  TVoiceList(inherited Expand);
end;

function TVoiceList.Extract(SineSynthVoice: TSineSynthVoice): TSineSynthVoice;
begin
Result := TSineSynthVoice(inherited Extract(SineSynthVoice));
end;

function TVoiceList.First: TSineSynthVoice;
begin
  Result := Get(0);
end;

function TVoiceList.Get(Index: Integer): TSineSynthVoice;
begin
  Result:=  TSineSynthVoice(inherited Get(Index));
end;


function TVoiceList.IndexOf(SineSynthVoice: TSineSynthVoice): Integer;
begin
   Result:=  inherited IndexOf(SineSynthVoice);
end;

procedure TVoiceList.Insert(Index: Integer; SineSynthVoice: TSineSynthVoice);
begin
 inherited Insert(Index,SineSynthVoice);
end;

function TVoiceList.Last: TSineSynthVoice;
begin
  Result := Get(Count - 1);
end;



procedure TVoiceList.Put(Index: Integer; SineSynthVoice: TSineSynthVoice);
begin
   inherited Put(Index,SineSynthVoice);
end;

function TVoiceList.Remove(SineSynthVoice: TSineSynthVoice): Integer;
begin
 Result:= inherited Remove(SineSynthVoice);
end;

procedure TVoiceList.Notify(SineSynthVoice: TSineSynthVoice; Action: TListNotification);
begin
inherited Notify(SineSynthVoice, Action);
end;

procedure TVoiceList.Assign(ListA: TVoiceList; AOperator: TListAssignOp; ListB: TVoiceList);

begin
 inherited Assign(ListA,AOperator,ListB);
end;

end.

Post

Hi,

I just installed Xe2 (plus the latest updates) and I am trying to install the latest DelphiAsioVST from SVN and I am having problems installing the packages for the Win32 platform.

The first problem I'm having is that I'm getting the following error when trying to compile DAV_Common_D16:
[DCC Error] DAV_Common.pas(1324): E2116 Invalid combination of opcode and operands
with function GetMXCSR: Cardinal in DAV_Common.pas

Code: Select all

function GetMXCSR: Cardinal;
var
  State : PInt64;
begin
  GetMem(State, 512); // needs to be aligned!
  try
    asm
      //the following line of code produces
      //error E2116: E2116 Invalid combination of opcode & operands
      FXSAVE   State  
      MOV      EDX, State
      {$IFDEF CPUx86_64}
      MOV      EAX, [RDX + 24].Cardinal
      {$ELSE}
      MOV      EAX, [EDX + 24].Cardinal
      {$ENDIF}
      MOV      Result, EAX
    end;
  finally
    FreeMem(State);
  end;
end;
Unless the global search function is broken this function appears to be dead code - it isn't referenced by any code in any of the projects.
When I comment out the function the DAV_Common_D16 compiles OK.
ImageCakewalk/Sonar Plugin Management Tools

Post

Yes, you can delete that part and everything works fine! :-)

Currently I'm trying to run the Simple Sampler example in 64-bit.
It gives me a terrible sound when I try to play a WAV and I'm trying to understand why. I tried to run a parallel debugging for the 32 bit and the 64 bit versions, but I can't spot where's the problem...

Paolo

Post

I suspect the error is in this function:

Code: Select all

function TSimpleSamplerVoice.Process: Single;
begin
 if TVSTSSModule(FVSTModule).SampleLength <= 0 then
  begin
   result := FPosition.Re * FAngle.Re - FPosition.Im * FAngle.Im;
   FPosition.Im := FPosition.Im * FAngle.Re + FPosition.Re * FAngle.Im;
   FPosition.Re := result; result := result * FAmplitude;
  end
 else
  begin
   Result := FAmplitude * Hermite32_asm(FSampleFrac, @FMem[0]);
   FSampleFrac := FSampleFrac + FSampleInc;
   while FSampleFrac >= 1 do
     begin
      inc(FSamplePos);
      if FSamplePos >= TVSTSSModule(FVSTModule).SampleLength
       then FSamplePos := 0;
      FSampleFrac := FSampleFrac - 1;
      Move(FMem[1], FMem[0], 12);
      FMem[3] := TVSTSSModule(FVSTModule).Sample[FSamplePos];
     end;
  end;
end;
I say this, because the Waveform display displays the correct waveform and the Process Replacing method outputs the correct thing. No, changing to Hermire64_asm don't resolve the things. Any ideas of porting this code to 64 bits?

Paolo

Post

DONE!! I hope this info will be useful to someone else who wants to compile the Examples for Delphi XE2 at 64 bits..! Actually Christian's functions are made to work with 64 bits in mind, so there are simple things to correct. In my previous issue I couldn't make the Simple Sampler example to work correctly, due to this function, that was reading ASM code (I thought that on 64bit it generates an error, strange).

There's also a typo, I think, in the NON asm version of the formula with a pointer having the symbol ^ that wasn't needed. Here's the correct Hermite_32 formula.

DAV_DspInterpolation.pas

Code: Select all

function Hermite32_asm(const Fractional: Single; Pntr: PDAV4SingleArray): Single;

var
  c : TDAV4SingleArray;
  b : Single;
begin
  c[0] := (Pntr[2] - Pntr[0]) * CHalf64;
  c[1] := Pntr[1] - Pntr[2];
  c[2] := c[0] + c[1];
  c[3] := c[2] + c[1] + (Pntr[3] - Pntr[1]) * CHalf64;
  b    := c[2] + c[3];
  Result := ((((c[3] * Fractional) - b) * Fractional + c[0]) * Fractional + Pntr[1]);

end;
Yes, the name as no meaning now, because there's no ASM in it, so the better way is to force the compiler IFDEF to read that formula for the 64 bit compiler. Keep in mind that I've correct it since the original has a ^ that wasn't needed.
Christian I'm sincerely impressed by the amount of work you put in your framework.

Paolo

Post

After spending a lot of hours on refactoring the code to Delphi XE2 (mostly String->AnsiString), I was able to build the packages and install them. Unfortunately, trying running included examples I get AVs when selecting ASIO driver or changing inputs/outputs.

Is there are any working release or other (may be commercial) library with ASIO/VST2 supporting Delphi XE2? I wish to develop 32 and 64 bit VST hosts.

Kindest regards,
Jacek Hajnrych

Post

The code in the SVN repository does support XE2 since the very first days when XE2 was released. You can get it here: http://sourceforge.net/scm/?type=svn&group_id=178956

Post

Christian,

I used the code from SVN (trunk). However, it doesn't compiled properly. Small corrects allowed for compiling but it didn't worked properly (e.g. AV when selecting ASIO driver). What's more, I cannot compile it for 64 bit Windows (assembler errors).

Regards,
Jacek

Post

I am going to try my hand at this for Delphi XE2 (used to program in Delphi a LONG time ago).

Has anyone had any luck with this working in 32 bit? I've seen the 64 bit complaints, but does 32 bit work well?

I have not tried anything yet, but will read through this enormous thread and try my hand at creating something simple.

I will be using the starter edition of Embarcadero Delphi XE2. If all goes well, i'll upgrade to the pro version later on.

Any help would be appreciated.

Mike

Post

Karmacomposer wrote:I am going to try my hand at this for Delphi XE2 (used to program in Delphi a LONG time ago).

Has anyone had any luck with this working in 32 bit? I've seen the 64 bit complaints, but does 32 bit work well?

Mike
Hi Mike,

Finally, I managed to properly compile the package. I'm running Delphi XE2 with the latest updates. I haven't tried 64 bit version yet. 32 bit version works properly. I'm able to compile and run most of the included examples. I started my own simple project (ASIO Host). After reading Steinberg's ASIO SDKs documentation it looks quite simple. I plan to build a simple ASIO/VST host with channels, VST slots and simple routing. There's included simple ASIO/VST host example. It allows to run only one VST plugin and works with single stereo in/out pairs while I plan to use mu multi in/out soundcard and build a dynamic VST chain for a channel. I'm not sure about Delphi Started Edition and required updates but I hope updates are common for all editions.

The library is great and free. Although it misses a good documentation. I suggest to take a closer look to examples.

Regards,
Jacek

Post

JacekH wrote:
Karmacomposer wrote:I am going to try my hand at this for Delphi XE2 (used to program in Delphi a LONG time ago).

Has anyone had any luck with this working in 32 bit? I've seen the 64 bit complaints, but does 32 bit work well?

Mike
Hi Mike,

Finally, I managed to properly compile the package. I'm running Delphi XE2 with the latest updates. I haven't tried 64 bit version yet. 32 bit version works properly. I'm able to compile and run most of the included examples. I started my own simple project (ASIO Host). After reading Steinberg's ASIO SDKs documentation it looks quite simple. I plan to build a simple ASIO/VST host with channels, VST slots and simple routing. There's included simple ASIO/VST host example. It allows to run only one VST plugin and works with single stereo in/out pairs while I plan to use mu multi in/out soundcard and build a dynamic VST chain for a channel. I'm not sure about Delphi Started Edition and required updates but I hope updates are common for all editions.

The library is great and free. Although it misses a good documentation. I suggest to take a closer look to examples.

Regards,
Jacek
Thank you.

The biggest difference I see between starter and Pro is unlimited commercial license, 64 bit and OSX development - so I cannot port anything to Mac (which means no IOS) till I pony up for the Pro edition. However, I can create my projects now and then buy Pro and immediately be able to output 64 bit and Mac versions since Delphi is a code once deploy many solution.

My interest lies mainly with virtual instruments and not necessarily vst effects. Can I create vsti with this library?

Mike

Post

Of course, you can create VSTi instruments. There 4 or 5 (AFAIR) examples of simple VSTi's and a number of FM synthesis algorithms.

Regards,
Jacek

Post

So this means I can write VST's in a proper Pascal-family language (I'm familiar with Modula-2, have previously used various Pascals including TP) instead of having to use C++? :) :) :love:

Post

nevermind

Post Reply

Return to “DSP and Plugin Development”