Platform SDK: DirectX

Integrating DirectMusic and DirectSound

The Microsoft Software Synthesizer and other synthesizers normally stream their output wave data to a DirectSound buffer. DirectMusic is capable of handling all the details of linking to DirectSound without any action on your part. When it creates or links to a DirectSound object, DirectMusic ensures that the primary buffer format matches that of the highest format among all DirectMusic ports.

[C++]

In an application that uses only music files for its soundtrack and does not require DirectSound for playing wave files or resources, the DirectSound object is typically created when the DirectMusic performance is initialized. This is shown in the following example, in which pPerf is a pointer to the IDirectMusicPerformance interface:

pPerf->Init(NULL, NULL, hwnd);

In this example, the first NULL specifies that the DirectMusic object is to be created and managed internally, the second NULL specifies the same for the DirectSound object, and hwnd is the handle of the controlling window for DirectSound.

Note  It is a good idea to supply the top-level application window handle when requesting that DirectMusic create the DirectSound object. See the Remarks for IDirectMusicPerformance::Init and IDirectSound::SetCooperativeLevel.

[Visual Basic]

In an application that uses only music files for its soundtrack and does not require DirectSound for playing wave files or resources, the DirectSound object is typically created when the DirectMusic performance is initialized. This is shown in the following example, where Perf is a DirectMusicPerformance object:

Perf.Init(Nothing, hwnd);

In this example, Nothing specifies that the DirectSound object is to be created and managed internally, and hwnd is the handle of the controlling window for DirectSound.

Note  It is a good idea to supply the top-level application window handle when requesting that DirectMusic create the DirectSound object. See the Remarks for DirectMusicPerformance.Init and DirectSound.SetCooperativeLevel.

More information is contained in the following topics: