?/TD>
Microsoft DirectX 9.0

DrumPad Sample


Description

The DrumPad sample transforms every input device on your computer (joysticks, joypads, keyboard, and mouse) into an audio drum machine using Action Mapping and Microsoft?DirectX?Audio. You can load different sound files to be played for each "drum".

Path

Source: (SDK root)\Samples\C++\DirectInput\DrumPad

Executable: (SDK root)\Samples\C++\DirectInput\Bin\DrumPad.exe

User's Guide

DrumPad has eight sound slots that are mapped to controls on the input devices on your system. The sample attempts to load default sound files from the ..\..\media directory. However, you can load any sound file into each of the slots.

To play the sounds, hit the mapped buttons on your joystick,joypad, keyboard, or mouse. You should see the corresponding green box light up on the right. Any number of devices can used simultaneously.

To load a sound into one of the slots, for example Bass Drum, click the corresponding Bass Drum button. This will open the Open Sound File window. Choose a new .wav file and click Open to finalize your choice.

To see which sound slot is mapped to which button, click View Device Mappings. You cannot change the device mappings in this sample.

Programming Notes

DrumPad uses action mapping to have Microsoft DirectInput?map each sound action to a control. The sound actions include:

Actions are mapped to Action Mapping Constants, which include genre-specific joystick actions, keyboard buttons, and mouse buttons. The DrumPad sample uses an arbitrary genre. You can observe how everything is mapped by seeing the device mappings during runtime.

The audio is done by encapsulating an array of DirectSoundBuffers or DirectMusicSegments. The game loop polls the devices and process the input by calling the DrumPad class and playing a sound.



© 2002 Microsoft Corporation. All rights reserved.