Package com.ms.com.directX Previous
Previous
Microsoft Packages
Microsoft Packages
Index
Index
Next
Next

Class dSound

Applications use the methods of the dSound class to create DirectSound objects and set up the environment.

public class dSound implements IdSound
{
  public void InternalSetObject(IUnknown lpdd);
  public IUnknown InternalGetObject();
  public dSoundBuffer CreateSoundBuffer(DSBufferDesc desc, byte[] w, IUnknown p);
  public  dSoundBuffer CreateSoundBuffer(DSBufferDesc desc, WaveFormatEx w, IUnknown p);
  public void GetCaps(DSCaps p);
  public void DSEnumerate(IDSEnumCallback fn, IUnknown lpargs);
  public dSoundBuffer DuplicateSoundBuffer(dSoundBuffer p);
  public void SetCooperativeLevel(int hdl, int data);
  public void Compact();
  public void GetSpeakerConfig(int[] data);
  public void SetSpeakerConfig(int data);
  public void Initialize(GuidData g);
}

The methods can be organized into the following groups:
Allocating memory Compact
Initialize
Creating buffers CreateSoundBuffer
DuplicateSoundBuffer
SetCooperativeLevel
Device capabilities GetCaps
DSEnumCallback
Speaker configuration GetSpeakerConfig
SetSpeakerConfig

Compact

public void Compact();

Moves the unused portions of onboard sound memory, if any, to a contiguous block so that the largest portion of free memory will be available.

Return Value:

No return value.

Remarks:

If the application calls this method, it must have exclusive cooperation with the DirectSound object. (To get exclusive access, specify DSSCL_EXCLUSIVE in a call to the SetCooperativeLevel method.) This method will fail if any operations are in progress.

See Also: SetCooperativeLevel


CreateSoundBuffer

public dSoundBuffer CreateSoundBuffer(DSBufferDesc desc, byte[] w, IUnknown p);

Creates a dSoundBuffer object to hold a sequence of audio samples.

Return Value:

Returns the dSoundBuffer object if successful; null otherwise.

ParameterDescription
desc A DSBufferDesc object that contains the description of the sound buffer to be created.
w Array variable that specifies the wave format for the sound buffer.
p Reserved; must be null.

Remarks:

Before it can play any sound buffers, the application must specify a cooperative level for a DirectSound object by using the SetCooperativeLevel method.

The desc parameter is an object that describes the type of buffer desired, including format, size, and capabilities. The application must specify the needed capabilities, or they will not be available. For example, if the application creates a dSoundBuffer object without specifying the DSBCAPS_CTRLFREQUENCY flag, any call to SetFrequency will fail.

The DSBCAPS_STATIC flag can also be specified, in which case DirectSound stores the buffer in onboard memory, if available, in order to take advantage of hardware mixing. To force the buffer to use either hardware or software mixing, use the DSBCAPS_LOCHARDWARE or DSBCAPS_LOCSOFTWARE flags.

See Also: DSBufferDesc, DuplicateSoundBuffer, SetCooperativeLevel


CreateSoundBuffer

public  dSoundBuffer CreateSoundBuffer(DSBufferDesc desc, WaveFormatEx w, IUnknown p);

Creates a dSoundBuffer object to hold a sequence of audio samples.

Return Value:

Returns the dSoundBuffer object if successful; null otherwise.

ParameterDescription
desc A DSBufferDesc object that contains the description of the sound buffer to be created.
w A WaveFormatEx object that specifies the wave format for the sound buffer.
p Reserved; must be null.

Remarks:

Before it can play any sound buffers, the application must specify a cooperative level for a DirectSound object by using the SetCooperativeLevel method.

The desc parameter is an object that describes the type of buffer desired, including format, size, and capabilities. The application must specify the needed capabilities, or they will not be available. For example, if the application creates a dSoundBuffer object without specifying the DSBCAPS_CTRLFREQUENCY flag, any call to SetFrequency will fail.

The DSBCAPS_STATIC flag can also be specified, in which case DirectSound stores the buffer in onboard memory, if available, in order to take advantage of hardware mixing. To force the buffer to use either hardware or software mixing, use the DSBCAPS_LOCHARDWARE or DSBCAPS_LOCSOFTWARE flags.

See Also: DSBufferDesc, DuplicateSoundBuffer, SetCooperativeLevel


DSEnumerate

public void DSEnumerate(IDSEnumCallback fn, IUnknown lpargs);

Enumerates the DirectSound drivers installed in the system.

Return Value:

No return value.

ParameterDescription
fn The IDSEnumCallback interface that contains the callback function to be called for each DirectSound object installed in the system.
lpargs User-defined context passed to the enumeration callback function every time that function is called.


DuplicateSoundBuffer

public dSoundBuffer DuplicateSoundBuffer(dSoundBuffer p);

Creates a new dSoundBuffer object that uses the same buffer memory as the original object.

Return Value:

Returns the dSoundBuffer object if successful; null otherwise.

ParameterDescription
p The dSoundBuffer object to be duplicated.

Remarks:

The new object can be used just like the original.

Initially, the duplicate buffer will have the same parameters as the original buffer. However, the application can change the parameters of each buffer independently, and each can be played or stopped without affecting the other.

If data in the buffer is changed through one object, the change will be reflected in the other object since the buffer memory is shared.

The buffer memory will be released when the last object referencing it is released.

See Also: CreateSoundBuffer


GetCaps

public void GetCaps(DSCaps p);

Retrieves the capabilities of the hardware device that is represented by the DirectSound object.

Return Value:

No return value.

ParameterDescription
p The DSCaps object that receives the capabilities of this sound device.

Remarks:

Information retrieved in the DSCaps object describes the maximum capabilities of the sound device and those currently available, such as the number of hardware mixing channels and the amount of onboard sound memory. This information can be used to fine-tune performance and optimize resource allocation.

Because of resource sharing requirements, the maximum capabilities in one area might only be available at the cost of another area. For example, the maximum number of hardware-mixed streaming sound buffers may only be available if there are no hardware static sound buffers.

See Also: DirectSoundCreate, DSCaps


GetSpeakerConfig

public void GetSpeakerConfig(int[] data);

Retrieves the speaker configuration specified for this DirectSound object.

Return Value:

No return value.

ParameterDescription
data Array variable that receives the speaker configuration for this DirectSound object. The speaker configuration is specified with one value of DSSPEAKER_ type.

See Also: SetSpeakerConfig


Initialize

public void Initialize(GuidData g);

Initializes the dSound object if it has not yet been initialized.

Return Value:

No return value.

ParameterDescription
g The GUID specifying the sound driver for this DirectSound object to bind to, or null to select the primary sound driver.

Remarks:

Because the DirectSoundCreate function calls this method internally, it is not needed for the current release of DirectSound.

See Also: DirectSoundCreate


SetCooperativeLevel

public void SetCooperativeLevel(int hdl, int data);

Sets the cooperative level of the application for this sound device.

Return Value:

No return value.

ParameterDescription
hd1 Window handle for the application.
data One value of DSSCL_ type, specifying the requested priority level.

Remarks:

The application must set the cooperative level by calling this method before its buffers can be played. The recommended cooperative level is DSSCL_NORMAL; use other priority levels when necessary.

See Also: Compact


SetSpeakerConfig

public void SetSpeakerConfig(int data);

Specifies the speaker configuration for the DirectSound object.

Return Value:

No return value.

ParameterDescription
data One value of DSSPEAKER_ type, specifying the speaker configuration of the specified DirectSound object.

See Also: GetSpeakerConfig



Top© 1996 Microsoft Corporation. All rights reserved.