📄 mmplgdsp.pas
字号:
{========================================================================}
{= (c) 1995-98 SwiftSoft Ronald Dittrich =}
{========================================================================}
{= All Rights Reserved =}
{========================================================================}
{= D 01099 Dresden = Fax.: +49 (0)351-8037944 =}
{= Loewenstr.7a = info@swiftsoft.de =}
{========================================================================}
{= Actual versions on http://www.swiftsoft.de/mmtools.html =}
{========================================================================}
{= This code is for reference purposes only and may not be copied or =}
{= distributed in any format electronic or otherwise except one copy =}
{= for backup purposes. =}
{= =}
{= No Delphi Component Kit or Component individually or in a collection=}
{= subclassed or otherwise from the code in this unit, or associated =}
{= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
{= without express permission from SwiftSoft. =}
{= =}
{= For more licence informations please refer to the associated =}
{= HelpFile. =}
{========================================================================}
{= $Date: 11.04.98 - 04:29:50 $ =}
{========================================================================}
unit MMPlgDSP;
{$I COMPILER.INC}
interface
uses
Windows,
Messages,
SysUtils,
Forms,
MMUtils,
MMSystem,
MMRegs;
const
DSP_HDRVER = $10;
type
TScaleLayer3 = array [0..1 , 0..31 , 0..17] of Single; (* Layer3 Amplification array *)
TScaleLayer2 = array [0..1 , 0..31 , 0..35] of Single; (* Layer2 Amplification array *)
TShortData = array [0 .. 20000] of Smallint; (* Sample array *)
PShortData = ^TShortData; (* Pointer to Sample-Array *)
PPlugInDSPModule = ^TPlugInDSPModule;
TPlugInDSPModule = record (* PlugIn DSP-module type *)
Description : PChar;
hWNDParent : HWND; {parent window (filled in by Application)}
hDLLInstance : HINST; {instance handle to this DLL (filled in by Application)}
sRate : integer; {sample rate (filled in by Application)}
nCh : integer; {number of channels (filled in by Application)}
BlockSize : Integer; {BlockSize (filled in by Application)}
Config : procedure(This_Mod: PPlugInDSPModule); cdecl;
Init : function (This_Mod: PPlugInDSPModule): Integer; cdecl;
Restart : function (This_Mod: PPlugInDSPModule): Integer; cdecl;
ModifySamples : procedure(This_Mod: PPlugInDSPModule; Samples: PShortData); cdecl;
ModifyLayer3XR : procedure(This_Mod: PPlugInDSPModule; var Xr: TScaleLayer3); cdecl;
ModifyLayer2Subband : procedure(This_Mod: PPlugInDSPModule; var Subbands: TScaleLayer2); cdecl;
Quit : procedure(This_Mod: PPlugInDSPModule); cdecl;
UserData : Pointer;
end;
PPlugInDSPModule2 = ^TPlugInDSPModule2;
TPlugInDSPModule2 = record (* PlugIn DSP-module type *)
Description : PChar;
hWNDParent : HWND; {parent window (filled in by Application)}
hDLLInstance : HINST; {instance handle to this DLL (filled in by Application)}
Config : procedure(This_Mod: PPlugInDSPModule2); cdecl;
Init : function (This_Mod: PPlugInDSPModule2): Integer; cdecl;
ModifySamples : function (This_Mod: PPlugInDSPModule2; Samples: PShortData; nSamples, bps, nch, srate: integer): integer; cdecl;
Quit : procedure(This_Mod: PPlugInDSPModule2); cdecl;
UserData : Pointer;
end;
PPlugInDSPHeader = ^TPlugInDSPheader;
TPlugInDSPHeader = packed record (* PlugIn DSP Header *)
Version : Integer; (* PlugIn DSP version ID , PlugIn checks this *)
Description : PChar; (* Name of the DSP-plugin *)
GetModule : function(Idx: Integer): Pointer; cdecl;
end;
PDSPModule = ^TDSPModule;
TDSPModule = packed record
Description : string;
Active : Boolean;
ModuleData : PPlugInDSPModule;
ModuleData2 : PPlugInDSPModule2;
end;
PPlugInDSP = ^TPlugInDSP;
TPlugInDSP = packed record
DLLName : string;
DLLInstance : THandle;
Description : string;
Modules : array[0..99] of TDSPModule;
NumModules : integer;
Open : Boolean;
Header : PPlugInDSPHeader;
end;
function ReadPlugInDSP(FileName: string): PPlugInDSP;
procedure FreePlugInDSP(var PlugIn: PPlugInDSP);
function OpenPlugInDSP(PlugIn: PPlugInDSP; ParentWindow: HWND): Boolean;
procedure ClosePlugInDSP(PlugIn: PPlugInDSP);
procedure ConfigPlugInDSPModule(Module: TDSPModule);
function InitPlugInDSPModule(var Module: TDSPModule; pwfx: PWaveFormatEx; BytesPerBlock: Longint): Boolean;
function RestartPlugInDSPModule(var Module: TDSPModule; pwfx: PWaveFormatEx; BytesPerBlock: Longint): Boolean;
function ModifySamplesPlugInDSP(var Module: TDSPModule; Buffer: PSmallint; nBytes: Longint; pwfx: PWaveFormatEx): Longint;
procedure QuitPlugInDSPModule(var Module: TDSPModule);
implementation
type
TGetHeader = function : PPlugInDSPHeader; cdecl;
TGetModule = function (Which: Integer) : Pointer; cdecl;
TConfig = procedure(This_Mod: Pointer); cdecl;
TInit = function (This_Mod: Pointer): Integer; cdecl;
TRestart = function (This_Mod: Pointer): Integer; cdecl;
TQuit = procedure(This_Mod: Pointer); cdecl;
TModifySamples = procedure(This_Mod: Pointer; Samples: PShortData); cdecl;
TModifySamples2 = function (This_Mod: Pointer; Samples: PShortData; nSamples, bps, nch, srate: integer): integer; cdecl;
TModifyLayer3XR = procedure(This_Mod: Pointer; var Xr : TscaleLayer3); cdecl;
TModifyLayer2Subband = procedure(This_Mod: Pointer; var Subbands: TScaleLayer2); cdecl;
{==============================================================================}
function ReadPlugInDSP(FileName: string): PPlugInDSP;
var
hPlugIn : THandle;
EntryPoint: TFarProc;
GetHeader : TGetHeader;
GetModule : TGetModule;
Hdr : PPlugInDSPHeader;
Module : Pointer;
Ver2 : Boolean;
begin
Result := nil;
hPlugIn := LoadLibrary(PChar(FileName));
if (hPlugIn <> 0) then
begin
try
Ver2 := False;
EntryPoint := GetProcAddress(hPlugIn, 'winampDSPGetHeader');
if (EntryPoint = nil) then
EntryPoint := GetProcAddress(hPlugIn, 'MMPlugInDSPGetHeader');
if (EntryPoint = nil) then
begin
EntryPoint := GetProcAddress(hPlugIn, 'winampDSPGetHeader2');
if (EntryPoint <> nil) then Ver2 := True;
end;
if (EntryPoint <> nil) then
begin
@GetHeader := EntryPoint;
Hdr := GetHeader; { Get PlugIn-header }
if (Hdr <> nil) and (Hdr.Version >= DSP_HDRVER) then
begin
New(Result);
with Result^ do
begin
DLLName := UpperCase(FileName);
DLLInstance := 0;
Description := StrPas(Hdr.Description);
Header := nil;
Open := False;
GetModule := Hdr^.GetModule;
NumModules := 0;
repeat
Module := GetModule(NumModules);
if (Module <> nil) then
begin
if Ver2 then
Modules[NumModules].Description := StrPas(PPlugInDSPModule2(Module).Description)
else
Modules[NumModules].Description := StrPas(PPlugInDSPModule(Module).Description);
Modules[NumModules].ModuleData := nil;
Modules[NumModules].ModuleData2 := nil;
Modules[NumModules].Active := False;
inc(NumModules);
end;
until (Module = nil) or (NumModules = 100);
end;
end;
end;
finally
FreeLibrary(hPlugIn);
end;
end;
end;
{==============================================================================}
function OpenPlugInDSP(PlugIn: PPlugInDSP; ParentWindow: HWND): Boolean;
var
EntryPoint: TFarProc;
GetHeader : TGetHeader;
GetModule : TGetModule;
Hdr : PPlugInDSPHeader;
Module : Pointer;
Ver2 : Boolean;
begin
if (PlugIn <> nil) and not PlugIn.Open then
begin
PlugIn.DLLInstance := LoadLibrary(PChar(PlugIn.DLLname));
if (PlugIn.DLLInstance <> 0) then
begin
try
Ver2 := False;
EntryPoint := GetProcAddress(PlugIn.DLLInstance, 'winampDSPGetHeader');
if (EntryPoint = nil) then
EntryPoint := GetProcAddress(PlugIn.DLLInstance, 'MMPlugInDSPGetHeader');
if (EntryPoint = nil) then
begin
EntryPoint := GetProcAddress(PlugIn.DLLInstance, 'winampDSPGetHeader2');
if (EntryPoint <> nil) then Ver2 := True;
end;
if (EntryPoint <> nil) then
begin
@GetHeader := EntryPoint;
Hdr := GetHeader; { Get PlugIn-header }
if (Hdr <> nil) and (Hdr.Version >= DSP_HDRVER) then
begin
with PlugIn^ do
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -