DirectSound Mixer Sample

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



Comments

  • undefine DSBCAPS_CTRLDEFAULT

    Posted by wave826 on 12/18/2009 10:37pm

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

    Reply
  • I whould like to learn how to use DirectSoundFullDuplex Object

    Posted by Legacy on 03/27/2003 12: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 ;)
    thanks

    Reply
  • Voice recognition

    Posted by Legacy on 10/21/2002 12: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 05:55am

      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.

      Reply
    Reply
  • Solution to the DSBCAPS_CTRLDEFAULT problem

    Posted by Legacy on 08/02/2002 12: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

    DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY.

    replace the DSBCAPS_CTRLDEFAULT by the line just above...

    http://www.mvps.org/directx/faq/direct_sound.htm#dsound_defcap

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

    Reply
  • Visual Basic Project For Calling Sounds and Pictures

    Posted by Legacy on 04/22/2002 12: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

    Gbolahan.

    Reply
  • Directx Installed or not

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

    Originally posted by: Sharma

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

    Reply
  • Tell me more about DIRECTSOUNDNOTIFY

    Posted by Legacy on 11/08/2001 12: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

    Reply
  • How to play captured sounds?

    Posted by Legacy on 10/17/2001 12: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,
    Claudio
    Siena - Italy

    Reply
  • Does Not Compile, DSBCAPS_CTRLDEFAULT Undefined

    Posted by Legacy on 08/22/2001 12: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
    Franklin

    Reply
  • Does Not Compile, DSBCAPS_CTRLDEFAULT Undefined

    Posted by Legacy on 08/22/2001 12: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
    Franklin

    Reply
  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • Download the Information Governance Survey Benchmark Report to gain insights that can help you further establish business value in your Records and Information Management (RIM) program and across your entire organization. Discover how your peers in the industry are dealing with this evolving information lifecycle management environment and uncover key insights such as: 87% of organizations surveyed have a RIM program in place 8% measure compliance 64% cannot get employees to "let go" of information for …

  • On-demand Event Event Date: March 27, 2014 Teams need to deliver quality software faster and need integrated agile planning, task tracking, source control, auto deploy with continuous builds and a configurable process to adapt to the way you work. Rational Team Concert and DevOps Services (JazzHub) have everything you need to build great software, integrated seamlessly together right out of the box or available immediately in the cloud. And with the Rational Team Concert Client, you can connect your …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds