Delphi Graphics and Game Programming Exposed! with DirectX For versions 5.0-7.0:Sound and Music
Search Tips
Advanced Search
Title
Author
Publisher
ISBN
Please Select
-----------
Artificial Intel
Business & Mgmt
Components
Content Mgmt
Certification
Databases
Enterprise Mgmt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Productivity Apps
Programming Langs
Security
Soft Engineering
UI
Web Services
Webmaster
Y2K
-----------
New Arrivals
Delphi Graphics and Game Programming Exposed with DirectX 7.0
by John Ayres
Wordware Publishing, Inc.
ISBN: 1556226373 Pub Date: 12/01/99
Search this book:
Previous
Table of Contents
Next
Of particular interest to the game programmer is the value of the dwFlags member. This member contains a combination of one or more flags that indicate device capabilities. Specifically, if the DSCAPS_EMULDRIVER flag is included in this value, a DirectSound driver is not actually present in the system, and all DirectSound functionality is being emulated. This means that no hardware acceleration is available, secondary sound buffers can only be created in system memory, and playback latency will be higher. See the example program in Listing 9-3 for a list of available flags.
The TDSCaps structure is defined as:
TDSCaps = packed record
dwSize: DWORD; // the size of the structure, in bytes
dwFlags: DWORD; // capability flags
dwMinSecondarySampleRate: DWORD; // minimum sample rate for secondary
buffers in hardware
dwMaxSecondarySampleRate: DWORD; // maximum sample rate for secondary
buffers in hardware
dwPrimaryBuffers: DWORD; // number of primary buffers (always 1)
dwMaxHwMixingAllBuffers: DWORD; // maximum number of hardware buffers
dwMaxHwMixingStaticBuffers: DWORD; // maximum number of static hardware
buffers
dwMaxHwMixingStreamingBuffers: DWORD; // maximum number of streaming hardware
buffers
dwFreeHwMixingAllBuffers: DWORD; // number of free hardware buffers
dwFreeHwMixingStaticBuffers: DWORD; // number of free static hardware
buffers
dwFreeHwMixingStreamingBuffers: DWORD;// number of free streaming hardware
buffers
dwMaxHw3DAllBuffers: DWORD; // maximum number of 3-D hardware
buffers
dwMaxHw3DStaticBuffers: DWORD; // maximum number of 3-D static hardware
buffers
dwMaxHw3DStreamingBuffers: DWORD; // maximum number of 3-D streaming
hardware buffers
dwFreeHw3DAllBuffers: DWORD; // number of free 3-D hardware buffers
dwFreeHw3DStaticBuffers: DWORD; // number of free 3-D static hardware
buffers
dwFreeHw3DStreamingBuffers: DWORD; // number of free 3-D streaming hardware
buffers
dwTotalHwMemBytes: DWORD; // total hardware memory, in bytes
dwFreeHwMemBytes: DWORD; // free hardware memory, in bytes
dwMaxContigFreeHwMemBytes: DWORD; // largest contiguous block of free
hardware memory, in bytes
dwUnlockTransferRateHwBuffers: DWORD; // rate of data transfer to hardware
buffers, in kilobytes per second
dwPlayCpuOverheadSwBuffers: DWORD; // percentage of CPU cycles used to mix
software buffers
dwReserved1: DWORD; // reserved, not used
dwReserved2: DWORD; // reserved, not used
end;
The following example demonstrates how to create the DirectSound object, set its cooperative level, and retrieve audio hardware capabilities.
Listing 9-3: Creating DirectSound and retrieving hardware capabilities
procedure TForm1.FormCreate(Sender: TObject);
var
DXSound: IDirectSound;
DevCaps: TDSCaps;
begin
{create the DirectSound object}
DirectSoundCreate(nil, DXSound, nil);
{set its cooperative level to the lowest setting, as we only need to
retrieve device capabilities}
DXSound.SetCooperativeLevel(Handle, DSSCL_NORMAL);
{initialize the TDSCaps structure}
FillChar(DevCaps, SizeOf(TDSCaps), 0);
DevCaps.dwSize := SizeOf(TDSCaps);
{retrieve the capabilities of the audio hardware}
DXSound.GetCaps(DevCaps);
{display general device capabilities}
with lbxDevCaps.Items do
begin
Add(General driver capabilities -);
Add()
if (DevCaps.dwFlags and DSCAPS_CERTIFIED) = DSCAPS_CERTIFIED then
Add(Driver tested and certified by Microsoft);
if (DevCaps.dwFlags and DSCAPS_CONTINUOUSRATE) = DSCAPS_CONTINUOUSRATE then
Add(Supports all sample rates between min and max);
if (DevCaps.dwFlags and DSCAPS_EMULDRIVER) = DSCAPS_EMULDRIVER then
Add(No DirectSound driver detected);
if (DevCaps.dwFlags and DSCAPS_PRIMARY16BIT) = DSCAPS_PRIMARY16BIT then
Add(Supports 16-bit primary buffer);
if (DevCaps.dwFlags and DSCAPS_PRIMARY8BIT) = DSCAPS_PRIMARY8BIT then
Add(Supports 8-bit primary buffer);
if (DevCaps.dwFlags and DSCAPS_PRIMARYMONO) = DSCAPS_PRIMARYMONO then
Add(Supports a 1-channel primary buffer);
if (DevCaps.dwFlags and DSCAPS_PRIMARYSTEREO) = DSCAPS_PRIMARYSTEREO then
Add(Supports a 2-channel primary buffer);
if (DevCaps.dwFlags and DSCAPS_SECONDARY16BIT) = DSCAPS_SECONDARY16BIT then
Add(Supports 16-bit hardware mixed secondary buffers);
if (DevCaps.dwFlags and DSCAPS_SECONDARY8BIT) = DSCAPS_SECONDARY8BIT then
Add(Supports 8-bit hardware mixed secondary buffers);
if (DevCaps.dwFlags and DSCAPS_SECONDARYMONO) = DSCAPS_SECONDARYMONO then
Add(Supports 1 channel hardware mixed secondary buffers);
if (DevCaps.dwFlags and DSCAPS_SECONDARYSTEREO)=DSCAPS_SECONDARYSTEREO then
Add(Supports 2 channel hardware mixed secondary buffers);
Add(Number of primary buffers: +IntToStr(DevCaps.dwPrimaryBuffers));
Add(Software mixing CPU overhead: +
IntToStr(DevCaps.dwPlayCpuOverheadSwBuffers)+%);
{if the driver is a true DirectSound driver, it can take advantage of any
hardware acceleration, so display hardware-specific attributes}
if (DevCaps.dwFlags and DSCAPS_EMULDRIVER) DSCAPS_EMULDRIVER then
begin
Add();
Add();
Add(Hardware specific capabilities -);
Add();
Add(Minimum secondary hardware buffer sample rate: +
IntToStr(DevCaps.dwMinSecondarySampleRate));
Add(Maximum secondary hardware buffer sample rate: +
IntToStr(DevCaps.dwMaxSecondarySampleRate));
Add(Maximum hardware buffers: +
IntToStr(DevCaps.dwMaxHwMixingAllBuffers));
Add(Maximum static hardware buffers: +
IntToStr(DevCaps.dwMaxHwMixingStaticBuffers));
Add(Maximum streaming hardware buffers: +
IntToStr(DevCaps.dwMaxHwMixingStreamingBuffers));
Add(Free hardware buffers:+IntToStr(DevCaps.dwFreeHwMixingAllBuffers));
Add(Free static hardware buffers: +
IntToStr(DevCaps.dwFreeHwMixingStaticBuffers));
Add(Free streaming hardware buffers: +
IntToStr(DevCaps.dwFreeHwMixingStreamingBuffers));
Add(Maximum 3-D hardware buffers: +
IntToStr(DevCaps.dwMaxHw3DAllBuffers));
Add(Maximum 3-D static hardware buffers: +
IntToStr(DevCaps.dwMaxHw3DStaticBuffers));
Add(Maximum 3-D streaming hardware buffers: +
IntToStr(DevCaps.dwMaxHw3DStreamingBuffers));
Add(Free 3-D hardware buffers: +IntToStr(DevCaps.dwFreeHw3DAllBuffers));
Add(Free 3-D static hardware buffers: +
IntToStr(DevCaps.dwFreeHw3DStaticBuffers));
Add(Free 3-D streaming hardware buffers: +
IntToStr(DevCaps.dwFreeHw3DStreamingBuffers));
Add(Total hardware memory: +IntToStr(DevCaps.dwTotalHwMemBytes)+ bytes);
Add(Free hardware memory: +IntToStr(DevCaps.dwFreeHwMemBytes)+ bytes);
Add(Maximum contiguous free hardware memory: +
IntToStr(DevCaps.dwMaxContigFreeHwMemBytes)+ bytes);
Add(Data transfer rate: +
IntToStr(DevCaps.dwUnlockTransferRateHwBuffers)+ kb per second);
end;
end;
end;
Figure 9-4: The audio hardware capabilities
Previous
Table of Contents
Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.
Wyszukiwarka
Podobne podstrony:
TI 01 09 06 T pl(2)wyklad 10 09 06 2 komorka chemwyklad 10 09 06 2 komorka budowaxenon E83 od 09 06TI 99 09 06 B pl(1)TO 09 06 2013Referendum ws paktu bezpieczeństwa opóźnione (09 06 2009)pdm? 2016 09 0609 06 19 DTZ prezentacja tenant mix FINAL1TI 98 09 06 T pl(1)TI 01 09 06 T B pl(2)09 06 Transport reczny i mechaniczny normy dzwiganiaTI 03 09 06 T pl(1)więcej podobnych podstron