Ada计算机图形DirectX之audiodefs

--------------------------------------------
-- DirectX SDK (August 2009) Ada package  --
-- Translator: Gu.Dongfeng(顾冬峰),2018   --
-- E-mail:[email protected]                   --
-- 为了Ada在应用层面的推广而翻译之        --
--------------------------------------------

with win32;                 use win32;
with win32.windef;          use win32.windef;
with win32.rpcdce;          use win32.rpcdce;

with Interfaces.C;


package audiodefs is

--/**************************************************************************
-- *
-- *  WAVEFORMATEX: Base structure for many audio formats.  Format-specific
-- *  extensions can be defined for particular formats by using a non-zero
-- *  cbSize value and adding extra fields to the end of this structure.
-- *
-- ***************************************************************************/

   -- audiodefs.h:40
   type tWAVEFORMATEX is record
      wFormatTag:WORD;                -- Integer identifier of the format
      nChannels:WORD;                 -- Number of audio channels
      nSamplesPerSec:DWORD;           -- Audio sample rate
      nAvgBytesPerSec:DWORD;          -- Bytes per second (possibly approximate)
      nBlockAlign:WORD;               -- Size in bytes of a sample block (all channels)
      wBitsPerSample:WORD;            -- Size in bits of a single per-channel sample
      cbSize:WORD;                    -- Bytes of extra data appended to this struct
   end record;

   subtype WAVEFORMATEX is tWAVEFORMATEX;
   
   -- Defining pointer types outside of the #if block to make sure they are
   -- defined even if mmreg.h or mmsystem.h is #included before this file

   -- audiodefs.h:56
   type PWAVEFORMATEX is access all WAVEFORMATEX;
   type NPWAVEFORMATEX is access all WAVEFORMATEX;
   type LPWAVEFORMATEX is access all WAVEFORMATEX;

   -- audiodefs.h:57
   type PCWAVEFORMATEX is access constant WAVEFORMATEX;
   type LPCWAVEFORMATEX is access constant WAVEFORMATEX;
   

-- /**************************************************************************
-- *
-- *  WAVEFORMATEXTENSIBLE: Extended version of WAVEFORMATEX that should be
-- *  used as a basis for all new audio formats.  The format tag is replaced
-- *  with a GUID, allowing new formats to be defined without registering a
-- *  format tag with Microsoft.  There are also new fields that can be used
-- *  to specify the spatial positions for each channel and the bit packing
-- *  used for wide samples (e.g. 24-bit PCM samples in 32-bit containers).
-- *
-- ***************************************************************************/
 
   -- audiodefs.h:77
   type WAVEFORMATEXTENSIBLE_SAMPLES(C:Integer:=0) is record
      case C is
         when 0=>
            wValidBitsPerSample:WORD;                -- Valid bits in each sample container
         when 1=>
            wSamplesPerBlock:WORD;                   -- Samples per block of audio data; valid if wBitsPerSample=0 (but rarely used).
         when others=>
            wReserved:WORD;                          -- Zero if neither case above applies.
      end case;
   end record with Unchecked_Union;

   -- audiodefs.h:74
   type WAVEFORMATEXTENSIBLE is record
      Format:WAVEFORMATEX;                            -- Base WAVEFORMATEX data
      Samples:WAVEFORMATEXTENSIBLE_SAMPLES;
      dwChannelMask:DWORD;                            -- Positions of the audio channels
      SubFormat:GUID;                                 -- Format identifier GUID
   end record;

   -- audiodefs.h:90
   type PWAVEFORMATEXTENSIBLE is access all WAVEFORMATEXTENSIBLE;
   type LPWAVEFORMATEXTENSIBLE is access all WAVEFORMATEXTENSIBLE;

   -- audiodefs.h:91
   type PCWAVEFORMATEXTENSIBLE is access constant WAVEFORMATEXTENSIBLE;
   type LPCWAVEFORMATEXTENSIBLE is access constant WAVEFORMATEXTENSIBLE;

--/**************************************************************************
-- *
-- *  Define the most common wave format tags used in WAVEFORMATEX formats.
-- *
-- ***************************************************************************/

   -- If WAVE_FORMAT_PCM is not defined, we need to define some legacy types
   -- for compatibility with the Windows mmreg.h / mmsystem.h header files.

   -- Old general format structure (information common to all formats)
   -- audiodefs.h:107
   type waveformat_tag is record
      wFormatTag:WORD;
      nChannels:WORD;
      nSamplesPerSec:DWORD;
      nAvgBytesPerSec:DWORD;
      nBlockAlign:WORD;
   end record;

   -- audiodefs.h:114
   subtype WAVEFORMAT is waveformat_tag;
   type PWAVEFORMAT is access all waveformat_tag;
   type NPWAVEFORMAT is access all waveformat_tag;
   type LPWAVEFORMAT is access all waveformat_tag;

   -- Specific format structure for PCM data
   -- audiodefs.h:117
   type pcmwaveformat_tag is record
      wf:WAVEFORMAT;
      wBitsPerSample:WORD;
   end record;

   -- audiodefs.h:121
   subtype PCMWAVEFORMAT is pcmwaveformat_tag;
   type PPCMWAVEFORMAT is access all pcmwaveformat_tag;
   type NPPCMWAVEFORMAT is access all pcmwaveformat_tag;
   type LPPCMWAVEFORMAT is access all pcmwaveformat_tag;


   -- audiodefs.h:123
   WAVE_FORMAT_PCM : constant := 16#0001#;
   
   -- Replicate the Microsoft ADPCM type definitions from mmreg.h.
   -- audiodefs.h:131
   type adpcmcoef_tag is record
      iCoef1:short;
      iCoef2:short;
   end record;

   subtype ADPCMCOEFSET is adpcmcoef_tag;
   
   type ADPCMCOEFSET_ARRAY is array(Natural range<>) of ADPCMCOEFSET;

   -- audiodefs.h:140
   type adpcmwaveformat_tag is record
      wfx:WAVEFORMATEX;
      wSamplesPerBlock:WORD;
      wNumCoef:WORD;
      aCoef:ADPCMCOEFSET_Array(0..0);    -- Always 7 coefficient pairs for MS ADPCM
   end record;

   subtype ADPCMWAVEFORMAT is adpcmwaveformat_tag;

   -- audiodefs.h:149
   WAVE_FORMAT_ADPCM : constant := 16#0002#;

   -- Other frequently used format tags
   
   -- audiodefs.h:156
   WAVE_FORMAT_UNKNOWN : constant := 16#0000#; -- Unknown or invalid format tag

   -- audiodefs.h:160
   WAVE_FORMAT_IEEE_FLOAT : constant := 16#0003#; -- 32-bit floating-point

   -- audiodefs.h:164
   WAVE_FORMAT_MPEGLAYER3 : constant := 16#0055#; -- ISO/MPEG Layer3

   -- audiodefs.h:168
   WAVE_FORMAT_DOLBY_AC3_SPDIF : constant := 16#0092#; -- Dolby Audio Codec 3 over S/PDIF

   -- audiodefs.h:172
   WAVE_FORMAT_WMAUDIO2 : constant := 16#0161#; -- Windows Media Audio

   -- audiodefs.h:176
   WAVE_FORMAT_WMAUDIO3 : constant := 16#0162#; -- Windows Media Audio Pro

   -- audiodefs.h:180
   WAVE_FORMAT_WMASPDIF : constant := 16#0164#; -- Windows Media Audio over S/PDIF

   -- audiodefs.h:184
   WAVE_FORMAT_EXTENSIBLE : constant := 16#FFFE#; -- All WAVEFORMATEXTENSIBLE formats
   
   function uuidof(s:string) return win32.rpcdce.guid;
   
--/**************************************************************************
-- *
-- *  Define the most common wave format GUIDs used in WAVEFORMATEXTENSIBLE
-- *  formats.  Note that including the Windows ksmedia.h header after this
-- *  one will cause build problems; this cannot be avoided, since ksmedia.h
-- *  defines these macros without preprocessor guards.
-- *
-- ***************************************************************************/
   
   pragma Warnings(Off);
   -- audiodefs.h:201
   KSDATAFORMAT_SUBTYPE_PCM:constant win32.rpcdce.GUID:=uuidof("00000001-0000-0010-8000-00aa00389b71");

   -- audiodefs.h:206
   KSDATAFORMAT_SUBTYPE_ADPCM:constant win32.rpcdce.GUID:=uuidof("00000002-0000-0010-8000-00aa00389b71");

   -- audiodefs.h:211
   KSDATAFORMAT_SUBTYPE_IEEE_FLOAT:constant win32.rpcdce.GUID:=uuidof("00000003-0000-0010-8000-00aa00389b71");
   
   pragma Warnings(On);
   
   -- Speaker positions used in the WAVEFORMATEXTENSIBLE dwChannelMask field.
   
   SPEAKER_FRONT_LEFT            :constant:=16#00000001#;
   SPEAKER_FRONT_RIGHT           :constant:=16#00000002#;
   SPEAKER_FRONT_CENTER          :constant:=16#00000004#;
   SPEAKER_LOW_FREQUENCY         :constant:=16#00000008#;
   SPEAKER_BACK_LEFT             :constant:=16#00000010#;
   SPEAKER_BACK_RIGHT            :constant:=16#00000020#;
   SPEAKER_FRONT_LEFT_OF_CENTER  :constant:=16#00000040#;
   SPEAKER_FRONT_RIGHT_OF_CENTER :constant:=16#00000080#;
   SPEAKER_BACK_CENTER           :constant:=16#00000100#;
   SPEAKER_SIDE_LEFT             :constant:=16#00000200#;
   SPEAKER_SIDE_RIGHT            :constant:=16#00000400#;
   SPEAKER_TOP_CENTER            :constant:=16#00000800#;
   SPEAKER_TOP_FRONT_LEFT        :constant:=16#00001000#;
   SPEAKER_TOP_FRONT_CENTER      :constant:=16#00002000#;
   SPEAKER_TOP_FRONT_RIGHT       :constant:=16#00004000#;
   SPEAKER_TOP_BACK_LEFT         :constant:=16#00008000#;
   SPEAKER_TOP_BACK_CENTER       :constant:=16#00010000#;
   SPEAKER_TOP_BACK_RIGHT        :constant:=16#00020000#;
   SPEAKER_RESERVED              :constant:=16#7FFC0000#;
   SPEAKER_ALL                   :constant:=16#80000000#;
     
   use type Interfaces.C.unsigned_long;
   
   SPEAKER_MONO             :constant:=(SPEAKER_FRONT_CENTER);
   SPEAKER_STEREO           :constant dword:=(SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT);
   SPEAKER_2POINT1          :constant dword:=(SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT or SPEAKER_LOW_FREQUENCY);
   SPEAKER_SURROUND         :constant dword:=(SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT or SPEAKER_FRONT_CENTER or SPEAKER_BACK_CENTER);
   SPEAKER_QUAD             :constant dword:=(SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT or SPEAKER_BACK_LEFT or SPEAKER_BACK_RIGHT);
   SPEAKER_4POINT1          :constant dword:=(SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT or SPEAKER_LOW_FREQUENCY or SPEAKER_BACK_LEFT or SPEAKER_BACK_RIGHT);
   SPEAKER_5POINT1          :constant dword:=(SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT or SPEAKER_FRONT_CENTER or SPEAKER_LOW_FREQUENCY or SPEAKER_BACK_LEFT or SPEAKER_BACK_RIGHT);
   SPEAKER_7POINT1          :constant dword:=(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);
   SPEAKER_5POINT1_SURROUND :constant dword:=(SPEAKER_FRONT_LEFT or SPEAKER_FRONT_RIGHT or SPEAKER_FRONT_CENTER or SPEAKER_LOW_FREQUENCY or SPEAKER_SIDE_LEFT or SPEAKER_SIDE_RIGHT);
   SPEAKER_7POINT1_SURROUND :constant dword:=(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);




   --
   -- THE END
   --


end audiodefs;







--------------------------------------------
-- DirectX SDK (August 2009) Ada package  --
-- Translator: Gu.Dongfeng(顾冬峰),2018   --
-- E-mail:[email protected]                   --
-- 为了Ada在应用层面的推广而翻译之        --
--------------------------------------------


with Ada.Characters.Handling;

package body audiodefs is

   pragma linker_options("-lole32");
   procedure ClsIdFromString(ws:wide_String;gid:in out win32.rpcdce.guid);
   pragma Import (Stdcall, CLSIDFromString, "CLSIDFromString");

   function uuidof(s:string) return win32.rpcdce.guid is
      gid:win32.rpcdce.GUID:=(0,0,0,(others=>0));
   begin
      if s(s'first)='{' and s(s'last)='}' then
         ClsIdFromString(Ada.Characters.Handling.TO_WIDE_STRING(s&character'val(0)),gid);
      else
         ClsIdFromString(Ada.Characters.Handling.TO_WIDE_STRING("{"&s&"}"&character'val(0)),gid);
      end if;
      return gid;
   end uuidof;

end audiodefs;






猜你喜欢

转载自blog.csdn.net/adacore/article/details/83144401
今日推荐