Thema: Delphi Winamp Plugin in Delphi

Einzelnen Beitrag anzeigen

Medium

Registriert seit: 23. Jan 2008
3.686 Beiträge
 
Delphi 2007 Enterprise
 
#2

Re: Winamp Plugin in Delphi

  Alt 23. Okt 2008, 00:11
Ich hab mir mal ein Gerüst zusammen gebastelt, dass eine ganz brauchbare Minimalbasis für eine Plugin DLL ist. Das klärt zwar noch nicht die Frage, wie man denn nun an die Titel kommt, aber es erzeugt zumindest schon mal eine DLL die WinAmp als Plugin annimmt. Ansonsten sind C und Delphi ja konzeptionell nicht so unheimlich weit voneinander entfernt (zumindest was hier relevante Dinge angehen dürfte), so dass das C SDK durchaus eine brauchbare Hilfe ist. Im zweifel zeig doch mal her, an welcher Stelle genau du fest sitzt.

Delphi-Quellcode:
library WinampVisTemplate;

uses
  Windows;

{$R *.res}

type
  PWinampVisModule = ^TwinampVisModule;
  TwinampVisModule = record
    description : PChar; // description of module
    hwndParent : HWND; // parent window (filled in by calling app)
    hDllInstance : HINST; // instance handle to this DLL (filled in by calling app)
    sRate : Cardinal; // sample rate (filled in by calling app)
    nCh : Cardinal; // number of channels (filled in...)
    latencyMs : Cardinal; // latency from call to Render to actual drawing
    delayMs : Cardinal; // delay between calls to Render (in ms)

    // the data is filled in according to the respective Nch entry
    spectrumNCh : Cardinal; // Number of channels
    waveformNCh : Cardinal; // Number of channels
    spectrumData : Array [0..1, 0..575] of Byte; // waveform data (values from 0-255)
    waveformData : Array [0..1, 0..575] of Byte; // spectrum data (values from 0-255)

    // functions that winamp calls to configure the plugin, initialise ...
    Config : procedure(const PVisModule : PwinampVisModule); cdecl;
    Init : function (const PVisModule : PwinampVisModule) : Integer; cdecl;
    Render : function (const PVisModule : PwinampVisModule) : Integer; cdecl;
    Quit : procedure(const PVisModule : PwinampVisModule); cdecl;
    userData : procedure; cdecl; // user data, optional
  end;

  PwinampVisHeader = ^TwinampVisHeader;
  TwinampVisHeader = record
    version : Integer;
    description : PChar; // description of library
    getModule : function (Which : Integer) : PwinampVisModule; cdecl;
  end;

// forward declaration of the procedures
function GetModule(Which :integer) :PWinAMPVisModule; cdecl; forward;
procedure Config(const PVisModule : PWinAMPVisModule); cdecl; forward;
function Init(const PVisModule : PWinAMPVisModule): integer; cdecl; forward;
function Render(const PVisModule : PWinAMPVisModule): integer; cdecl; forward;
procedure Quit(const PVisModule : PWinAMPVisModule); cdecl; forward;
function winampVisGetHeader: PwinampVisHeader; cdecl; export; forward;


const
  HDR: TWinAMPVisHeader =
           (Version : $101; // WinAMP checks this for compatibility
            Description : 'XXX'; // Name of your vis
            GetModule : GetModule);

  VisModule: TWinAMPVisModule =
           (Description : 'XXX'; // Short description of your vis
            hWNDParent : 0;
            hDLLInstance : 0;
            sRate : 0;
            nCh : 0;
            LatencyMs : 10;
            DelayMS : 25;
            SpectrumNch : 2;
            WaveformNch : 0;
            Config : Config; // config function
            Init : Init; // Plug-in initialization function. Returns 0 if success
            Render : Render; // render function. 0 if successful, 1 if vis should end
            Quit : Quit; // quit function
            UserData : nil);

exports
  winampVisGetHeader;

{------------------------------------------------------------------------------}

function WinAMPVisGetHeader: PWinAMPVisHeader;
begin
  // Return the main header
  Result := @HDR;
end;

function GetModule(Which: Integer): PWinampVisModule;
begin
  if which = 0 then
    Result := @VisModule
  else
    Result := nil;
end;

procedure Config(const PVisModule: PWinAMPVisModule);
begin
  // Called when user clicks vis configuration
end;

function Init(const PVisModule: PWinAMPVisModule): Integer;
begin
  // Called first after loading the plugin
  Result := 0;
end;

function Render(const PVisModule: PWinAMPVisModule): Integer;
begin
  // Your code to render one frame of your vis
  // Called continously while vis is running
  Result := 0;
end;

procedure Quit(const PVisModule: PWinAMPVisModule);
begin
  // Called at stopping of vis
end;

begin
end.
"When one person suffers from a delusion, it is called insanity. When a million people suffer from a delusion, it is called religion." (Richard Dawkins)
  Mit Zitat antworten Zitat