⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x3daudio.pas

📁 3D GameStudio 的Delphi开发包
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{******************************************************************************}
{*                                                                            *}
{*  Copyright (C) Microsoft Corporation.  All Rights Reserved.                *}
{*                                                                            *}
{*  Files:      X3DAudio.h                                                    *}
{*  Content:    Cross-platform stand-alone 3D audio math library              *}
{*                                                                            *}
{*  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: X3DAudio.pas,v 1.6 2006/10/21 21:30:10 clootie Exp $ }
{******************************************************************************}
{                                                                              }
{ Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI)        }
{                                                                              }
{ 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 }
{                                                                              }
{******************************************************************************}

(*-========================================================================-_
 |                               - X3DAUDIO -                               |
 |        Copyright (c) Microsoft Corporation.  All rights reserved.        |
 |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
 |VERSION:  0.1                         MODEL:   Unmanaged User-mode        |
 |CONTRACT: N / A                       EXCEPT:  No Exceptions              |
 |PARENT:   N / A                       MINREQ:  Win2000, Xenon             |
 |PROJECT:  X3DAudio                    DIALECT: MS Visual C++ 7.0          |
 |>------------------------------------------------------------------------<|
 | DUTY: Cross-platform stand-alone 3D audio math library                   |
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
  NOTES:
    1.  Definition of terms:
            LFE: Low Frequency Effect -- always omnidirectional.
            LPF: Low Pass Filter, divided into two classifications:
                 Direct -- Applied to the direct signal path,
                           used for obstruction/occlusion effect.
                 Reverb -- Applied to the reverb signal path,
                           used for occlusion effect only.

    2.  Volume level is expressed as a linear amplitude scaler:
        1.0f represents no attenuation applied to the original signal,
        0.5f denotes an attenuation of 6dB, and 0.0f results in silence.
        Amplification (volume > 1.0f) is also allowed, and is not clamped.

    3.  X3DAudio uses a left-handed Cartesian coordinate system with values
        on the x-axis increasing from left to right, on the y-axis from
        bottom to top, and on the z-axis from near to far.
        Azimuths are measured clockwise from a given reference direction.

        Distance measurement is with respect to user-defined world units.
        Applications may provide coordinates using any system of measure
        as all non-normalized calculations are scale invariant, with such
        operations natively occurring in the user-defined world unit space.
        Metric constants are supplied only as a convenience.
        Distance is calculated using the Euclidean norm formula.

    4.  Only real values are permissible with functions using 32-bit
        float parameters -- NAN and infinite values are not accepted.
        All computation occurs in 32-bit precision mode.                    *)

{$I DirectX.inc}

unit X3DAudio;

interface

(*$HPPEMIT '#include "X3DAudio.h"' *)

//--------------<D-E-F-I-N-I-T-I-O-N-S>-------------------------------------//
uses
  {$IFDEF XBOX}vectorintrinsics{$ELSE}Windows{$ENDIF},
  DXTypes, Direct3D9;

const
  X3DAudioDLL = 'X3DAudio.dll';

  // speaker geometry configuration flags, specifies assignment of channels to speaker positions, defined as per WAVEFORMATEXTENSIBLE.dwChannelMask
  SPEAKER_FRONT_LEFT            = $00000001;
  {$EXTERNALSYM SPEAKER_FRONT_LEFT}
  SPEAKER_FRONT_RIGHT           = $00000002;
  {$EXTERNALSYM SPEAKER_FRONT_RIGHT}
  SPEAKER_FRONT_CENTER          = $00000004;
  {$EXTERNALSYM SPEAKER_FRONT_CENTER}
  SPEAKER_LOW_FREQUENCY         = $00000008;
  {$EXTERNALSYM SPEAKER_LOW_FREQUENCY}
  SPEAKER_BACK_LEFT             = $00000010;
  {$EXTERNALSYM SPEAKER_BACK_LEFT}
  SPEAKER_BACK_RIGHT            = $00000020;
  {$EXTERNALSYM SPEAKER_BACK_RIGHT}
  SPEAKER_FRONT_LEFT_OF_CENTER  = $00000040;
  {$EXTERNALSYM SPEAKER_FRONT_LEFT_OF_CENTER}
  SPEAKER_FRONT_RIGHT_OF_CENTER = $00000080;
  {$EXTERNALSYM SPEAKER_FRONT_RIGHT_OF_CENTER}
  SPEAKER_BACK_CENTER           = $00000100;
  {$EXTERNALSYM SPEAKER_BACK_CENTER}
  SPEAKER_SIDE_LEFT             = $00000200;
  {$EXTERNALSYM SPEAKER_SIDE_LEFT}
  SPEAKER_SIDE_RIGHT            = $00000400;
  {$EXTERNALSYM SPEAKER_SIDE_RIGHT}
  SPEAKER_TOP_CENTER            = $00000800;
  {$EXTERNALSYM SPEAKER_TOP_CENTER}
  SPEAKER_TOP_FRONT_LEFT        = $00001000;
  {$EXTERNALSYM SPEAKER_TOP_FRONT_LEFT}
  SPEAKER_TOP_FRONT_CENTER      = $00002000;
  {$EXTERNALSYM SPEAKER_TOP_FRONT_CENTER}
  SPEAKER_TOP_FRONT_RIGHT       = $00004000;
  {$EXTERNALSYM SPEAKER_TOP_FRONT_RIGHT}
  SPEAKER_TOP_BACK_LEFT         = $00008000;
  {$EXTERNALSYM SPEAKER_TOP_BACK_LEFT}
  SPEAKER_TOP_BACK_CENTER       = $00010000;
  {$EXTERNALSYM SPEAKER_TOP_BACK_CENTER}
  SPEAKER_TOP_BACK_RIGHT        = $00020000;
  {$EXTERNALSYM SPEAKER_TOP_BACK_RIGHT}

  // standard speaker geometry configurations, used with X3DAudioInitialize
  SPEAKER_STEREO  = (SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT);
  {$EXTERNALSYM SPEAKER_STEREO}
  SPEAKER_2POINT1          = (SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT or SPEAKER_LOW_FREQUENCY);
  {$EXTERNALSYM SPEAKER_2POINT1}
  SPEAKER_SURROUND         = (SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT or SPEAKER_FRONT_CENTER or SPEAKER_BACK_CENTER);
  {$EXTERNALSYM SPEAKER_SURROUND}
  SPEAKER_QUAD             = (SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT or SPEAKER_BACK_LEFT or SPEAKER_BACK_RIGHT);
  {$EXTERNALSYM SPEAKER_QUAD}
  SPEAKER_4POINT1          = (SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT or SPEAKER_LOW_FREQUENCY or SPEAKER_BACK_LEFT or SPEAKER_BACK_RIGHT);
  {$EXTERNALSYM SPEAKER_4POINT1}
  SPEAKER_5POINT1          = (SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT or SPEAKER_FRONT_CENTER or SPEAKER_LOW_FREQUENCY or SPEAKER_BACK_LEFT or SPEAKER_BACK_RIGHT);
  {$EXTERNALSYM SPEAKER_5POINT1}
  SPEAKER_7POINT1          = (SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT or SPEAKER_FRONT_CENTER or SPEAKER_LOW_FREQUENCY or SPEAKER_BACK_LEFT or SPEAKER_BACK_RIGHT or SPEAKER_FRONT_LEFT_OF_CENTER or SPEAKER_FRONT_RIGHT_OF_CENTER);
  {$EXTERNALSYM SPEAKER_7POINT1}
  SPEAKER_5POINT1_SURROUND = (SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT or SPEAKER_FRONT_CENTER or SPEAKER_LOW_FREQUENCY or SPEAKER_SIDE_LEFT  or SPEAKER_SIDE_RIGHT);
  {$EXTERNALSYM SPEAKER_5POINT1_SURROUND}
  SPEAKER_7POINT1_SURROUND = (SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT or SPEAKER_FRONT_CENTER or SPEAKER_LOW_FREQUENCY or SPEAKER_BACK_LEFT or SPEAKER_BACK_RIGHT or SPEAKER_SIDE_LEFT  or SPEAKER_SIDE_RIGHT);
  {$EXTERNALSYM SPEAKER_7POINT1_SURROUND}

  // xenon speaker geometry configuration, used with X3DAudioInitialize
  {$IFDEF XBOX}
  SPEAKER_XBOX = SPEAKER_5POINT1; // SPEAKER_XENON = $3f;
  {$EXTERNALSYM SPEAKER_XENON}
  {$ENDIF}


  X3DAUDIO_HANDLE_BYTESIZE = 20; // size of instance handle in bytes
  {$EXTERNALSYM X3DAUDIO_HANDLE_BYTESIZE}

  // float math constants
  X3DAUDIO_PI  = 3.141592654;
  {$EXTERNALSYM X3DAUDIO_PI}
  X3DAUDIO_2PI = 6.283185307;
  {$EXTERNALSYM X3DAUDIO_2PI}

  // speed of sound in meters per second for dry air at approximately 20C, used with X3DAudioInitialize
  X3DAUDIO_SPEED_OF_SOUND = 343.5;
  {$EXTERNALSYM X3DAUDIO_SPEED_OF_SOUND}

  // calculation control flags, used with X3DAudioCalculate
  X3DAUDIO_CALCULATE_MATRIX        = $00000001; // enable matrix coefficient table calculation
  {$EXTERNALSYM X3DAUDIO_CALCULATE_MATRIX}
  X3DAUDIO_CALCULATE_DELAY         = $00000002; // enable delay time array calculation (stereo final mix only)
  {$EXTERNALSYM X3DAUDIO_CALCULATE_DELAY}
  X3DAUDIO_CALCULATE_LPF_DIRECT    = $00000004; // enable LPF direct-path coefficient calculation
  {$EXTERNALSYM X3DAUDIO_CALCULATE_LPF_DIRECT}
  X3DAUDIO_CALCULATE_LPF_REVERB    = $00000008; // enable LPF reverb-path coefficient calculation
  {$EXTERNALSYM X3DAUDIO_CALCULATE_LPF_REVERB}
  X3DAUDIO_CALCULATE_REVERB        = $00000010; // enable reverb send level calculation
  {$EXTERNALSYM X3DAUDIO_CALCULATE_REVERB}
  X3DAUDIO_CALCULATE_DOPPLER       = $00000020; // enable doppler shift factor calculation
  {$EXTERNALSYM X3DAUDIO_CALCULATE_DOPPLER}
  X3DAUDIO_CALCULATE_EMITTER_ANGLE = $00000040; // enable emitter-to-listener interior angle calculation
  {$EXTERNALSYM X3DAUDIO_CALCULATE_EMITTER_ANGLE}

  X3DAUDIO_CALCULATE_ZEROCENTER    = $00010000; // do not position to front center speaker, center destination channel will be zero in returned matrix coefficient table, used only for matrix calculations and only for final mix formats that have a front center channel
  {$EXTERNALSYM X3DAUDIO_CALCULATE_ZEROCENTER}


//--------------<M-A-C-R-O-S>-----------------------------------------------//
  // function storage-class attribute and calltype
{ #if defined(_XBOX) || defined(X3DAUDIOSTATIC)
  #define X3DAUDIO_API_(type) EXTERN_C type STDAPICALLTYPE
  $ELSE
      #if defined(X3DEXPORT)
          #define X3DAUDIO_API_(type) EXTERN_C __declspec(dllexport) type STDAPICALLTYPE
      #else
          #define X3DAUDIO_API_(type) EXTERN_C __declspec(dllimport) type STDAPICALLTYPE
      #endif
  $ENDIF
  #define X3DAUDIO_IMP_(type) type STDMETHODCALLTYPE
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -