19 Jun '13 - 02:02 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: BASS_VST-how to load, list use a VST effect?  (Read 3365 times)
aafuss
Posts: 11


« on: 16 Jul '06 - 13:25 »
Reply with quoteQuote

How do I load, list & use  a VST effect  in a Delphi or VB application  using BASS_VST?
Logged
Keyman
Posts: 167


« Reply #1 on: 16 Jul '06 - 14:58 »
Reply with quoteQuote

How to do this in VB I don't know.
The Delphi code however has been posted before.

This code will give you the idea, keep in mind that FVSTForm is a simple (empty) form.

// Open and load the VST plugin
procedure LoadVST;
begin
  VSTOpenDialog.Execute;
  FVSTHandle := BASS_VST_ChannelSetDSP(FStream, PChar(VSTOpenDialog.FileName), 0, 0)
end;


procedure ShowVST;
var
  VSTPlugInfo: BASS_VST_INFO;
begin
  if not Assigned(FVSTForm) then
    FVSTForm := TVSTForm.Create(Application);

  if BASS_VST_GetInfo(FVSTHandle, @VSTPlugInfo) then
  begin
    if VSTPlugInfo.hasEditor then
    begin
      FVSTForm.Caption := ' ' + string(VSTPlugInfo.effectName) + ' - ' + string(VSTPlugInfo.vendorName);
      if VSTPlugInfo.editorHeight = 0 then
        FVSTForm.ClientHeight := 150
      else FVSTForm.ClientHeight := VSTPlugInfo.editorHeight;

      if VSTPlugInfo.editorWidth = 0 then
        FVSTForm.ClientWidth  := 300
      else FVSTForm.ClientWidth  := VSTPlugInfo.editorWidth;

      if (VSTPlugInfo.editorHeight = 0) or (VSTPlugInfo.editorWidth = 0) then
        FVSTForm.BorderStyle := bsSizeable
      else FVSTForm.BorderStyle := bsDialog;

      BASS_VST_EmbedEditor(FVSTHandle, 0);  // un-embed first!!
      if BASS_VST_EmbedEditor(FVSTHandle, FVSTForm.Handle) then
      begin
        if FVSTForm.Visible then
          FVSTForm.BringToFront
        else FVSTForm.Visible := True;
      end;
    end;
  end;
end;

// to unload the plugin (make sure the editor window is closed before you do this)
procedure UnloadVST;
begin
  if Assigned(FVSTForm) then
    FVSTForm.Hide;

  BASS_VST_ChannelRemoveDSP(FStream, FVSTHandle);
end;

Logged
aafuss
Posts: 11


« Reply #2 on: 17 Jul '06 - 14:15 »
Reply with quoteQuote

Will this work in Delphi 7?
Logged
aafuss
Posts: 11


« Reply #3 on: 17 Jul '06 - 18:03 »
Reply with quoteQuote

How to do this in VB I don't know.
The Delphi code however has been posted before.

This code will give you the idea, keep in mind that FVSTForm is a simple (empty) form.

// Open and load the VST plugin
procedure LoadVST;
begin
  VSTOpenDialog.Execute;
  FVSTHandle := BASS_VST_ChannelSetDSP(FStream, PChar(VSTOpenDialog.FileName), 0, 0)
end;


procedure ShowVST;
var
  VSTPlugInfo: BASS_VST_INFO;
begin
  if not Assigned(FVSTForm) then
    FVSTForm := TVSTForm.Create(Application);

  if BASS_VST_GetInfo(FVSTHandle, @VSTPlugInfo) then
  begin
    if VSTPlugInfo.hasEditor then
    begin
      FVSTForm.Caption := ' ' + string(VSTPlugInfo.effectName) + ' - ' + string(VSTPlugInfo.vendorName);
      if VSTPlugInfo.editorHeight = 0 then
        FVSTForm.ClientHeight := 150
      else FVSTForm.ClientHeight := VSTPlugInfo.editorHeight;

      if VSTPlugInfo.editorWidth = 0 then
        FVSTForm.ClientWidth  := 300
      else FVSTForm.ClientWidth  := VSTPlugInfo.editorWidth;

      if (VSTPlugInfo.editorHeight = 0) or (VSTPlugInfo.editorWidth = 0) then
        FVSTForm.BorderStyle := bsSizeable
      else FVSTForm.BorderStyle := bsDialog;

      BASS_VST_EmbedEditor(FVSTHandle, 0);  // un-embed first!!
      if BASS_VST_EmbedEditor(FVSTHandle, FVSTForm.Handle) then
      begin
        if FVSTForm.Visible then
          FVSTForm.BringToFront
        else FVSTForm.Visible := True;
      end;
    end;
  end;
end;

// to unload the plugin (make sure the editor window is closed before you do this)
procedure UnloadVST;
begin
  if Assigned(FVSTForm) then
    FVSTForm.Hide;

  BASS_VST_ChannelRemoveDSP(FStream, FVSTHandle);
end;



Hi,
Having trouble with your code:
Build
  [Error] Unit1.pas(30): Undeclared identifier: 'VSTOpenDialog'
  [Error] Unit1.pas(30): Missing operator or semicolon
  [Error] Unit1.pas(31): Undeclared identifier: 'FVSTHandle'
  [Error] Unit1.pas(31): Undeclared identifier: 'BASS_VST_ChannelSetDSP'
  [Error] Unit1.pas(31): Undeclared identifier: 'FStream'
  [Error] Unit1.pas(31): ')' expected but identifier 'FileName' found
  [Error] Unit1.pas(36): Undeclared identifier: 'BASS_VST_INFO'
  [Error] Unit1.pas(38): Undeclared identifier: 'FVSTForm'
  [Error] Unit1.pas(39): Undeclared identifier: 'TVSTForm'
  [Error] Unit1.pas(41): Undeclared identifier: 'BASS_VST_GetInfo'
  [Error] Unit1.pas(41): Undeclared identifier: 'FVSTHandle'
  [Error] Unit1.pas(43): 'THEN' expected but identifier 'hasEditor' found
  [Error] Unit1.pas(45): Missing operator or semicolon
  [Error] Unit1.pas(45): ')' expected but identifier 'effectName' found
  [Error] Unit1.pas(46): Missing operator or semicolon
  [Error] Unit1.pas(46): 'THEN' expected but identifier 'editorHeight' found
  [Error] Unit1.pas(50): 'THEN' expected but identifier 'editorWidth' found
  [Error] Unit1.pas(54): ')' expected but identifier 'editorHeight' found
  [Error] Unit1.pas(59): Undeclared identifier: 'BASS_VST_EmbedEditor'
  [Error] Unit1.pas(59): 'THEN' expected but identifier 'Handle' found
  [Error] Unit1.pas(61): 'THEN' expected but identifier 'Visible' found
  [Error] Unit1.pas(72): Incompatible types
  [Error] Unit1.pas(73): Missing operator or semicolon
  [Error] Unit1.pas(75): Undeclared identifier: 'BASS_VST_ChannelRemoveDSP'
  [Error] Unit1.pas(75): Undeclared identifier: 'FStream'
  [Error] Unit1.pas(79): Record, object or class type required
  [Error] Unit1.pas(81): 'END' expected but end of file found
  [Error] Unit1.pas(12): Unsatisfied forward or external declaration: 'TForm1.Button1Click'
  [Fatal Error] babyavst.dpr(6): Could not compile used unit 'Unit1.pas'


Can you do a sample containg the code, so I can then load VST plugins?
Logged
aafuss
Posts: 11


« Reply #4 on: 19 Jul '06 - 15:25 »
Reply with quoteQuote

Keyman,
Tried using your code, but won't work for me. Can you create a sample contaning the code? So that I can then fix what's wrong with my code.
Logged
Keyman
Posts: 167


« Reply #5 on: 20 Jul '06 - 11:51 »
Reply with quoteQuote

This was made in Delphi 7.

You need to (of course) declare some private fields for this to work.

VSTOpenDialog is a TFileOpenDialog;
FVSTForm is a TVSTForm; // make a standard form & name it VSTForm, add it to your project
FVSTHandle is a HSTREAM;
use the unit Bass_VST to solve all 'undeclared identifier: BASS_VST_XXX' errors

I don't have an example project or anything but it should be easy to implement with the pointers I gave you.
Just create a empty form, drop an FileOpenDialog on it and add the fields and methods as described before.

uses
  Windows, Classes, Dialogs, BASS!!!;  //Need bass for the HSTREAM type!!

type
  MyForm = class(TForm)
    VSTOpenDialog: TFileOpenDialog;
  private
    FVSTForm:  TVSTForm; // make a standard form & name it VSTForm, add it to your project
    FVSTHandle: HSTREAM;
    procedure LoadVST;
    procedure ShowVST;
    procedure UnloadVST;
  end;

implementation

uses
  bass_vst; 

procedure TMyForm.LoadVST;
begin
  // code here
end;

etc. etc.

Don't forget to use the bass_vst unit!
Add some buttons to test the stuff and of you go!
Logged
aafuss
Posts: 11


« Reply #6 on: 20 Jul '06 - 16:35 »
Reply with quoteQuote

Where do I paste in the first code-and where to get Bass_VST unit?
Logged
aafuss
Posts: 11


« Reply #7 on: 20 Jul '06 - 16:46 »
Reply with quoteQuote

unit Unit1;

interface
uses
  Windows, Classes, Dialogs, BASS;  //Need bass for the HSTREAM type!!

type
  MyForm = class(TForm)

    VSTOpenDialog: TFileOpenDialog;
  private
    FVSTForm:  TVSTForm; // make a standard form & name it VSTForm, add it to your project
    FVSTHandle: HSTREAM;
    procedure LoadVST;
    procedure ShowVST;
    procedure UnloadVST;
  end;

implementation

uses
  bass_vst; 

procedure TMyForm.LoadVST;
begin
procedure LoadVST;
begin
  VSTOpenDialog.Execute;
  FVSTHandle := BASS_VST_ChannelSetDSP(FStream, PChar(VSTOpenDialog.FileName), 0, 0)
end;


procedure ShowVST;
var
  VSTPlugInfo: BASS_VST_INFO;
begin
  if not Assigned(FVSTForm) then
    FVSTForm := TVSTForm.Create(Application);

  if BASS_VST_GetInfo(FVSTHandle, @VSTPlugInfo) then
  begin
    if VSTPlugInfo.hasEditor then
    begin
      FVSTForm.Caption := ' ' + string(VSTPlugInfo.effectName) + ' - ' + string(VSTPlugInfo.vendorName);
      if VSTPlugInfo.editorHeight = 0 then
        FVSTForm.ClientHeight := 150
      else FVSTForm.ClientHeight := VSTPlugInfo.editorHeight;

      if VSTPlugInfo.editorWidth = 0 then
        FVSTForm.ClientWidth  := 300
      else FVSTForm.ClientWidth  := VSTPlugInfo.editorWidth;

      if (VSTPlugInfo.editorHeight = 0) or (VSTPlugInfo.editorWidth = 0) then
        FVSTForm.BorderStyle := bsSizeable
      else FVSTForm.BorderStyle := bsDialog;

      BASS_VST_EmbedEditor(FVSTHandle, 0);  // un-embed first!!
      if BASS_VST_EmbedEditor(FVSTHandle, FVSTForm.Handle) then
      begin
        if FVSTForm.Visible then
          FVSTForm.BringToFront
        else FVSTForm.Visible := True;
      end;
    end;
  end;
end;

// to unload the plugin (make sure the editor window is closed before you do this)
procedure UnloadVST;
begin
if Assigned(FVSTForm) then
    FVSTForm.Hide;

  BASS_VST_ChannelRemoveDSP(FStream, FVSTHandle);
end;
end.
END





Still having lots of problems-I tried adding the new code but won't work at all.  Added the declarations, BASS_VST.

Here's my code-can you help me to get it working?:
http://stashbox.org/uploads/1153410378/Babya%20VST.zip
Logged
Keyman
Posts: 167


« Reply #8 on: 21 Jul '06 - 09:50 »
Reply with quoteQuote

Hi,

Are you sure you want to do this?
Your project showed me that you don't have much programming experience  Huh
Anyway, to help you getting started I made a complete program to load and play music files and to load and show VST plugins.

Download here: Link removed
« Last Edit: 24 Jul '06 - 15:36 by Keyman » Logged
aafuss
Posts: 11


« Reply #9 on: 21 Jul '06 - 19:20 »
Reply with quoteQuote

Thanks, Keyman.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines