Virtual Developer Workshop: Containerized Development with Docker

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



    Posted by wave826 on 12/19/2009 06:37am

    convert to VC2005,error report undefine DSBCAPS_CTRLDEFAULT. why? thk!

  • I whould like to learn how to use DirectSoundFullDuplex Object

    Posted by Legacy on 03/27/2003 08:00am

    Originally posted by: Aquatic

    I�m a beginner in DirectSound and I whant to setup a a full duplex audio system with DirectSound 9 with directSoundFullDuplex Object but I don�t kno how.

    Help me please ;)

  • Voice recognition

    Posted by Legacy on 10/21/2002 07:00am

    Originally posted by: Oyster

    Recently, i was carry out a project which using Visual C++ to capture the user voice through a microphone and than transformit into text form. Is it anybody here can give me some ideal on how to code it?or anybody is experience in this field can give me a hand. Thank you very much.

    • Ergent!!! SOS!!! Need Help!!!

      Posted by crazywhale on 06/12/2008 12:55pm

      I want to write a program for the voice recognition and this program is use to control a control car.Can you give me a example to write this type of program. if can, can you send it to my email address, thanks.My email address is xiao_hui1016@hotmail.com. Hope can get the information as soon as possible. Thanks you so much.

  • Solution to the DSBCAPS_CTRLDEFAULT problem

    Posted by Legacy on 08/02/2002 07:00am

    Originally posted by: Etienne

    In order to help people who have DirectX 7 like me...

    Q. Why, when compiling in DirectX 7, does using the DSBCAPS_CTRLDEFAULT cause an error?
    This flag has been removed to encourage utilizing only those flags that are needed.
    This minimizes the resources needed, and in some cases may provide
    better selection of appropriate devices.
    This flag was previously defined as


    replace the DSBCAPS_CTRLDEFAULT by the line just above...


    I would like to thank the people who brought this
    great code !
    Thank you.
    You're of great help.

  • Visual Basic Project For Calling Sounds and Pictures

    Posted by Legacy on 04/22/2002 07:00am

    Originally posted by: Gbolahan Oduyiga

    I am presently working of a Sound /picture project which is to be interfaced with visual basic. I have been on this project since and I have a deadline which is just about three days after today. The visual basic programme is meant to call the pictures and the sounds for instance when a particular sound is played, a picture flashes out to compliment it. Please I would like you to send me vbcodes necessary to implement this project and i will aslo appreciate it if samples of similar project can be sent to me.

    Thanks so much for your help


  • Directx Installed or not

    Posted by Legacy on 01/03/2002 08:00am

    Originally posted by: Sharma

    Could u tell me if there is a DirectX Api that helps to find if Directx is installed on the system or not.

  • Tell me more about DIRECTSOUNDNOTIFY

    Posted by Legacy on 11/08/2001 08:00am

    Originally posted by: li_zuo_min

    I want to use DIRECTSOUNDNOTIFY,but i am not amiliar
    with it. help me! if you can ,give me a sample.
    My address : li_zuo_min@sina.com

  • How to play captured sounds?

    Posted by Legacy on 10/17/2001 07:00am

    Originally posted by: Claudio

    Hi to everyone.
    I would like to capture a sound from a microphone and I want to play it without delay,or only few milliseconds.
    In a second time I would like to add an echo effect.

    Has anyone any advice for me?
    Thanks in advance,
    Siena - Italy

  • Does Not Compile, DSBCAPS_CTRLDEFAULT Undefined

    Posted by Legacy on 08/22/2001 07:00am

    Originally posted by: Franklin

    Hi this code does not compile, The Compiler reports that DSBCAPS_CTRLDEFAULT is not defined. How do I over come this Problem. Help!!!!!

    Thanks in Advance

  • Does Not Compile, DSBCAPS_CTRLDEFAULT Undefined

    Posted by Legacy on 08/22/2001 07:00am

    Originally posted by: Franklin

    Hi this code does not compile, The Compiler reports that DSBCAPS_CTRLDEFAULT is not defined. How do I over come this Problem. Help!!!!!

    Thanks in Advance

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date