home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / nastroje / d5 / DDX_SDK.ZIP / DDXBase.pas < prev    next >
Pascal/Delphi Source File  |  2001-06-02  |  24KB  |  711 lines

  1. unit DDXBase;
  2.  
  3. interface
  4.  
  5. uses
  6.   windows, classes, SysUtils, ComObj, MMSystem, forms, dialogs;
  7.  
  8. const
  9.   WAVE_FORMAT_IEEE_FLOAT = 3; {missing from the Delphi MMSystem header...}
  10.   MaxParams = 16; {your effect can have up to 16 parameters}
  11.   DDX_SDK_Version = 1; {try to keep versions Delphi and C++ libraries together}
  12.  
  13. type
  14.   {the storage array for effect parameters}
  15.   TParamArray = array [0..MaxParams-1] of single;
  16.  
  17.   {lets you easily specify the number of input and output channels you want}
  18.   tChannelMode = (
  19.     cmUnknown,
  20.     cmMonoToMono,
  21.     cmMonoToStereo,
  22.     cmStereoToMono,
  23.     cmStereoToStereo);
  24.   tChannelModes = set of tChannelMode;
  25.  
  26.   {lets you easily specify the type of data you are prepared to process}
  27.   tSampleType = (stUnknown, stFloat32, stInteger16);
  28.     {Delphi equivalents: Single, SmallInt}
  29.   tSampleTypes = set of tSampleType;
  30.  
  31.   { Your plugins should inherit from this base class }
  32.   TDelphiDirectXPluginBase = class
  33.   private
  34.     {storage of our effect parameters}
  35.     fParamArray  : TParamArray;
  36.  
  37.     {what sample types are we PREPARED to handle}
  38.     fSampleTypes : tSampleTypes;
  39.     {what channel modes are we PREPARED to handle}
  40.     fChannelModes: tChannelModes;
  41.  
  42.     {what sample type are we ACTUALLY dealing with}
  43.     fSampleType    : tSampleType;
  44.     fInputChannels : integer;
  45.     fOutputChannels: integer;
  46.     fSampleRate    : integer;
  47.  
  48.     procedure SetChannelModes (val: tChannelModes);
  49.     function  GetChannelModes : tChannelModes;
  50.     procedure SetSampleTypes  (val: tSampleTypes);
  51.     function  GetSampleTypes  : tSampleTypes;
  52.   protected
  53.  
  54.     {will need to be typecase to your actual form type}
  55.     fEditorForm : TForm;
  56.  
  57.     { these get/set methods are for our OWN "properties",
  58.       and not part of the dll inter-communication system. }
  59.     function GetParam (ndx: integer) : single;
  60.     procedure SetParam (ndx: integer; val: single);
  61.  
  62.   public
  63.     {*** YOU PROBABALY DON'T need to override these calls}
  64.     function BaseConnectEditor (aEditorForm : tForm) : integer; virtual;
  65.     { Called by the C++ plugin to connect the plugin to the editor form }
  66.  
  67.     function FocusEditor : integer; virtual;
  68.     { Called by the C++ plugin when focus is sent to the (MS) MFC property page,
  69.       which sadly does not refresh all the controls on a (Borland) VCL form,
  70.       so we have to do it ourself!}
  71.  
  72.     function GetParameter (aParamNum : integer) : single; virtual;
  73.     { Called by the C++ plugin to get a parameter  }
  74.  
  75.     {*** YOU MAY override these calls, but probably won't need to}
  76.     function CheckInputFormat (aFormat : PWAVEFORMATEX) : bool; virtual;
  77.     function CheckOutputFormat (aFormat : PWAVEFORMATEX) : bool; virtual;
  78.     function CheckTransform (aInputFormat, aOutputFormat : PWAVEFORMATEX) : bool; virtual;
  79.     function SetInputFormat (aFormat : PWAVEFORMATEX) : integer; virtual;
  80.     function SetOutputFormat (aFormat : PWAVEFORMATEX) : integer; virtual;
  81.     { These Set...Format calls are the first time you will know about the
  82.       number of input and output channels, the sample format and the sample
  83.       rate.  If you need to do some precomputation based on these items,
  84.       you might override these calls.  Of course, if you just need to use
  85.       these values as they are, they will be in place by the time
  86.       Transform is called. }
  87.  
  88.     function GetMaxBufferSize (
  89.            aSrcBufferSize : integer;
  90.            aDstBufferSize : pInteger) : integer; virtual;
  91.  
  92.     function SetParameter (
  93.                aParamNum : integer;
  94.                aValue    : single)
  95.                          : integer; virtual;
  96.     { Called by the C++ plugin to set a parameter.
  97.       If you need to do some pre-computation based on parameters,
  98.       you might override this. }
  99.  
  100.     {*** YOU WILL PROBABLY NEED to override these calls}
  101.     constructor create; virtual;  {virtual to "force" you to have no parameters}
  102.     { Virtual constructors are one of the "tricky" features of delphi,
  103.       but we definitely need it here because we "register" our descended
  104.       class type (which gets stored in a class reference variable declared as
  105.       the ancestor's class reference), and then hope that the right class will
  106.       be created! }
  107.     destructor destroy; override;
  108.     { You might want to dispose some buffers...}
  109.  
  110.     procedure CompleteConnectEditor; virtual;
  111.     { called after the effect has been connected to an editor form,
  112.       you'll need to override this so that your editor form can be
  113.       connected to the effect object. }
  114.  
  115.     procedure DisplaySetParameter (
  116.                 aParamNum : integer;
  117.                 aValue    : single); virtual;
  118.     { you'll need to override this so that your editor form
  119.       (if connected) can update its visual controls with the
  120.       new values. }
  121.  
  122.     {*** YOU MUST override these calls}
  123.     function Transform (
  124.                aInBuffer  : pointer;
  125.                aInSamples : integer;
  126.                aOutBuffer : pointer;
  127.                aOutSamples: integer;
  128.                aProcessed : pInteger)
  129.                           : integer; virtual; abstract;
  130.     { If you don't know why you have to override this, you should be
  131.       doing something else! ;) }
  132.  
  133.     //function TransformInPlace (
  134.     //           aBuffer   : pointer;
  135.     //           aNumSamps : integer)
  136.     //                     : integer; virtual; abstract;
  137.     { Not enabled }
  138.  
  139.     property ParamArray [ndx: integer] : single read GetParam write SetParam;
  140.  
  141.     {what sample types / channel modes are we PREPARED to handle}
  142.     property ChannelModes  : tChannelModes read GetChannelModes  write SetChannelModes;
  143.     property SampleTypes   : tSampleTypes  read GetSampleTypes   write SetSampleTypes;
  144.  
  145.     {what sample type / channel mode are we ACTUALLY dealing with}
  146.     property SampleType    : tSampleType   read fSampleType      write fSampleType;
  147.     property InputChannels : integer       read fInputChannels   write fInputChannels;
  148.     property OutputChannels: integer       read fOutputChannels  write fOutputChannels;
  149.     property SampleRate    : integer       read fSampleRate      write fSampleRate;
  150.   end;
  151.  
  152.   TDelphiPluginClassRef     = class of TDelphiDirectXPluginBase;
  153.   TDelphiEditorFormClassRef = class of TForm;
  154.  
  155.  
  156. {You MUST call this procedure in the INITIALIZATION section of YOUR effect unit}
  157. procedure RegisterEffect (
  158.             aEffectName        : string;
  159.             aEffectDesc        : string;
  160.             aEffectHelpFile    : string;
  161.             aPropertiesName    : string;
  162.             aEffectGUID        : string;
  163.             aPropertiesGUID    : string;
  164.             aPluginClassRef    : TDelphiPluginClassRef;
  165.             aEditorFormClassRef: TDelphiEditorFormClassRef);
  166.  
  167.  
  168. {Here are the declaration of the procedural interface to the DLL}
  169. {You'll never call these, they are exported}
  170. function DelphiDDXSDKVersion : integer; stdcall; export;
  171. function DelphiEffectCLSID (aGuid : pGuid) : integer; stdcall; export;
  172. function DelphiPropertiesCLSID (aGuid : pGuid) : integer; stdcall; export;
  173. function DelphiEffectName (aName : pchar; aMaxLen : integer) : integer; stdcall; export;
  174. function DelphiEffectDesc (aName : pchar; aMaxLen : integer) : integer; stdcall; export;
  175. function DelphiEffectHelpFile (aName : pchar; aMaxLen : integer) : integer; stdcall; export;
  176. function DelphiPropertiesName (aName : pchar; aMaxLen : integer) : integer; stdcall; export;
  177. function DelphiCreateEffect : pointer; stdcall; export;
  178. function DelphiFreeEffect (aEffect : pointer) : integer; stdcall; export;
  179. function DelphiCheckInputFormat (aEffect : pointer; aFormat : PWAVEFORMATEX) : bool; stdcall; export;
  180. function DelphiCheckOutputFormat (aEffect : pointer; aFormat : PWAVEFORMATEX) : bool; stdcall; export;
  181. function DelphiCheckTransform (aEffect : pointer; aInputFormat, aOutputFormat : PWAVEFORMATEX) : bool; stdcall; export;
  182. function DelphiSetInputFormat (aEffect : pointer; aFormat : PWAVEFORMATEX) : integer; stdcall; export;
  183. function DelphiSetOutputFormat (aEffect : pointer; aFormat : PWAVEFORMATEX) : integer; stdcall; export;
  184. function DelphiGetMaxBufferSize (
  185.            aEffect        : pointer;
  186.            aSrcBufferSize : integer;
  187.            aDstBufferSize : pInteger) : integer; stdcall; export;
  188.  
  189. function DelphiSetParameter (
  190.            aEffect   : pointer;
  191.            aParamNum : integer;
  192.            aValue    : single)
  193.                      : integer; stdcall; export;
  194.  
  195. function DelphiGetParameter (
  196.            aEffect   : pointer;
  197.            aParamNum : integer)
  198.                      : single; stdcall; export;
  199.  
  200. function DelphiTransform (
  201.            aEffect    : pointer;
  202.            aInBuffer  : pointer;
  203.            aInSamples : integer;
  204.            aOutBuffer : pointer;
  205.            aOutSamples: integer;
  206.            aProcessed : pInteger)
  207.                       : integer; stdcall; export;
  208.  
  209. //function DelphiTransformInPlace (
  210. //           aEffect   : pointer;
  211. //           aBuffer   : pointer;
  212. //           aNumSamps : integer)
  213. //                     : integer; stdcall; export;
  214.  
  215. function DelphiGetEditorSize (
  216.            aEditorWidth  : PInteger;
  217.            aEditorHeight : PInteger)
  218.                          : integer; stdcall; export;
  219.  
  220. function DelphiCreateEditor (
  221.            aParentHandle : HWND;
  222.            aEditorHandle : Pointer;  {will be loaded with the handle of the created window}
  223.            aEditorPointer: Pointer)  {will be loaded with the pointer of our created window}
  224.                          : integer; stdcall; export;
  225.  
  226. function DelphiConnectEditor (
  227.            aEffect : pointer;
  228.            aEditor : Pointer)
  229.                    : integer; stdcall; export;
  230.  
  231. function DelphiFocusEditor (aEffect : pointer) : integer; stdcall; export;
  232.  
  233. implementation
  234.  
  235. {********* TDelphiDirectXPluginBase implementation ************}
  236.  
  237. constructor TDelphiDirectXPluginBase.create;
  238. begin
  239.   inherited create;
  240.   ChannelModes := [cmMonoToMono, cmMonoToStereo];
  241.   SampleTypes  := [stFloat32, stInteger16];
  242. end;
  243.  
  244. destructor TDelphiDirectXPluginBase.destroy;
  245. begin
  246.   inherited destroy;
  247. end;
  248.  
  249. function TDelphiDirectXPluginBase.GetParam (ndx: integer) : single;
  250. begin
  251.   result := fParamArray [ndx];
  252. end;
  253.  
  254. procedure TDelphiDirectXPluginBase.SetParam (ndx: integer; val: single);
  255. begin
  256.   fParamArray [ndx] := val;
  257. end;
  258.                   
  259. procedure TDelphiDirectXPluginBase.SetChannelModes (val: tChannelModes);
  260. begin
  261.   fChannelModes := val;
  262. end;
  263.  
  264. function  TDelphiDirectXPluginBase.GetChannelModes : tChannelModes;
  265. begin
  266.  result := fChannelModes;
  267. end;
  268.  
  269. procedure TDelphiDirectXPluginBase.SetSampleTypes  (val: tSampleTypes);
  270. begin
  271.   fSampleTypes := val;
  272. end;
  273.  
  274. function  TDelphiDirectXPluginBase.GetSampleTypes  : tSampleTypes;
  275. begin
  276.   result := fSampleTypes;
  277. end;
  278.  
  279. procedure DecodeWaveFormat (
  280.             aFormat : PWAVEFORMATEX;
  281.             var aSampleType : tSampleType;
  282.             var aNumChannels: integer;
  283.             var aSampleRate : integer);
  284. begin
  285.   aSampleType := stUnknown;
  286.   aNumChannels := 0;
  287.   with aFormat^ do begin
  288.     if (wFormatTag = WAVE_FORMAT_IEEE_FLOAT) and (wBitsPerSample = 32)
  289.       then aSampleType := stFloat32
  290.     else
  291.     if (wFormatTag = WAVE_FORMAT_PCM) and (wBitsPerSample = 16)
  292.       then aSampleType := stInteger16;
  293.     aNumChannels := nChannels;
  294.     aSampleRate  := nSamplesPerSec;
  295.   end;
  296. end;
  297.  
  298. function TDelphiDirectXPluginBase.CheckInputFormat (aFormat : PWAVEFORMATEX) : bool;
  299. var
  300.   SampType : tSampleType;
  301.   Channels : integer;
  302.   SampRate : integer;
  303. begin
  304.   {here is where we define what type of input we are prepared to accept}
  305.   {our approach here is to let the settings in out SampleTypes and ChannelModes
  306.    members do the work.}
  307.   DecodeWaveFormat (aFormat, SampType, Channels, SampRate);
  308.  
  309.   {check the sample type first}
  310.   result := (SampType in SampleTypes);
  311.  
  312.   {then go on and check the channels}
  313.   if result then begin
  314.     case Channels of
  315.       1  : result := (ChannelModes * [cmMonoToMono, cmMonoToStereo] <> []);
  316.       2  : result := (ChannelModes * [cmStereoToMono, cmStereoToStereo] <> []);
  317.       else result := false;
  318.     end;
  319.   end;
  320. end;
  321.  
  322. function TDelphiDirectXPluginBase.CheckOutputFormat (aFormat : PWAVEFORMATEX) : bool;
  323. var
  324.   SampType : tSampleType;
  325.   Channels : integer;
  326.   SampRate : integer;
  327. begin
  328.   {here is where we define what type of input we are prepared to write}
  329.   {to force stereo output from mono input, don't allow nChannels = 1}
  330.  
  331.   DecodeWaveFormat (aFormat, SampType, Channels, SampRate);
  332.  
  333.   {check the sample type first}
  334.   result := (SampType in SampleTypes);
  335.  
  336.   {then go on and check the channels}
  337.   if result then begin
  338.     case Channels of
  339.       1  : result := (ChannelModes * [cmMonoToMono, cmStereoToMono] <> []);
  340.       2  : result := (ChannelModes * [cmMonoToStereo, cmStereoToStereo] <> []);
  341.       else result := false;
  342.     end;
  343.   end;
  344. end;
  345.  
  346. function TDelphiDirectXPluginBase.CheckTransform (aInputFormat, aOutputFormat : PWAVEFORMATEX) : bool;
  347. var
  348.   InSampType  : tSampleType;
  349.   InChannels  : integer;
  350.   OutSampType : tSampleType;
  351.   OutChannels : integer;
  352.   InSampRate  : integer;
  353.   OutSampRate : integer;
  354. begin
  355.   {here is where we define what type of conversions we are prepareted to make}
  356.   {generally, we will only tolerate differences of number of channels,
  357.    ie for mono->stereo and stereo->mono}
  358.  
  359.   DecodeWaveFormat (aInputFormat,  InSampType,  InChannels,  InSampRate);
  360.   DecodeWaveFormat (aOutputFormat, OutSampType, OutChannels, OutSampRate);
  361.  
  362.   {we won't handle conversion of sample types or rates}
  363.   result := (InSampType = OutSampType) and (InSampRate = OutSampRate);
  364.  
  365.   {we have already checked that we handle both the input and output formats,
  366.    we only have to check that we can handle the relationship between them}
  367.   if result then begin
  368.     if (InChannels = 1) and (OutChannels = 1)
  369.       then result := cmMonoToMono in ChannelModes
  370.     else if (InChannels = 1) and (OutChannels = 2)
  371.       then result := cmMonoToStereo in ChannelModes
  372.     else if (InChannels = 2) and (OutChannels = 1)
  373.       then result := cmStereoToMono in ChannelModes
  374.     else if (InChannels = 2) and (OutChannels = 2)
  375.       then result := cmStereoToStereo in ChannelModes
  376.     else result := false;
  377.   end;
  378. end;
  379.  
  380. function TDelphiDirectXPluginBase.SetInputFormat (aFormat : PWAVEFORMATEX) : integer;
  381. begin
  382.   {keep track of what input format we will actually be using}
  383.   DecodeWaveFormat (aFormat,  fSampleType,  fInputChannels, fSampleRate);
  384.   result := 0;
  385. end;
  386.  
  387. function TDelphiDirectXPluginBase.SetOutputFormat (aFormat : PWAVEFORMATEX) : integer;
  388. begin
  389.   {keep track of what output format we will actually be using}
  390.   DecodeWaveFormat (aFormat,  fSampleType,  fOutputChannels, fSampleRate);
  391.   result := 0;
  392. end;
  393.  
  394. function TDelphiDirectXPluginBase.GetMaxBufferSize (
  395.        aSrcBufferSize : integer;
  396.        aDstBufferSize : pInteger) : integer;
  397. begin
  398.   aDstBufferSize^ := aSrcBufferSize;
  399.   result := 0;
  400. end;
  401.  
  402. function TDelphiDirectXPluginBase.SetParameter (
  403.            aParamNum : integer;
  404.            aValue    : single)
  405.                      : integer;
  406. begin
  407.   ParamArray [aParamNum] := avalue;
  408.   if fEditorForm <> nil then DisplaySetParameter (aParamNum, aValue);
  409.   result := 0;
  410. end;
  411.  
  412. function TDelphiDirectXPluginBase.GetParameter (aParamNum : integer) : single;
  413. begin
  414.   result := ParamArray [aParamNum];
  415. end;
  416.  
  417. function TDelphiDirectXPluginBase.BaseConnectEditor (aEditorForm : tForm) : integer;
  418. begin
  419.   fEditorForm := aEditorForm;
  420.   if fEditorForm <> nil then CompleteConnectEditor;
  421.   result := 0;
  422. end;
  423.  
  424. procedure TDelphiDirectXPluginBase.CompleteConnectEditor;
  425. begin
  426.   {nothing in base class}
  427. end;
  428.  
  429. function TDelphiDirectXPluginBase.FocusEditor : integer;
  430. var ctr : integer;
  431. begin
  432.   if fEditorForm <> nil then begin
  433.     for ctr := 0 to fEditorForm.controlcount-1 do
  434.       fEditorForm.controls [ctr].invalidate;
  435.   end;
  436.   result := 0;
  437. end;
  438.  
  439.  
  440. procedure TDelphiDirectXPluginBase.DisplaySetParameter (
  441.             aParamNum : integer;
  442.             aValue    : single);
  443. begin
  444.   {nothing in base class}
  445. end;
  446.  
  447. {********* end of TDelphiDirectXPluginBase implementation ************}
  448.  
  449.  
  450. {********* our internal (within-Delphi) registration of user user details ************ }
  451. type
  452.   TEffectRegistration = record
  453.     EffectName        : string;
  454.     EffectDesc        : string;
  455.     EffectHelpFile    : string;
  456.     PropertiesName    : string;
  457.     EffectGUID        : string;
  458.     PropertiesGUID    : string;
  459.     PluginClassRef    : TDelphiPluginClassRef;
  460.     EditorFormClassRef: TDelphiEditorFormClassRef;
  461.   end;
  462.  
  463. var
  464.   GlobalEffectRegistration : TEffectRegistration;
  465. const
  466.   GlobalEffectRegistered   : boolean = false;
  467.  
  468. procedure RegisterEffect (
  469.             aEffectName        : string;
  470.             aEffectDesc        : string;
  471.             aEffectHelpFile    : string;
  472.             aPropertiesName    : string;
  473.             aEffectGUID        : string;
  474.             aPropertiesGUID    : string;
  475.             aPluginClassRef    : TDelphiPluginClassRef;
  476.             aEditorFormClassRef: TDelphiEditorFormClassRef);
  477. begin
  478.   with GlobalEffectRegistration do begin
  479.     EffectName        := aEffectName;
  480.     EffectDesc        := aEffectDesc;
  481.     EffectHelpFile    := aEffectHelpFile;
  482.     PropertiesName    := aPropertiesName;
  483.     EffectGUID        := aEffectGUID;
  484.     PropertiesGUID    := aPropertiesGUID;
  485.     PluginClassRef    := aPluginClassRef;
  486.     EditorFormClassRef:= aEditorFormClassRef;
  487.   end;
  488.   GlobalEffectRegistered := true;
  489. end;
  490.  
  491. procedure AssertRegistered;
  492. begin
  493.   if not GlobalEffectRegistered then begin
  494.     ShowMessage ('YOu have not called RegisterEffect');
  495.     halt (1);
  496.   end;
  497. end;
  498.  
  499.  
  500. {********* procedural interface to the dll ************ }
  501.  
  502.  
  503.  
  504. function DelphiDDXSDKVersion : integer; stdcall; export;
  505. begin
  506.   result := DDX_SDK_Version;
  507. end;
  508.  
  509. function DelphiEffectCLSID (aGuid : pGuid) : integer; stdcall; export;
  510. begin
  511.   AssertRegistered;
  512.   aGUID^ := StringToGUID (GlobalEffectRegistration.EffectGUID);
  513.   result := 0;
  514. end;
  515.  
  516. function DelphiPropertiesCLSID (aGuid : pGuid) : integer; stdcall; export;
  517. begin
  518.   AssertRegistered;
  519.   aGUID^ := StringToGUID (GlobalEffectRegistration.PropertiesGUID);
  520.   result := 0;
  521. end;
  522.  
  523. function DelphiEffectName (aName : pchar; aMaxLen : integer) : integer; stdcall; export;
  524. begin
  525.   AssertRegistered;
  526.   StrPCopy (aName, copy (GlobalEffectRegistration.EffectName, 1, aMaxLen));
  527.   result := 0;
  528. end;
  529.  
  530. function DelphiEffectDesc (aName : pchar; aMaxLen : integer) : integer; stdcall; export;
  531. begin
  532.   AssertRegistered;
  533.   StrPCopy (aName, copy (GlobalEffectRegistration.EffectDesc, 1, aMaxLen));
  534.   result := 0;
  535. end;
  536.  
  537. function DelphiEffectHelpFile (aName : pchar; aMaxLen : integer) : integer; stdcall; export;
  538. begin
  539.   AssertRegistered;
  540.   StrPCopy (aName, copy (GlobalEffectRegistration.EffectHelpFile, 1, aMaxLen));
  541.   result := 0;
  542. end;
  543.  
  544. function DelphiPropertiesName (aName : pchar; aMaxLen : integer) : integer; stdcall; export;
  545. begin
  546.   AssertRegistered;
  547.   StrPCopy (aName, copy (GlobalEffectRegistration.PropertiesName, 1, aMaxLen));
  548.   result := 0;
  549. end;
  550.  
  551. function DelphiCreateEffect : pointer; stdcall; export;
  552. begin
  553.   AssertRegistered;
  554.   result := GlobalEffectRegistration.PluginClassRef.create;
  555. end;
  556.  
  557. function DelphiFreeEffect (aEffect : pointer) : integer; stdcall; export;
  558. begin
  559.   TDelphiDirectXPluginBase (aEffect).free;
  560.   result := 0;
  561. end;
  562.  
  563. function DelphiCheckInputFormat (aEffect : pointer; aFormat : PWAVEFORMATEX) : bool; stdcall; export;
  564. begin
  565.   result := TDelphiDirectXPluginBase (aEffect).CheckInputFormat (aFormat);
  566. end;
  567.  
  568. function DelphiCheckOutputFormat (aEffect : pointer; aFormat : PWAVEFORMATEX) : bool; stdcall; export;
  569. begin
  570.   result := TDelphiDirectXPluginBase (aEffect).CheckOutputFormat (aFormat);
  571. end;
  572.  
  573. function DelphiCheckTransform (aEffect : pointer; aInputFormat, aOutputFormat : PWAVEFORMATEX) : bool; stdcall; export;
  574. begin
  575.   result := TDelphiDirectXPluginBase (aEffect).CheckTransform (aInputFormat, aOutputFormat);
  576. end;
  577.  
  578. function DelphiSetInputFormat (aEffect : pointer; aFormat : PWAVEFORMATEX) : integer; stdcall; export;
  579. begin
  580.   result := TDelphiDirectXPluginBase (aEffect).SetInputFormat (aFormat);
  581. end;
  582.  
  583. function DelphiSetOutputFormat (aEffect : pointer; aFormat : PWAVEFORMATEX) : integer; stdcall; export;
  584. begin
  585.   result := TDelphiDirectXPluginBase (aEffect).SetOutputFormat (aFormat);
  586. end;
  587.  
  588. function DelphiGetMaxBufferSize (
  589.            aEffect        : pointer;
  590.            aSrcBufferSize : integer;
  591.            aDstBufferSize : pInteger) : integer; stdcall; export;
  592. begin
  593.   result := TDelphiDirectXPluginBase (aEffect).GetMaxBufferSize (aSrcBufferSize, aDstBufferSize);
  594. end;
  595.  
  596. function DelphiSetParameter (
  597.            aEffect   : pointer;
  598.            aParamNum : integer;
  599.            aValue    : single)
  600.                      : integer; stdcall; export;
  601. begin
  602. //showmessage (
  603. //  'DelphiSetParameter ' + inttostr (aParamNum) +
  604. //  ' to ' + floattostr (aValue));
  605.  
  606.   result := TDelphiDirectXPluginBase (aEffect).SetParameter (aParamNum, aValue);
  607. end;
  608.  
  609. function DelphiGetParameter (
  610.            aEffect   : pointer;
  611.            aParamNum : integer)
  612.                      : single; stdcall; export;
  613. begin
  614.   result := TDelphiDirectXPluginBase (aEffect).GetParameter (aParamNum);
  615. //showmessage (
  616. //  'DelphiGetParameter ' + inttostr (aParamNum) +
  617. //  ' returning ' + floattostr (result));
  618. end;
  619.  
  620.  
  621. function DelphiTransform (
  622.            aEffect    : pointer;
  623.            aInBuffer  : pointer;
  624.            aInSamples : integer;
  625.            aOutBuffer : pointer;
  626.            aOutSamples: integer;
  627.            aProcessed : pInteger)
  628.                       : integer; stdcall; export;
  629. begin
  630.   result := TDelphiDirectXPluginBase (aEffect).Transform (
  631.     aInBuffer, aInSamples, aOutBuffer, aOutSamples, aProcessed);
  632. end;
  633.  
  634.  
  635. //function DelphiTransformInPlace (
  636. //           aEffect   : pointer;
  637. //           aBuffer   : pointer;
  638. //           aNumSamps : integer)
  639. //                     : integer; stdcall; export;
  640. //begin
  641. //  result := TDelphiDirectXPluginBase (aEffect).TransformInPlace (aBuffer, aNumSamps);
  642. //end;
  643.  
  644. const
  645.   GlobEditorWidth : integer = -1;
  646.   GlobEditorHeight: integer = -1;
  647.  
  648. function DelphiGetEditorSize (
  649.            aEditorWidth  : PInteger;
  650.            aEditorHeight : PInteger)
  651.                          : integer; stdcall; export;
  652. var
  653.   vEditorForm : TForm;
  654. begin
  655.   if GlobEditorWidth = -1 then begin
  656.     vEditorForm := GlobalEffectRegistration.EditorFormClassRef.Create (nil);
  657.     try
  658.       vEditorForm.visible := false;
  659.       GlobEditorWidth     := vEditorForm.clientwidth;
  660.       GlobEditorHeight    := vEditorForm.clientheight;
  661.     finally
  662.       vEditorForm.free;
  663.     end;
  664.   end;
  665.   aEditorWidth^  := GlobEditorWidth;
  666.   aEditorHeight^ := GlobEditorHeight;
  667.   result := 0;
  668. end;
  669.  
  670. function DelphiCreateEditor (
  671.            aParentHandle : HWND;
  672.            aEditorHandle : Pointer;  {will be loaded with the handle of the created window}
  673.            aEditorPointer: Pointer)  {will be loaded with the pointer of our created window}
  674.                          : integer; stdcall; export;
  675. type
  676.   PHWND = ^HWND;
  677.   PFORM = ^TFORM;
  678. var
  679.   vEditorForm : TForm;
  680.   vHandle     : HWND;
  681. begin
  682.   AssertRegistered;
  683.   vEditorForm := GlobalEffectRegistration.EditorFormClassRef.CreateParented (aParentHandle);
  684.   vEditorForm.visible := false;
  685.   vEditorForm.top := 0;
  686.   vEditorForm.left:= 0;
  687.   vEditorForm.visible := true;
  688.  
  689.   vHandle := (vEditorForm as GlobalEffectRegistration.EditorFormClassRef).Handle;
  690.  
  691.   PHWND (aEditorHandle)^  := vHandle;
  692.   PFORM (aEditorPointer)^ := vEditorForm;
  693.   result := 0;
  694. end;
  695.  
  696. function DelphiConnectEditor (
  697.            aEffect : pointer;
  698.            aEditor : Pointer)
  699.                    : integer; stdcall; export;
  700. begin
  701.   result := TDelphiDirectXPluginBase (aEffect).BaseConnectEditor (aEditor);
  702. end;
  703.  
  704. function DelphiFocusEditor (aEffect : pointer) : integer; stdcall; export;
  705. begin
  706.   result := TDelphiDirectXPluginBase (aEffect).FocusEditor;
  707. end;
  708.  
  709. end.
  710.  
  711.