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

📄 xact.pas

📁 3D GameStudio 的Delphi开发包
💻 PAS
📖 第 1 页 / 共 5 页
字号:
{******************************************************************************}
{*                                                                            *}
{*  Copyright (C) Microsoft Corporation.  All Rights Reserved.                *}
{*                                                                            *}
{*  Files:      xact.h, xact2wb.h, xact3D.h                                   *}
{*  Content:    XACT public interfaces, functions and data types;             *}
{*              XACT 2 wave bank definitions; XACT 3D support.                *}
{*                                                                            *}
{*  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: xact.pas,v 1.11 2006/10/21 22:10:57 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 }
{                                                                              }
{******************************************************************************}

{$I DirectX.inc}

unit xact;

interface

(*$HPPEMIT '#include "xact.h"' *)
(*$HPPEMIT '#include "xact2wb.h"' *)
(*$HPPEMIT '#include "xact3D.h"' *)

uses
  {$IFDEF XBOX}XAudio, xauddefs{$ELSE}Windows, ActiveX{$ENDIF}, X3DAudio;

{$IFDEF XBOX}
type
  //XBox compatibility types - not needed in real XBox SDK
  PXAudioVoiceOutput = Pointer;
  PXAudioVoiceOutputVolume = Pointer;
  PXACTCueProperies = Pointer;
{$ENDIF}


//------------------------------------------------------------------------------
// XACT class and interface IDs (Version 2.4)
//------------------------------------------------------------------------------
{$IFNDEF XBOX} // XACT COM support only exists on Windows
const
  CLSID_XACTEngine: TGUID = '{bc3e0fc6-2e0d-4c45-bc61-d9c328319bd8}';
  CLSID_XACTAuditionEngine: TGUID = '{30bad9f7-0018-49e9-bf94-4ae89cc54d64}';
  CLSID_XACTDebugEngine: TGUID = '{74ee14d5-ca1d-44ac-8bd3-fa94f7346e24}';
  // will be defined later -> IID_IXACTEngine: TGUID = '{43a0d4a8-9387-4e06-9433-65418fe70a67}';

  {$EXTERNALSYM CLSID_XACTEngine}
  {$EXTERNALSYM CLSID_XACTAuditionEngine}
  {$EXTERNALSYM CLSID_XACTDebugEngine}
{$ENDIF}


//------------------------------------------------------------------------------
// Forward Declarations
//------------------------------------------------------------------------------

{$IFNDEF XBOX}
const
  XACT_RENDERER_ID_LENGTH    = $ff;   // Maximum number of characters allowed in the renderer ID
  {$EXTERNALSYM XACT_RENDERER_ID_LENGTH}
  XACT_RENDERER_NAME_LENGTH  = $ff;   // Maximum number of characters allowed in the renderer display name.
  {$EXTERNALSYM XACT_RENDERER_NAME_LENGTH}

  XACT_ENGINE_LOOKAHEAD_DEFAULT   = 250;         // Default look-ahead time of 250ms can be used during XACT engine initialization.
  {$EXTERNALSYM XACT_ENGINE_LOOKAHEAD_DEFAULT}
{$ENDIF}

type
  IXACTSoundBank = class;
  IXACTWaveBank = class;
  IXACTCue = class;

  PXACT_Notification = ^TXACT_Notification;
  PIXACTCue = ^IXACTCue;


//------------------------------------------------------------------------------
// Typedefs
//------------------------------------------------------------------------------

  TXACTIndex = Word;            // All normal indices
  TXACTNotificationType = Byte; // Notification type
  TXACTVariableValue = Single;  // Variable value
  TXACTVariableIndex = Word;    // Variable index
  TXACTCategory = Word;         // Sound category
  TXACTChannel = Byte;          // Audio channel
  TXACTVolume = Single;         // Volume value
  TXACTTime = Longint;          // Time (in ms)

  PXACTIndex = ^TXACTIndex;
  PXACTNotificationType = ^TXACTNotificationType;
  PXACTVariableValue = ^TXACTVariableValue;
  PXACTVariableIndex = ^TXACTVariableIndex;
  PXACTCategory = ^TXACTCategory;
  PXACTChannel = ^TXACTChannel;
  PXACTVolume = ^TXACTVolume;
  PXACTTime = ^TXACTTime;

  XACTINDEX = TXACTIndex;
  XACTNOTIFICATIONTYPE = TXACTNotificationType;
  XACTVARIABLEVALUE = TXACTVariableValue;
  XACTVARIABLEINDEX = TXACTVariableIndex;
  XACTCATEGORY = TXACTCategory;
  XACTCHANNEL = TXACTChannel;
  XACTVOLUME = TXACTVolume;
  XACTTIME = TXACTTime;

  {$NODEFINE XACTINDEX}
  {$NODEFINE XACTNOTIFICATIONTYPE}
  {$NODEFINE XACTVARIABLEVALUE}
  {$NODEFINE XACTVARIABLEINDEX}
  {$NODEFINE XACTCATEGORY}
  {$NODEFINE XACTCHANNEL}
  {$NODEFINE XACTVOLUME}
  {$NODEFINE XACTTIME}
  {$NODEFINE TXACTINDEX}
  {$NODEFINE TXACTNOTIFICATIONTYPE}
  {$NODEFINE TXACTVARIABLEVALUE}
  {$NODEFINE TXACTVARIABLEINDEX}
  {$NODEFINE TXACTCATEGORY}
  {$NODEFINE TXACTCHANNEL}
  {$NODEFINE TXACTVOLUME}
  {$NODEFINE TXACTTIME}
  {$HPPEMIT 'typedef XACTINDEX TXACTIndex'}
  {$HPPEMIT 'typedef XACTNOTIFICATIONTYPE TXACTNotificationType'}
  {$HPPEMIT 'typedef XACTVARIABLEVALUE TXACTVariableValue'}
  {$HPPEMIT 'typedef XACTVARIABLEINDEX TXACTVariableIndex'}
  {$HPPEMIT 'typedef XACTCATEGORY TXACTCategory'}
  {$HPPEMIT 'typedef XACTCHANNEL TXACTChanel'}
  {$HPPEMIT 'typedef XACTVOLUME TXACTVolume'}
  {$HPPEMIT 'typedef XACTTIME TXACTTime'}



//------------------------------------------------------------------------------
// XACT Parameters
//------------------------------------------------------------------------------

  {$NODEFINE TXACT_ReadFile_Callback}
  TXACT_ReadFile_Callback = function (hFile: THandle; lpBuffer: Pointer; nNumberOfBytesToRead: DWORD;
      lpNumberOfBytesRead: PDWORD; lpOverlapped: POverlapped): BOOL; stdcall;
  {$NODEFINE TXACT_GetOverlappedResult_Callback}
  TXACT_GetOverlappedResult_Callback = function (hFile: THandle; lpOverlapped: POverlapped;
      lpNumberOfBytesTransferred: PDWORD; bWait: BOOL): BOOL; stdcall;

  PXACT_FileIO_Callbacks = ^TXACT_FileIO_Callbacks;
  XACT_FILEIO_CALLBACKS = record
    readFileCallback: TXACT_ReadFile_Callback;
    getOverlappedResultCallback: TXACT_GetOverlappedResult_Callback;
  end;
  {$EXTERNALSYM XACT_FILEIO_CALLBACKS}
  TXACT_FileIO_Callbacks = XACT_FILEIO_CALLBACKS;

  // The callback that receives the notifications.
  TXACT_Notification_Callback = procedure (const pNotification: PXACT_Notification); stdcall;
  {$EXTERNALSYM TXACT_Notification_Callback}

{$IFNDEF XBOX}
  // Renderer details
  PXACT_Renderer_Details = ^TXACT_Renderer_Details;
  XACT_RENDERER_DETAILS = record
    rendererID: array[0..XACT_RENDERER_ID_LENGTH-1] of WideChar;       // The string ID for the rendering device.
    displayName: array[0..XACT_RENDERER_NAME_LENGTH-1] of WideChar;    // A friendly name suitable for display to a human.
    defaultDevice: BOOL;                                               // Set to TRUE if this device is the primary audio device on the system.
  end;
  {$EXTERNALSYM XACT_RENDERER_DETAILS}
  TXACT_Renderer_Details = XACT_RENDERER_DETAILS;
  TXACTRendererDetails = XACT_RENDERER_DETAILS;
  PXACTRendererDetails = PXACT_Renderer_Details;
{$ENDIF}

  // Runtime (engine) parameters
  PXACT_Runtime_Parameters = ^TXACT_Runtime_Parameters;
  XACT_RUNTIME_PARAMETERS = record
    lookAheadTime:                 DWORD;   // Time in ms
    pGlobalSettingsBuffer:         Pointer; // Buffer containing the global settings file
    globalSettingsBufferSize:      DWORD;   // Size of global settings buffer
    globalSettingsFlags:           DWORD;   // Flags for global settings
    globalSettingsAllocAttributes: DWORD;   // Global settings buffer allocation attributes (see XMemAlloc)
    fileIOCallbacks:               TXACT_FileIO_Callbacks;      // File I/O callbacks
    fnNotificationCallback:        TXACT_Notification_Callback; // Callback that receives notifications.
  {$IFNDEF XBOX}
    pRendererID:                   PWideChar;                   // Ptr to the ID for the audio renderer the engine should connect to.
  {$ENDIF}
  end;
  {$EXTERNALSYM XACT_RUNTIME_PARAMETERS}
  TXACT_Runtime_Parameters = XACT_RUNTIME_PARAMETERS;

//------------------------------------------------------------------------------
// Streaming Parameters
//------------------------------------------------------------------------------

  PXACT_Wavebank_Streaming_Parameters = ^TXACT_Wavebank_Streaming_Parameters;
  XACT_WAVEBANK_STREAMING_PARAMETERS = record
    file_: THandle;         // File handle associated with wavebank data
    offset: DWORD;          // Offset within file of wavebank header (must be sector aligned)
    flags: DWORD;           // Flags (none currently)
    packetSize: Word;       // Stream packet size (in sectors) to use for each stream (min = 2)
                            //   number of sectors (DVD = 2048 bytes: 2 = 4096, 3 = 6144, 4 = 8192 etc.)
                            //   optimal DVD size is a multiple of 16 (DVD block = 16 DVD sectors)
  end;
  {$EXTERNALSYM XACT_WAVEBANK_STREAMING_PARAMETERS}
  TXACT_Wavebank_Streaming_Parameters = XACT_WAVEBANK_STREAMING_PARAMETERS;

//------------------------------------------------------------------------------
// Cue Properties (Xbox Only)
//------------------------------------------------------------------------------
{$IFDEF XBOX}
  PXACTCueProperties = ^TXACTCueProperties;
  XACTCUEPROPERTIES = record
    ActiveSoundCategory:    TXACTCategory; // Category of the active sound
    ActiveSoundTrackCount:  Byte;          // The number of tracks in the active sound
    ActiveSoundPriority:    Byte;          // The priority of the active sound
    FirstTrackWaveIndex:    TXACTIndex;    // Index of the currently selected wave variation in the first track
    FirstTrackWaveDuration: DWORD;         // Estimated duration (ms) of the selected wave in the first track (does not account for pitch changes)
    MaxTrackChannelCount:   TXACTChannel;  // The highest number of channels in any track
    MaxTrackLoopCount:      Byte;          // The highest loop count of any track (255 is infinite)
  end;
  {$EXTERNALSYM XACTCUEPROPERTIES}
  TXACTCueProperties = XACTCUEPROPERTIES;
{$ENDIF} // XBOX

//------------------------------------------------------------------------------
// Channel Mapping / Speaker Panning
//------------------------------------------------------------------------------

  PXACTChannelMapEntry = ^TXACTChannelMapEntry;
  XACTCHANNELMAPENTRY = record
    InputChannel: TXACTChannel;
    OutputChannel: TXACTChannel;
    Volume: TXACTVolume;
  end;
  {$EXTERNALSYM XACTCHANNELMAPENTRY}
  TXACTChannelMapEntry = XACTCHANNELMAPENTRY;


  PXACTChannelMap = ^TXACTChannelMap;
  XACTCHANNELMAP = record
    EntryCount: TXACTChannel;
    paEntries: PXACTChannelMapEntry;
  end;
  {$EXTERNALSYM XACTCHANNELMAP}
  TXACTChannelMap = XACTCHANNELMAP;

  PXACTChannelVolumeEntry = ^TXACTChannelVolumeEntry;
  XACTCHANNELVOLUMEENTRY = record
    EntryIndex: TXACTChannel;
    Volume: TXACTVolume;
  end;
  {$EXTERNALSYM XACTCHANNELVOLUMEENTRY}
  TXACTChannelVolumeEntry = XACTCHANNELVOLUMEENTRY;

  PXACTChannelVolume = ^TXACTChannelVolume;
  XACTCHANNELVOLUME = record
    EntryCount: TXACTChannel;
    paEntries: PXACTChannelVolumeEntry;
  end;
  {$EXTERNALSYM XACTCHANNELVOLUME}
  TXACTChannelVolume = XACTCHANNELVOLUME;


//------------------------------------------------------------------------------
// Notifications
//------------------------------------------------------------------------------

// Pack the notification structures
// Original C++ header: #pragma pack(push, 1)

⌨️ 快捷键说明

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