Стартовый пул
This commit is contained in:
3619
acs/Src/fileformats/windows/direct3d9.pas
Normal file
3619
acs/Src/fileformats/windows/direct3d9.pas
Normal file
File diff suppressed because it is too large
Load Diff
6340
acs/Src/fileformats/windows/directdraw.pas
Normal file
6340
acs/Src/fileformats/windows/directdraw.pas
Normal file
File diff suppressed because it is too large
Load Diff
32049
acs/Src/fileformats/windows/directshow9.pas
Normal file
32049
acs/Src/fileformats/windows/directshow9.pas
Normal file
File diff suppressed because it is too large
Load Diff
1821
acs/Src/fileformats/windows/directsound.pas
Normal file
1821
acs/Src/fileformats/windows/directsound.pas
Normal file
File diff suppressed because it is too large
Load Diff
29
acs/Src/fileformats/windows/directx.inc
Normal file
29
acs/Src/fileformats/windows/directx.inc
Normal file
@@ -0,0 +1,29 @@
|
||||
{******************************************************************************}
|
||||
{ }
|
||||
{ The contents of this file are subject to the Mozilla Public License Version }
|
||||
{ 1.1 (the "License"); you may not use this file except in compliance with the }
|
||||
{ License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ }
|
||||
{ }
|
||||
{ Software distributed under the License is distributed on an "AS IS" basis, }
|
||||
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
|
||||
{ the specific language governing rights and limitations under the License. }
|
||||
{ }
|
||||
{ The Original Code is DirectX.inc. }
|
||||
{ }
|
||||
{******************************************************************************}
|
||||
|
||||
// Borland compilers support
|
||||
{$INCLUDE Jedi.inc}
|
||||
|
||||
{$DEFINE TYPE_IDENTITY}
|
||||
{$DEFINE SUPPORTS_EXCEPTIONS}
|
||||
|
||||
// Additional settings
|
||||
{$MINENUMSIZE 4}
|
||||
{$ALIGN ON}
|
||||
|
||||
{$IFDEF COMPILER7_UP}
|
||||
{$WARN UNSAFE_CODE OFF}
|
||||
{$WARN UNSAFE_TYPE OFF}
|
||||
{$WARN UNSAFE_CAST OFF}
|
||||
{$ENDIF}
|
133
acs/Src/fileformats/windows/dxtypes.pas
Normal file
133
acs/Src/fileformats/windows/dxtypes.pas
Normal file
@@ -0,0 +1,133 @@
|
||||
{******************************************************************************}
|
||||
{* *}
|
||||
{* copyright (c) microsoft corporation. all rights reserved. *}
|
||||
{* *}
|
||||
{* files: dxsdkver.h, extracts from various directx sdk include files *}
|
||||
{* content: directx 9.0 headers common types *}
|
||||
{* *}
|
||||
{* directx 9.0 delphi / freepascal adaptation by alexey barkovoy *}
|
||||
{* e-mail: directx@clootie.ru *}
|
||||
{* *}
|
||||
{* latest version can be downloaded from: *}
|
||||
{* http://www.clootie.ru *}
|
||||
{* http://sourceforge.net/projects/delphi-dx9sdk *}
|
||||
{* *}
|
||||
{*----------------------------------------------------------------------------*}
|
||||
{* $id: dxtypes.pas,v 1.1 2005/09/12 22:04:53 z0m3ie exp $ }
|
||||
{******************************************************************************}
|
||||
{ }
|
||||
{ the contents of this file are used with permission, subject to the mozilla }
|
||||
{ public license version 1.1 (the "license"); you may not use this file except }
|
||||
{ in compliance with the license. you may obtain a copy of the license at }
|
||||
{ http://www.mozilla.org/mpl/mpl-1.1.html }
|
||||
{ }
|
||||
{ software distributed under the license is distributed on an "as is" basis, }
|
||||
{ without warranty of any kind, either express or implied. see the license for }
|
||||
{ the specific language governing rights and limitations under the license. }
|
||||
{ }
|
||||
{ alternatively, the contents of this file may be used under the terms of the }
|
||||
{ gnu lesser general public license (the "lgpl license"), in which case the }
|
||||
{ provisions of the lgpl license are applicable instead of those above. }
|
||||
{ if you wish to allow use of your version of this file only under the terms }
|
||||
{ of the lgpl license and not to allow others to use your version of this file }
|
||||
{ under the mpl, indicate your decision by deleting the provisions above and }
|
||||
{ replace them with the notice and other provisions required by the lgpl }
|
||||
{ license. if you do not delete the provisions above, a recipient may use }
|
||||
{ your version of this file under either the mpl or the lgpl license. }
|
||||
{ }
|
||||
{ for more information about the lgpl: http://www.gnu.org/copyleft/lesser.html }
|
||||
{ }
|
||||
{******************************************************************************}
|
||||
|
||||
{.$I DirectX.inc}
|
||||
|
||||
unit dxtypes;
|
||||
|
||||
interface
|
||||
|
||||
|
||||
uses windows;
|
||||
|
||||
(*==========================================================================;
|
||||
*
|
||||
* File: dxsdkver.h
|
||||
* Content: DirectX SDK Version Include File
|
||||
*
|
||||
****************************************************************************)
|
||||
const
|
||||
_DXSDK_PRODUCT_MAJOR = 9;
|
||||
_DXSDK_PRODUCT_MINOR = 08;
|
||||
_DXSDK_BUILD_MAJOR = 299;
|
||||
_DXSDK_BUILD_MINOR = 0000;
|
||||
|
||||
|
||||
|
||||
(****************************************************************************
|
||||
* Other files
|
||||
****************************************************************************)
|
||||
type
|
||||
// TD3DValue is the fundamental Direct3D fractional data type
|
||||
D3DVALUE = Single;
|
||||
TD3DValue = D3DVALUE;
|
||||
PD3DValue = ^TD3DValue;
|
||||
|
||||
D3DCOLOR = DWord;
|
||||
TD3DColor = D3DCOLOR;
|
||||
PD3DColor = ^TD3DColor;
|
||||
|
||||
_D3DVECTOR = packed record
|
||||
x: Single;
|
||||
y: Single;
|
||||
z: Single;
|
||||
end {_D3DVECTOR};
|
||||
D3DVECTOR = _D3DVECTOR;
|
||||
TD3DVector = _D3DVECTOR;
|
||||
PD3DVector = ^TD3DVector;
|
||||
|
||||
REFERENCE_TIME = LONGLONG;
|
||||
TReferenceTime = REFERENCE_TIME;
|
||||
PReferenceTime = ^TReferenceTime;
|
||||
|
||||
|
||||
// ==================================================================
|
||||
// Here comes generic Windows types for Win32 / Win64 compatibility
|
||||
//
|
||||
|
||||
//
|
||||
// The INT_PTR is guaranteed to be the same size as a pointer. Its
|
||||
// size with change with pointer size (32/64). It should be used
|
||||
// anywhere that a pointer is cast to an integer type. UINT_PTR is
|
||||
// the unsigned variation.
|
||||
//
|
||||
{$IFDEF WIN64}
|
||||
INT_PTR = Int64;
|
||||
UINT_PTR = Int64; // not yet: UInt64;
|
||||
LONG_PTR = Int64;
|
||||
ULONG_PTR = Int64; // not yet: UInt64;
|
||||
DWORD_PTR = Int64; // not yet: UInt64;
|
||||
{$ELSE}
|
||||
INT_PTR = Longint;
|
||||
UINT_PTR = Longword;
|
||||
LONG_PTR = Longint;
|
||||
ULONG_PTR = Longword;
|
||||
DWORD_PTR = Longword;
|
||||
{$ENDIF}
|
||||
PINT_PTR = ^INT_PTR;
|
||||
PUINT_PTR = ^UINT_PTR;
|
||||
PLONG_PTR = ^LONG_PTR;
|
||||
PULONG_PTR = ^ULONG_PTR;
|
||||
|
||||
|
||||
//
|
||||
// SIZE_T used for counts or ranges which need to span the range of
|
||||
// of a pointer. SSIZE_T is the signed variation.
|
||||
//
|
||||
SIZE_T = ULONG_PTR;
|
||||
SSIZE_T = LONG_PTR;
|
||||
PSIZE_T = ^SIZE_T;
|
||||
PSSIZE_T = ^SSIZE_T;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
578
acs/Src/fileformats/windows/jedi.inc
Normal file
578
acs/Src/fileformats/windows/jedi.inc
Normal file
@@ -0,0 +1,578 @@
|
||||
{******************************************************************************}
|
||||
{ }
|
||||
{ The contents of this file are subject to the Mozilla Public License Version }
|
||||
{ 1.1 (the "License"); you may not use this file except in compliance with the }
|
||||
{ License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ }
|
||||
{ }
|
||||
{ Software distributed under the License is distributed on an "AS IS" basis, }
|
||||
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
|
||||
{ the specific language governing rights and limitations under the License. }
|
||||
{ }
|
||||
{ The Original Code is JEDI.INC. }
|
||||
{ }
|
||||
{ The Initial Developer of the Original Code is Project JEDI }
|
||||
{ http://www.delphi-jedi.org }
|
||||
{ }
|
||||
{******************************************************************************}
|
||||
{ }
|
||||
{ This file defines various generic compiler directives used in the JEDI Code }
|
||||
{ Library (JCL) and JEDI Visual Component Library Library (J-VCL). The }
|
||||
{ directives in this file are of generic nature and consist mostly of mappings }
|
||||
{ from the VERXXX directives defined by Delphi and C++ Builder to friendly }
|
||||
{ names such as DELPHI5 and SUPPORTS_WIDESTRING. These friendly names are }
|
||||
{ subsequently used in both libraries to test for compiler versions and/or }
|
||||
{ whether the compiler supports certain features (such as widestring's or 64 }
|
||||
{ bit integers. Both libraries provide an additional, library specific, }
|
||||
{ include file. For the JCL this is JCL.INC. These files should be included in }
|
||||
{ source files instead of this file (which is pulled in automatically). }
|
||||
{ }
|
||||
{ Maintainer: Marcel van Brakel }
|
||||
{ Last modified: May 25, 2002 }
|
||||
{ }
|
||||
{******************************************************************************}
|
||||
|
||||
(*
|
||||
|
||||
- Development environment directives
|
||||
|
||||
This file defines two driectives to indicate which development environment the
|
||||
library is being compiled with. Currently this can either be Delphi or
|
||||
C++ Builder (in the near future "Kylix" will be added).
|
||||
|
||||
Directive Description
|
||||
------------------------------------------------------------------------------
|
||||
DELPHI Defined if compiled with Delphi
|
||||
CBUILDER Defined if compiled with C++ Builder
|
||||
|
||||
- Platform Directives
|
||||
|
||||
Platform directives are not explicitly defined in this file but are defined
|
||||
by the compiler itself. They are listed here only for completeness.
|
||||
|
||||
Directive Description
|
||||
------------------------------------------------------------------------------
|
||||
WIN32 Defined when target platform is 32 bit Windows
|
||||
LINUX Defined when target platform is Linux
|
||||
|
||||
- Delphi Versions
|
||||
|
||||
The following directives are direct mappings from the VERXXX directives to a
|
||||
friendly name of the associated compiler. These directives are only defined if
|
||||
the compiler is Delphi (ie DELPHI is defined).
|
||||
|
||||
Directive Description
|
||||
------------------------------------------------------------------------------
|
||||
DELPHI1 Defined when compiling with Delphi 1
|
||||
DELPHI2 Defined when compiling with Delphi 2
|
||||
DELPHI3 Defined when compiling with Delphi 3
|
||||
DELPHI4 Defined when compiling with Delphi 4
|
||||
DELPHI5 Defined when compiling with Delphi 5
|
||||
DELPHI6 Defined when compiling with Delphi 6
|
||||
DELPHI7 Defined when compiling with Delphi 7
|
||||
DELPHI8 Defined when compiling with Delphi 8
|
||||
DELPHI9 Defined when compiling with Delphi 9
|
||||
DELPHI1_UP Defined when compiling with Delphi 1 or higher
|
||||
DELPHI2_UP Defined when compiling with Delphi 2 or higher
|
||||
DELPHI3_UP Defined when compiling with Delphi 3 or higher
|
||||
DELPHI4_UP Defined when compiling with Delphi 4 or higher
|
||||
DELPHI5_UP Defined when compiling with Delphi 5 or higher
|
||||
DELPHI6_UP Defined when compiling with Delphi 6 or higher
|
||||
DELPHI7_UP Defined when compiling with Delphi 7 or higher
|
||||
DELPHI8_UP Defined when compiling with Delphi 8 or higher
|
||||
DELPHI9_UP Defined when compiling with Delphi 9 or higher
|
||||
|
||||
- C++ Builder Versions
|
||||
|
||||
The following directives are direct mappings from the VERXXX directives to a
|
||||
friendly name of the associated compiler. These directives are only defined if
|
||||
the compiler is C++ Builder (ie BCB is defined).
|
||||
|
||||
Directive Description
|
||||
------------------------------------------------------------------------------
|
||||
BCB1 Defined when compiling with C++ Builder 1
|
||||
BCB3 Defined when compiling with C++ Builder 3
|
||||
BCB4 Defined when compiling with C++ Builder 4
|
||||
BCB5 Defined when compiling with C++ Builder 5
|
||||
BCB6 Defined when compiling with C++ Builder 6
|
||||
BCB7 Defined when compiling with C++ Builder 7
|
||||
BCB1_UP Defined when compiling with C++ Builder 1 or higher
|
||||
BCB3_UP Defined when compiling with C++ Builder 3 or higher
|
||||
BCB4_UP Defined when compiling with C++ Builder 4 or higher
|
||||
BCB5_UP Defined when compiling with C++ Builder 5 or higher
|
||||
BCB6_UP Defined when compiling with C++ Builder 6 or higher
|
||||
BCB7_UP Defined when compiling with C++ Builder 7 or higher
|
||||
|
||||
- Compiler Versions
|
||||
|
||||
The following directives are direct mappings from the VERXXX directives to a
|
||||
friendly name of the associated compiler. Unlike the DELPHI_X and BCB_X
|
||||
directives, these directives are indepedent of the development environment.
|
||||
That is, they are defined regardless of whether compilation takes place using
|
||||
Delphi or C++ Builder.
|
||||
|
||||
Directive Description
|
||||
------------------------------------------------------------------------------
|
||||
COMPILER1 Defined when compiling with Delphi 1
|
||||
COMPILER2 Defined when compiling with Delphi 2 or C++ Builder 1
|
||||
COMPILER3 Defined when compiling with Delphi 3
|
||||
COMPILER35 Defined when compiling with C++ Builder 3
|
||||
COMPILER4 Defined when compiling with Delphi 4 or C++ Builder 4
|
||||
COMPILER5 Defined when compiling with Delphi 5 or C++ Builder 5
|
||||
COMPILER6 Defined when compiling with Delphi 6 or C++ Builder 6
|
||||
COMPILER1_UP Defined when compiling with Delphi 1 or higher
|
||||
COMPILER2_UP Defined when compiling with Delphi 2 or C++ Builder 1 or higher
|
||||
COMPILER3_UP Defined when compiling with Delphi 3 or higher
|
||||
COMPILER35_UP Defined when compiling with C++ Builder 3 or higher
|
||||
COMPILER4_UP Defined when compiling with Delphi 4 or C++ Builder 4 or higher
|
||||
COMPILER5_UP Defined when compiling with Delphi 5 or C++ Builder 5 or higher
|
||||
COMPILER6_UP Defined when compiling with Delphi 6 or C++ Builder 6 or higher
|
||||
COMPILER7_UP Defined when compiling with Delphi 6 or C++ Builder 6 or higher
|
||||
|
||||
- Feature Directives
|
||||
|
||||
The features directives are used to test if the compiler supports specific
|
||||
features, such as method overloading, and adjust the sources accordingly. Use
|
||||
of these directives is preferred over the use of the DELPHI and COMPILER
|
||||
directives.
|
||||
|
||||
Directive Description
|
||||
------------------------------------------------------------------------------
|
||||
SUPPORTS_WIDESTRING Compiler supports the WideString type (D3/BCB3 up)
|
||||
SUPPORTS_INTERFACE Compiler supports interfaces (D3/BCB3)
|
||||
SUPPORTS_EXTSYM Compiler supports the $EXTERNALSYM directive (D4/BCB3)
|
||||
SUPPORTS_NODEFINE Compiler supports the $NODEFINE directive (D4/BCB3)
|
||||
SUPPORTS_INT64 Compiler supports the Int64 type (D4/BCB4)
|
||||
SUPPORTS_DYNAMICARRAYS Compiler supports dynamic arrays (D4/BCB4)
|
||||
SUPPORTS_DEFAULTPARAMS Compiler supports default parameters (D4/BCB4)
|
||||
SUPPORTS_OVERLOAD Compiler supports overloading (D4/BCB4)
|
||||
SUPPORTS_INLINE Compiler supports inline directive (D9)
|
||||
|
||||
- Compiler Settings
|
||||
|
||||
The compiler settings directives indicate whether a specific compiler setting
|
||||
is in effect. This facilitates changing compiler settings locally in a more
|
||||
compact and readible manner.
|
||||
|
||||
Directive Description
|
||||
------------------------------------------------------------------------------
|
||||
ALIGN_ON Compiling in the A+ state (no alignment)
|
||||
BOOLEVAL_ON Compiling in the B+ state (complete boolean evaluation)
|
||||
ASSERTIONS_ON Compiling in the C+ state (assertions on)
|
||||
DEBUGINFO_ON Compiling in the D+ state (debug info generation on)
|
||||
IMPORTEDDATA_ON Compiling in the G+ state (creation of imported data references)
|
||||
LONGSTRINGS_ON Compiling in the H+ state (string defined as AnsiString)
|
||||
IOCHECKS_ON Compiling in the I+ state (I/O checking enabled)
|
||||
WRITEABLECONST_ON Compiling in the J+ state (typed constants can be modified)
|
||||
LOCALSYMBOLS Compiling in the L+ state (local symbol generation)
|
||||
TYPEINFO_ON Compiling in the M+ state (RTTI generation on)
|
||||
OPTIMIZATION_ON Compiling in the O+ state (code optimization on)
|
||||
OPENSTRINGS_ON Compiling in the P+ state (variable string parameters are openstrings)
|
||||
OVERFLOWCHECKS_ON Compiling in the Q+ state (overflow checing on)
|
||||
RANGECHECKS_ON Compiling in the R+ state (range checking on)
|
||||
TYPEDADDRESS_ON Compiling in the T+ state (pointers obtained using the @ operator are typed)
|
||||
SAFEDIVIDE_ON Compiling in the U+ state (save FDIV instruction through RTL emulation)
|
||||
VARSTRINGCHECKS_ON Compiling in the V+ state (type checking of shortstrings)
|
||||
STACKFRAMES_ON Compiling in the W+ state (generation of stack frames)
|
||||
EXTENDEDSYNTAX_ON Compiling in the X+ state (Delphi extended syntax enabled)
|
||||
|
||||
*)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Compiler settings
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
{$IFOPT A+} {$DEFINE ALIGN_ON} {$ENDIF}
|
||||
{$IFOPT B+} {$DEFINE BOOLEVAL_ON} {$ENDIF}
|
||||
{$IFOPT C+} {$DEFINE ASSERTIONS_ON} {$ENDIF}
|
||||
{$IFOPT D+} {$DEFINE DEBUGINFO_ON} {$ENDIF}
|
||||
{$IFOPT G+} {$DEFINE IMPORTEDDATA_ON} {$ENDIF}
|
||||
{$IFOPT H+} {$DEFINE LONGSTRINGS_ON} {$ENDIF}
|
||||
//HINTS
|
||||
{$IFOPT I+} {$DEFINE IOCHECKS_ON} {$ENDIF}
|
||||
{$IFOPT J+} {$DEFINE WRITEABLECONST_ON} {$ENDIF}
|
||||
{$IFOPT L+} {$DEFINE LOCALSYMBOLS} {$ENDIF}
|
||||
{$IFOPT M+} {$DEFINE TYPEINFO_ON} {$ENDIF}
|
||||
{$IFOPT O+} {$DEFINE OPTIMIZATION_ON} {$ENDIF}
|
||||
{$IFOPT P+} {$DEFINE OPENSTRINGS_ON} {$ENDIF}
|
||||
{$IFOPT Q+} {$DEFINE OVERFLOWCHECKS_ON} {$ENDIF}
|
||||
{$IFOPT R+} {$DEFINE RANGECHECKS_ON} {$ENDIF}
|
||||
//REALCOMPATIBILITY
|
||||
{$IFOPT T+} {$DEFINE TYPEDADDRESS_ON} {$ENDIF}
|
||||
{$IFOPT U+} {$DEFINE SAFEDIVIDE_ON} {$ENDIF}
|
||||
{$IFOPT V+} {$DEFINE VARSTRINGCHECKS_ON} {$ENDIF}
|
||||
{$IFOPT W+} {$DEFINE STACKFRAMES_ON} {$ENDIF}
|
||||
//WARNINGS
|
||||
{$IFOPT X+} {$DEFINE EXTENDEDSYNTAX_ON} {$ENDIF}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// VERXXX to COMPILERX, DELPHIX and BCBX mappings
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
{$IFDEF VER170}
|
||||
{$DEFINE COMPILER9}
|
||||
{$IFDEF BCB}
|
||||
{$DEFINE BCB9}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ELSE}
|
||||
{$DEFINE DELPHI9}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER160}
|
||||
{$DEFINE COMPILER8}
|
||||
{$IFDEF BCB}
|
||||
{$DEFINE BCB8}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ELSE}
|
||||
{$DEFINE DELPHI8}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER150}
|
||||
{$DEFINE COMPILER7}
|
||||
{$IFDEF BCB}
|
||||
{$DEFINE BCB7}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ELSE}
|
||||
{$DEFINE DELPHI7}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER140}
|
||||
{$DEFINE COMPILER6}
|
||||
{$IFDEF BCB}
|
||||
{$DEFINE BCB6}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ELSE}
|
||||
{$DEFINE DELPHI6}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER130}
|
||||
{$DEFINE COMPILER5}
|
||||
{$IFDEF BCB}
|
||||
{$DEFINE BCB5}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ELSE}
|
||||
{$DEFINE DELPHI5}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER125}
|
||||
{$DEFINE COMPILER4}
|
||||
{$DEFINE BCB4}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER120}
|
||||
{$DEFINE COMPILER4}
|
||||
{$DEFINE DELPHI4}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER110}
|
||||
{$DEFINE COMPILER35}
|
||||
{$DEFINE BCB3}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER100}
|
||||
{$DEFINE COMPILER3}
|
||||
{$DEFINE DELPHI3}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER93}
|
||||
{$DEFINE COMPILER2}
|
||||
{$DEFINE BCB1}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER90}
|
||||
{$DEFINE COMPILER2}
|
||||
{$DEFINE DELPHI2}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER80}
|
||||
{$DEFINE COMPILER1}
|
||||
{$DEFINE DELPHI1}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// DELPHIX_UP from DELPHIX mappings
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
{$IFDEF DELPHI9}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI4_UP}
|
||||
{$DEFINE DELPHI3_UP}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI8}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI4_UP}
|
||||
{$DEFINE DELPHI3_UP}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI7}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI4_UP}
|
||||
{$DEFINE DELPHI3_UP}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI6}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI4_UP}
|
||||
{$DEFINE DELPHI3_UP}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI5}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI4_UP}
|
||||
{$DEFINE DELPHI3_UP}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI4}
|
||||
{$DEFINE DELPHI4_UP}
|
||||
{$DEFINE DELPHI3_UP}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI3}
|
||||
{$DEFINE DELPHI3_UP}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI2}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI1}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// BCBX_UP from BCBX mappings
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
{$IFDEF BCB9}
|
||||
{$DEFINE BCB9_UP}
|
||||
{$DEFINE BCB8_UP}
|
||||
{$DEFINE BCB7_UP}
|
||||
{$DEFINE BCB6_UP}
|
||||
{$DEFINE BCB5_UP}
|
||||
{$DEFINE BCB4_UP}
|
||||
{$DEFINE BCB3_UP}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF BCB8}
|
||||
{$DEFINE BCB8_UP}
|
||||
{$DEFINE BCB7_UP}
|
||||
{$DEFINE BCB6_UP}
|
||||
{$DEFINE BCB5_UP}
|
||||
{$DEFINE BCB4_UP}
|
||||
{$DEFINE BCB3_UP}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF BCB7}
|
||||
{$DEFINE BCB7_UP}
|
||||
{$DEFINE BCB6_UP}
|
||||
{$DEFINE BCB5_UP}
|
||||
{$DEFINE BCB4_UP}
|
||||
{$DEFINE BCB3_UP}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF BCB6}
|
||||
{$DEFINE BCB6_UP}
|
||||
{$DEFINE BCB5_UP}
|
||||
{$DEFINE BCB4_UP}
|
||||
{$DEFINE BCB3_UP}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF BCB5}
|
||||
{$DEFINE BCB5_UP}
|
||||
{$DEFINE BCB4_UP}
|
||||
{$DEFINE BCB3_UP}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF BCB4}
|
||||
{$DEFINE BCB4_UP}
|
||||
{$DEFINE BCB3_UP}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF BCB3}
|
||||
{$DEFINE BCB3_UP}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF BCB1}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// COMPILERX_UP from COMPILERX mappings
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
{$IFDEF COMPILER9}
|
||||
{$DEFINE COMPILER9_UP}
|
||||
{$DEFINE COMPILER8_UP}
|
||||
{$DEFINE COMPILER7_UP}
|
||||
{$DEFINE COMPILER6_UP}
|
||||
{$DEFINE COMPILER5_UP}
|
||||
{$DEFINE COMPILER4_UP}
|
||||
{$DEFINE COMPILER35_UP}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER8}
|
||||
{$DEFINE COMPILER8_UP}
|
||||
{$DEFINE COMPILER7_UP}
|
||||
{$DEFINE COMPILER6_UP}
|
||||
{$DEFINE COMPILER5_UP}
|
||||
{$DEFINE COMPILER4_UP}
|
||||
{$DEFINE COMPILER35_UP}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER7}
|
||||
{$DEFINE COMPILER7_UP}
|
||||
{$DEFINE COMPILER6_UP}
|
||||
{$DEFINE COMPILER5_UP}
|
||||
{$DEFINE COMPILER4_UP}
|
||||
{$DEFINE COMPILER35_UP}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER6}
|
||||
{$DEFINE COMPILER6_UP}
|
||||
{$DEFINE COMPILER5_UP}
|
||||
{$DEFINE COMPILER4_UP}
|
||||
{$DEFINE COMPILER35_UP}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER5}
|
||||
{$DEFINE COMPILER5_UP}
|
||||
{$DEFINE COMPILER4_UP}
|
||||
{$DEFINE COMPILER35_UP}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER4}
|
||||
{$DEFINE COMPILER4_UP}
|
||||
{$DEFINE COMPILER35_UP}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER35}
|
||||
{$DEFINE COMPILER35_UP}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER3}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER2}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER1}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Map COMPILERX_UP to friendly feature names
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
{$IFDEF COMPILER3_UP}
|
||||
{$DEFINE SUPPORTS_WIDESTRING}
|
||||
{$DEFINE SUPPORTS_INTERFACE}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER35_UP}
|
||||
{$DEFINE SUPPORTS_EXTSYM}
|
||||
{$DEFINE SUPPORTS_NODEFINE}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER4_UP}
|
||||
{$DEFINE SUPPORTS_INT64}
|
||||
{$DEFINE SUPPORTS_DYNAMICARRAYS}
|
||||
{$DEFINE SUPPORTS_DEFAULTPARAMS}
|
||||
{$DEFINE SUPPORTS_OVERLOAD}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER9_UP}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$ENDIF}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Cross-platform related defines
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
{$IFDEF WIN32}
|
||||
{$DEFINE MSWINDOWS}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
{$DEFINE UNIX}
|
||||
{$DEFINE COMPLIB_CLX}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF COMPLIB_CLX}
|
||||
{$DEFINE COMPLIB_VCL}
|
||||
{$ENDIF}
|
1200
acs/Src/fileformats/windows/macdll.pas
Normal file
1200
acs/Src/fileformats/windows/macdll.pas
Normal file
File diff suppressed because it is too large
Load Diff
290
acs/Src/fileformats/windows/mad.pas
Normal file
290
acs/Src/fileformats/windows/mad.pas
Normal file
@@ -0,0 +1,290 @@
|
||||
(*
|
||||
this file is a part of audio components suite v 2.3 (delphi version).
|
||||
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
|
||||
see the license file for more details.
|
||||
you can contact me at acs@compiler4.net
|
||||
this is the acs for delphi (windows) version of the unit.
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: mad.pas,v $
|
||||
Revision 1.1 2005/12/19 18:36:49 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:53 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.1 2005/08/25 20:18:00 z0m3ie
|
||||
Version 2.4 restructure
|
||||
TCDPlayer removed (fits not in component structure)
|
||||
TMP3ToWavConverter removed (fits not in component structure)
|
||||
|
||||
Revision 1.2 2005/08/22 20:17:02 z0m3ie
|
||||
changed Headers to log
|
||||
changed mail adress
|
||||
|
||||
}
|
||||
|
||||
unit mad;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
|
||||
{$IFDEF WIN32}
|
||||
Windows;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
baseunix, ACS_Procs;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
const
|
||||
|
||||
{$IFDEF WIN32}
|
||||
MADLibPath = 'MADLib.dll';
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
MADLibPath = 'libmad.so*'; // libmad.so
|
||||
{$DEFINE SEARCH_LIBS}
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
var
|
||||
|
||||
MADLibLoaded : Boolean = False;
|
||||
|
||||
type
|
||||
|
||||
mad_bitptr = packed record
|
||||
b : PChar;
|
||||
Cache, Left : Word;
|
||||
end;
|
||||
|
||||
mad_stream = packed record
|
||||
buffer : Pointer;
|
||||
bufend : Pointer;
|
||||
skiplen : LongWord;
|
||||
sync : Integer;
|
||||
freerate : LongWord;
|
||||
this_frame : Pointer;
|
||||
next_frame : Pointer;
|
||||
ptr : mad_bitptr;
|
||||
anc_ptr : mad_bitptr;
|
||||
anc_bitlen : LongWord;
|
||||
main_data : Pointer;
|
||||
md_len : LongWord;
|
||||
options : Integer;
|
||||
error : Integer;
|
||||
end;
|
||||
|
||||
p_mad_stream = ^mad_stream;
|
||||
|
||||
mad_timer_t = packed record
|
||||
seconds : Integer;
|
||||
fraction : LongWord;
|
||||
end;
|
||||
|
||||
mad_header = packed record
|
||||
layer : Integer;
|
||||
mode : Integer;
|
||||
mode_extension : Integer;
|
||||
emphasis : Integer;
|
||||
bitrate : LongWord;
|
||||
samplerate : LongWord;
|
||||
crc_check : Word;
|
||||
crc_target : Word;
|
||||
flags : Integer;
|
||||
private_bits : Integer;
|
||||
duration : mad_timer_t;
|
||||
end;
|
||||
|
||||
p_mad_header = ^mad_header;
|
||||
|
||||
mad_frame = packed record
|
||||
header : mad_header;
|
||||
options : Integer;
|
||||
sbsample : packed array[0..1, 0..35, 0..31] of Integer;
|
||||
overlap : Pointer;
|
||||
end;
|
||||
|
||||
p_mad_frame = ^mad_frame;
|
||||
|
||||
mad_pcm = packed record
|
||||
samplerate : LongWord;
|
||||
channels : Word;
|
||||
length : Word;
|
||||
samples : packed array [0..1, 0..1151] of Integer;
|
||||
end;
|
||||
|
||||
p_mad_pcm = ^mad_pcm;
|
||||
|
||||
mad_synth = packed record
|
||||
filter : array[0..1, 0..1, 0..1, 0..15, 0..7] of Integer;
|
||||
phase : LongWord;
|
||||
pcm : mad_pcm;
|
||||
end;
|
||||
|
||||
async_struct = packed record
|
||||
pid : LongWord;
|
||||
_in : Integer;
|
||||
_out : Integer;
|
||||
end;
|
||||
|
||||
sync_struct = packed record
|
||||
stream : mad_stream;
|
||||
frame : mad_frame;
|
||||
synth : mad_synth;
|
||||
end;
|
||||
|
||||
p_sync_struct = ^sync_struct;
|
||||
|
||||
TInputFunc = function(CData : Pointer; Stream : p_mad_stream) : Integer; cdecl;
|
||||
THeaderFunc = function(CData : Pointer; Header : p_mad_header) : Integer; cdecl;
|
||||
TFilterFunc = function(CData : Pointer; Frame : p_mad_frame) : Integer; cdecl;
|
||||
TOutputFunc = function(CData : Pointer; Header : p_mad_header; pcm : p_mad_pcm) : Integer; cdecl;
|
||||
TErrorFunc = function(CData : Pointer; Stream : p_mad_stream; Frame : p_mad_frame) : Integer; cdecl;
|
||||
TMessageFunc = function(P1, P2 : Pointer; var l : LongWord) : Integer; cdecl;
|
||||
|
||||
mad_decoder = packed record
|
||||
mode : Integer;
|
||||
options : Integer;
|
||||
async : async_struct;
|
||||
sync : p_sync_struct;
|
||||
data : Pointer;
|
||||
InputFunc : TInputFunc;
|
||||
HeaderFunc : THeaderFunc;
|
||||
FilterFunc : TFilterFunc;
|
||||
OutputFunc : TOutputFunc;
|
||||
ErrorFunc : TErrorFunc;
|
||||
MessageFunc : TMessageFunc;
|
||||
end;
|
||||
|
||||
p_mad_decoder = ^mad_decoder;
|
||||
|
||||
const
|
||||
|
||||
MAD_F_FRACBITS = 28;
|
||||
MAD_F_ONE = $10000000;
|
||||
|
||||
MAD_FLOW_CONTINUE = $0;
|
||||
MAD_FLOW_STOP = $10;
|
||||
MAD_FLOW_BREAK = $11;
|
||||
MAD_FLOW_IGNORE = $20;
|
||||
|
||||
MAD_DECODER_MODE_SYNC = 0;
|
||||
MAD_DECODER_MODE_ASYNC = 1;
|
||||
|
||||
type
|
||||
|
||||
mad_decoder_init_t = procedure(mad_decoder : p_mad_decoder; CData : Pointer;
|
||||
InputFunc : TInputFunc;
|
||||
HeaderFunc : THeaderFunc;
|
||||
FilterFunc : TFilterFunc;
|
||||
OutputFunc : TOutputFunc;
|
||||
ErrorFunc : TErrorFunc;
|
||||
MessageFunc : TMessageFunc); cdecl;
|
||||
|
||||
mad_decoder_finish_t = function(mad_decoder : p_mad_decoder) : Integer; cdecl;
|
||||
|
||||
mad_decoder_run_t = function(mad_decoder : p_mad_decoder; mad_decoder_mode : Integer) : Integer; cdecl;
|
||||
|
||||
mad_decoder_message_t = function(mad_decoder : p_mad_decoder; P : Pointer; var l : LongWord) : Integer; cdecl;
|
||||
|
||||
mad_stream_buffer_t = procedure(MadStream : p_mad_stream; Data : Pointer; l : LongWord); cdecl;
|
||||
|
||||
mad_stream_skip_t = procedure(MadStream : p_mad_stream; Skip : LongWord); cdecl;
|
||||
|
||||
mad_stream_sync_t = function(MadStream : p_mad_stream) : Integer; cdecl;
|
||||
|
||||
var
|
||||
|
||||
mad_decoder_init: mad_decoder_init_t;
|
||||
mad_decoder_finish : mad_decoder_finish_t;
|
||||
mad_decoder_run : mad_decoder_run_t;
|
||||
mad_decoder_message : mad_decoder_message_t;
|
||||
mad_stream_buffer : mad_stream_buffer_t;
|
||||
mad_stream_skip : mad_stream_skip_t;
|
||||
mad_stream_sync : mad_stream_sync_t;
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
{$IFDEF WIN32}
|
||||
|
||||
var
|
||||
Libhandle : HMODULE;
|
||||
|
||||
initialization
|
||||
|
||||
Libhandle := LoadLibraryEx(MADLibPath, 0, 0);
|
||||
|
||||
if Libhandle <> 0 then
|
||||
begin
|
||||
MADLibLoaded := True;
|
||||
|
||||
mad_decoder_init := GetProcAddress(Libhandle, 'mad_decoder_init');
|
||||
mad_decoder_finish := GetProcAddress(Libhandle, 'mad_decoder_finish');
|
||||
mad_decoder_run := GetProcAddress(Libhandle, 'mad_decoder_run');
|
||||
mad_decoder_message := GetProcAddress(Libhandle, 'mad_decoder_message');
|
||||
mad_stream_buffer := GetProcAddress(Libhandle, 'mad_stream_buffer');
|
||||
mad_stream_skip := GetProcAddress(Libhandle, 'mad_stream_skip');
|
||||
mad_stream_sync := GetProcAddress(Libhandle, 'mad_stream_sync');
|
||||
|
||||
end;
|
||||
|
||||
finalization
|
||||
|
||||
if Libhandle <> 0 then FreeLibrary(Libhandle);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
|
||||
var
|
||||
Libhandle : Pointer;
|
||||
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
Path : String;
|
||||
{$ENDIF}
|
||||
|
||||
initialization
|
||||
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
|
||||
Libhandle := nil;
|
||||
Path := FindLibs(MADLibPath);
|
||||
if Path <> '' then Libhandle := dlopen(@Path[1], RTLD_NOW or RTLD_GLOBAL);
|
||||
|
||||
{$ELSE}
|
||||
|
||||
Libhandle := dlopen(MADLibPath, RTLD_NOW or RTLD_GLOBAL);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
if Libhandle <> nil then
|
||||
begin
|
||||
|
||||
MADLibLoaded := True;
|
||||
|
||||
mad_decoder_init := dlsym(Libhandle, 'mad_decoder_init');
|
||||
mad_decoder_finish := dlsym(Libhandle, 'mad_decoder_finish');
|
||||
mad_decoder_run := dlsym(Libhandle, 'mad_decoder_run');
|
||||
mad_decoder_message := dlsym(Libhandle, 'mad_decoder_message');
|
||||
mad_stream_buffer := dlsym(Libhandle, 'mad_stream_buffer');
|
||||
mad_stream_skip := dlsym(Libhandle, 'mad_stream_skip');
|
||||
mad_stream_sync := dlsym(Libhandle, 'mad_stream_sync');
|
||||
|
||||
end;
|
||||
|
||||
finalization
|
||||
|
||||
if Libhandle <> nil then dlclose(Libhandle);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
end.
|
1411
acs/Src/fileformats/windows/msacm.pas
Normal file
1411
acs/Src/fileformats/windows/msacm.pas
Normal file
File diff suppressed because it is too large
Load Diff
334
acs/Src/fileformats/windows/waveconverter.pas
Normal file
334
acs/Src/fileformats/windows/waveconverter.pas
Normal file
@@ -0,0 +1,334 @@
|
||||
(*
|
||||
this file is a part of audio components suite v 2.3 (delphi version).
|
||||
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
|
||||
see the license file for more details.
|
||||
you can contact me at acs@compiler4.net
|
||||
this is the acs for delphi (windows) version of the unit.
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: waveconverter.pas,v $
|
||||
Revision 1.1 2005/12/19 18:36:49 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:53 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.1 2005/08/25 20:18:00 z0m3ie
|
||||
Version 2.4 restructure
|
||||
TCDPlayer removed (fits not in component structure)
|
||||
TMP3ToWavConverter removed (fits not in component structure)
|
||||
|
||||
Revision 1.2 2005/08/22 20:17:02 z0m3ie
|
||||
changed Headers to log
|
||||
changed mail adress
|
||||
|
||||
}
|
||||
|
||||
unit waveconverter;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
SysUtils,
|
||||
Windows, Classes, MMSystem, MSAcm;
|
||||
|
||||
type
|
||||
{$IFDEF FPC}
|
||||
TWaveFormat = WAVEFORMAT;
|
||||
{$ENDIF}
|
||||
|
||||
TRiffID = array[0..3] of char;
|
||||
TRiffHeader = packed record
|
||||
ID: TRiffID;
|
||||
BytesFollowing: DWord;
|
||||
end;
|
||||
|
||||
|
||||
TACMWaveFormat = packed record
|
||||
case integer of
|
||||
0 : (Format : TWaveFormatEx);
|
||||
1 : (RawData : Array[0..128] of byte);
|
||||
end;
|
||||
|
||||
TWaveConverter = class(TMemoryStream)
|
||||
private
|
||||
FMaxFmtSize: DWord;
|
||||
public
|
||||
CurrentFormat: TACMWaveFormat;
|
||||
NewFormat: TACMWaveFormat;
|
||||
function LoadStream(Stream : TStream): integer;
|
||||
function Convert: integer;
|
||||
function SaveWavToStream(MS: TStream): Integer;
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TWaveConverter }
|
||||
|
||||
function TWaveConverter.Convert: integer;
|
||||
var
|
||||
FStreamHandle: HACMStream;
|
||||
OutputBufferSize: DWord;
|
||||
FStreamHeader: TACMStreamHeader;
|
||||
OutPut: Pointer;
|
||||
begin
|
||||
FStreamHandle := nil;
|
||||
|
||||
//
|
||||
// Open the stream we're going to use to convert from the current to the
|
||||
// new format
|
||||
//
|
||||
Result := acmStreamOpen(FStreamhandle, nil, CurrentFormat.Format,
|
||||
NewFormat.Format, nil, 0, 0, ACM_STREAMOPENF_NONREALTIME);
|
||||
if Result <> 0 then
|
||||
begin
|
||||
//SetError('acmStreamOpen', Result);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
//
|
||||
// Calculate the size of the converted data
|
||||
//
|
||||
Result := acmStreamSize(FStreamHandle, self. Size, OutputBufferSize,
|
||||
ACM_STREAMSIZEF_SOURCE);
|
||||
|
||||
if Result <> 0 then
|
||||
begin
|
||||
// SetError('acmStreamSize', Result);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
//
|
||||
// Allocate memory for the converted data
|
||||
//
|
||||
GetMem(OutPut, OutputBufferSize);
|
||||
FillChar(OutPut^,OutputBufferSize,#0);
|
||||
|
||||
Self.Seek(0,0);
|
||||
|
||||
//
|
||||
// Initialize and prepare a header
|
||||
//
|
||||
with FStreamHeader do
|
||||
begin
|
||||
cbStruct := SizeOf(TACMStreamHeader);
|
||||
fdwStatus := 0;
|
||||
dwUser := 0;
|
||||
pbSrc := self.Memory;
|
||||
cbSrcLength := self.Size;
|
||||
cbSrcLengthUsed := 0;
|
||||
dwSrcUser := 0;
|
||||
pbDst := OutPut;
|
||||
cbDstLength := OutputBufferSize;
|
||||
cbDstLengthUsed := 0;
|
||||
dwDstUser := 0;
|
||||
end;
|
||||
Result := acmStreamPrepareHeader(FStreamHandle,FStreamHeader, 0);
|
||||
if Result <> 0 then
|
||||
begin
|
||||
// SetError('acmStreamPrepareHeader', Result);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
//
|
||||
// Tell acm to convert the stream
|
||||
//
|
||||
Result := acmStreamConvert(FStreamHandle,FStreamHeader,
|
||||
ACM_STREAMCONVERTF_BLOCKALIGN);
|
||||
if Result <> 0 then
|
||||
begin
|
||||
// SetError('acmStreamConvert', Result);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
//
|
||||
// Set the format eqaul to the newformat and copy the
|
||||
// data over to the streams memory
|
||||
//
|
||||
Move(NewFormat.RawData, CurrentFormat.RawData, FMaxFmtSize);
|
||||
Self.SetSize(OutputBufferSize);
|
||||
Self.Seek(0,0);
|
||||
Self.Write(Output^, OutputBufferSize);
|
||||
|
||||
//
|
||||
// Unprepeare the header
|
||||
//
|
||||
Result := acmStreamUnprepareHeader(FStreamHandle,FStreamHeader, 0);
|
||||
if Result <> 0 then
|
||||
begin
|
||||
// SetError('acmStreamUnprepareHeader', Result);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
//
|
||||
// Close the stream
|
||||
//
|
||||
Result := acmStreamClose(FStreamHandle, 0);
|
||||
if Result <> 0 then
|
||||
begin
|
||||
// SetError('acmStreamClose', Result);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
FreeMem(OutPut);
|
||||
end;
|
||||
|
||||
constructor TWaveConverter.Create;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
acmMetrics(nil, ACM_METRIC_MAX_SIZE_FORMAT, FMaxFmtSize);
|
||||
|
||||
FillChar(CurrentFormat.Format, FMaxFmtSize, 0);
|
||||
FillChar(NewFormat.Format, FMaxFmtSize, 0);
|
||||
end;
|
||||
|
||||
destructor TWaveConverter.Destroy;
|
||||
begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TWaveConverter.LoadStream(Stream : TStream): integer;
|
||||
var
|
||||
Header: TRiffHeader;
|
||||
ID: TRiffID;
|
||||
Mem: Pointer;
|
||||
Data: PByteArray;
|
||||
|
||||
|
||||
NumRead: Integer;
|
||||
Pos: Integer;
|
||||
|
||||
begin
|
||||
Result := 0;
|
||||
try
|
||||
//read the header
|
||||
NumRead := Stream.Read(Header, SizeOf(Header));
|
||||
Pos := NumRead;
|
||||
|
||||
NumRead := Stream.Read(ID, SizeOf(ID));
|
||||
Pos := Pos + NumRead;
|
||||
|
||||
if (Header.ID <> 'RIFF') or (ID <> 'WAVE') then
|
||||
begin
|
||||
Exit;
|
||||
end;
|
||||
|
||||
while Pos < Stream.Size -1 do
|
||||
begin
|
||||
Dec(Pos,7);
|
||||
Stream.Seek(Pos, soFromBeginning);
|
||||
|
||||
NumRead := Stream.Read(Header, SizeOf(Header));
|
||||
Pos := Pos + NumRead;
|
||||
|
||||
|
||||
if Header.ID = 'fmt ' then
|
||||
begin
|
||||
GetMem(Mem, Header.BytesFollowing);
|
||||
try
|
||||
NumRead := Stream.Read(Mem^, Header.BytesFollowing);
|
||||
Pos := Pos + NumRead;
|
||||
|
||||
if Header.BytesFollowing < SizeOf(TWaveFormatEx) then
|
||||
Move(Mem^, CurrentFormat.Format , SizeOf(TWaveFormatEx))
|
||||
else
|
||||
Move(Mem^, CurrentFormat.Format, Header.BytesFollowing);
|
||||
finally
|
||||
FreeMem(Mem);
|
||||
end;
|
||||
end
|
||||
else
|
||||
if Header.ID = 'fact' then
|
||||
begin
|
||||
GetMem(Data, Header.BytesFollowing);
|
||||
try
|
||||
NumRead := Stream.Read(Data^, Header.BytesFollowing);
|
||||
Pos := Pos + NumRead;
|
||||
finally
|
||||
FreeMem(Data);
|
||||
end;
|
||||
end
|
||||
else
|
||||
if Header.ID = 'data' then
|
||||
begin
|
||||
if Header.BytesFollowing > 0 then
|
||||
begin
|
||||
GetMem(Data, Header.BytesFollowing);
|
||||
try
|
||||
NumRead := Stream.Read(Data^, Header.BytesFollowing);
|
||||
Pos := Pos + NumRead;
|
||||
|
||||
Self.SetSize(Header.BytesFollowing);
|
||||
Self.Seek(0,0);
|
||||
Self.Write(Data^, (*Header.BytesFollowing*)self.Size);
|
||||
finally
|
||||
FreeMem(Data);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
Seek(0,0);
|
||||
finally
|
||||
// FileStream.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function TWaveConverter.SaveWavToStream(MS: TStream): Integer;
|
||||
var
|
||||
CurrentPos : Integer;
|
||||
H : TRiffHeader;
|
||||
ID : TRiffID;
|
||||
begin
|
||||
Result := 0;
|
||||
try
|
||||
CurrentPos := Position;
|
||||
|
||||
H.ID := 'RIFF';
|
||||
H.BytesFollowing := 0;
|
||||
MS.Write(H, SizeOf(H));
|
||||
|
||||
ID := 'WAVE';
|
||||
MS.Write(ID, SizeOf(ID));
|
||||
|
||||
H.ID := 'fmt ';
|
||||
H.BytesFollowing := SizeOf(TWaveFormat) + 2;
|
||||
MS.Write(H, SizeOf(H));
|
||||
MS.Write(CurrentFormat.Format, SizeOf(TWaveFormat) + 2);
|
||||
|
||||
H.ID := 'data';
|
||||
H.BytesFollowing := Size;
|
||||
MS.Write(H, SizeOf(H));
|
||||
Seek(0,0);
|
||||
// MS.CopyFrom(Self, Size);
|
||||
// ms.Write( Self, Size);
|
||||
self.SaveToStream(MS);
|
||||
|
||||
|
||||
MS.Seek(0,0);
|
||||
H.ID := 'RIFF';
|
||||
H.BytesFollowing := MS.Size - SizeOf(H) +1;
|
||||
MS.Write(H,SizeOf(H));
|
||||
|
||||
Position := CurrentPos;
|
||||
// MS.Free;
|
||||
except
|
||||
on E: Exception do
|
||||
begin
|
||||
Result := MCIERR_FILE_NOT_SAVED;
|
||||
// SetError('SaveFile', MCIERR_FILE_NOT_SAVED);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user