DirectSound Mixer Sample

Friday Jan 22nd 1999 by B Lobster
Share:

DirectSound Mixer or DSMixer helps you create many DirectSound PCM wave secondary buffers and play them together


DirectSound Mixer or DSMixer helps you create many DirectSound PCM wave secondary buffers and play them together.

This sample is based on the CodeGuru StackUp game sample by Tool@theWaterCooler.com

The main part of this sample is the CDSBuffer class which wraps the DirectSoundBuffer Object. New buffers can be created by supplying the (wave) file name in the constructor. CDSBuffer is derived from CObject. This helps in maintaining all these buffer in a CObList, or a class derived from CObList like CDSList. CDSList can be described as the class that wraps the DirectSound Object. To use this class, the Init() member function should be called to create the DirectSound Object and set the cooperative level. Here DirectSoundCreate() has been used rather than CoCreateInstance() to create the DirectSound Object.

One can mix sounds from different CDSBuffer instances simply by playing them at the same time. Data from CDSBuffer instances is mixed by DirectSound in the primary buffer. Any number of CDSBuffer instances can be played at one time, up to the limits of processing power.

Basic 3D Buffer support is also built into the CDSBuffer class. The buffer can be moved around and placed in an abitary position in 3D space. Similarly, the velocity of the buffer can also be set to generate sound effects due to doppler effect.

To create a CDSBuffer object a pointer to the DirectSound Object (LPDIRECTSOUND) is to be supplied and a CDSList instance can provide this. Alternatively to take use of MFC's Doc-View architecture a CDSBuffer instance can be defined in the CDocument derived class and something similar to CDSList can be maintained in the CWinApp derived application class. This is the way things have been done in the accompanying demo project.

The source code was built and tested with Visual C++ 6.0 and DirectX 6 in Windows 98 and Windows NT 4.0 (with Internet Explorer 4.0) on Intel platform.





Download demo project - 249 KB

Download CDSMixer and CDSList source - 5 KB

Date Posted: January 22, 1999

Share:
Home
Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved