1 / 27

Ray Bradley Karla N. Juárez David Wood Advisor: Dr. Stephen Murrell May 2 nd , 2005

Ray Bradley Karla N. Juárez David Wood Advisor: Dr. Stephen Murrell May 2 nd , 2005. Overview. What is DMC? Implementation choices Equipment used Coding the game Beat detection Direct input Graphics Integration Testing Demonstration Improvements Thoughts. What is DMC?.

Télécharger la présentation

Ray Bradley Karla N. Juárez David Wood Advisor: Dr. Stephen Murrell May 2 nd , 2005

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ray Bradley Karla N. Juárez David Wood Advisor: Dr. Stephen Murrell May 2nd, 2005

  2. Overview • What is DMC? • Implementation choices • Equipment used • Coding the game • Beat detection • Direct input • Graphics • Integration • Testing • Demonstration • Improvements • Thoughts

  3. What is DMC? • DMC is based on very popular arcade game Dance Dance Revolution (DDR) • Simple Idea • Players stand on a mat • Step on the arrows that correspond to scrolling arrows • DMC is an enhanced version of DDR • Detects beats in real-time • Use your own music

  4. DMC’s Features • Users choose a sound (.wav) file • Players can adjust • The frequency the game uses to find beats • The sensitivity used in determining beats • When a beat is detected in real-time, game randomly grabs a dance pattern and executes that pattern

  5. Choices for Implementation • Graphics Library • OpenGL • DirectX • DirectInput • Coding Language • Java • C++ • Compatible with graphics libraries • Widely used in game programming • Beat Detection • Simple Sound Energy Algorithm • Frequency Selected Sound Energy Algorithm • Detection based on frequency • Detected beats missed by Simple Algorithm • Sound File Format • .WAV • Raw data • No compression

  6. Gathering Equipment • MadCatz Beat Pad for Sony Playstation • Playstation to USB Converter/Adapter

  7. Coding Overview • Beat Detection • Obtaining input from dance pad using DirectX • Graphics using DirectX

  8. Beat Detection Theory • Sound Energy Algorithm • A beat is heard when the sound energy at that instant is greater than average of previous energies. • Instant ~ 23 ms • Sound History ~ 1 sec • Fast Fourier Transform • Separate sound into frequency sub-bands • Detect beats at specific frequency ranges

  9. Beat Detection Implementation • Wave File • 44100 samples/sec • Stereo (2 channels) • Compute FFT of buffers, Left and Right • Packed together; Left: Real, Right: Imaginary • Unpacked with aid of the Fourier symmetries:

  10. Beat Detection Implementation • Compute magnitude of complex pairs at chosen frequency sub-band • Sub-bands • 43 sub-bands • Width grows exponentially with frequency

  11. Beat Detection Implementation • Compare computed instant energy density with local average energy density multiplied by a sensitivity constant • Adjust local average energy density by adding in newest and subtracting out oldest

  12. Reading/Playing Wave Files • Wave Reader Class • Reads wave file • Supplies pointer to data buffer • Methods to refill the data buffer • Buffered Player Class • Manages communication with windows sound device • Uses 10 level buffering scheme • Accepts pointer to data buffer and refill function

  13. DirectX’s Input Method • DirectInput gathers information from input device • Classes are designed to accommodate various devices • More control than using the Windows API for input devices

  14. DirectInput • “Joystick” class provides access to functions specifically for “joystick” control • The following functions were used to access gamepad • EnumDevicesCallback(); • EnumObjectsCallback(); • DirectInput8Create(); • g_lpDI->EnumDevices( DI8DEVCLASS_GAMECTRL, EnumDevicesCallback, NULL, DIEDFL_ATTACHEDONLY) • g_joystickDevice->EnumObjects( EnumObjectsCallback, NULL, DIDFT_ALL) • g_joystickDevice->Acquire();

  15. DirectInput • Once the object has been “created” and “acquired” only two function calls are necessary to gather the pad’s input • g_joystickDevice->Poll(); • g_joystickDevice->GetDeviceState( sizeof(DIJOYSTATE2), &gamepad );

  16. The Axis Problem • Driver for converter detects arrow pads as axes • Buffer was designed to remember the last 6 inputs • Could not be too large or it would affect game play • Timer controlled how often buffer would be updated

  17. Contacting Soyo • Attempts were made to find alternative drivers for the converter • Contacted Soyo, still waiting for answer

  18. Coding the Graphics • Two classes were created • Arrow Outline • Stationary • 4 objects used in game • Scrolling Arrow • Movement is required • 5 arrows for each direction are constructed, but not all used at a time

  19. Coding the Graphics • Basic Arrow Class • Arrow(int intDirection) • bool IsActive(); • void ResetArrow(); • void SetTexture();

  20. Graphics – Setting Texture • Arrow object can be made for any direction • Direction is passed as a parameter to constructor • Constructor chooses the region required for texture – bitmap image drawn on top of object • Coordinates from bitmap file correspond to screen coordinates

  21. Graphics – Texture & Animation • Animation can be done by modifying bitmap-to-screen coordinates • Requires access to graphics card each time coordinates are modified • Faster approach is to use matrix translation D3DXMatrixTranslation(&mat, x, y, z) • Requires significant computing power when constantly rendering • Use a timer to send ‘Render’ signal

  22. Graphics - Text • Easy to implement using Direct3D’s font class and methods • LPD3DXFONT • Used to • Confirm correct step • Keep score • Display frequency and sensitivity

  23. Integration • The input objects were added directly to graphics code • Beat detection added • Single object • Instantiated in separate thread • Communicates using structure • Sends WM_BEAT message when beat detected • User interface added • Start screen • Open file dialog box • Frequency and sensitivity controls • OOP design made integration easy

  24. Testing • Problems discovered • Delay between when the arrow was stepped on and when DMC registered step • Beat detection caused graphics to slow down • Tweaked the timing of WM_BEAT message

  25. DMC Demo • Let’s play

  26. Future Improvements • Graphics • Dancing model • User interface • Custom dialog box • Control through game pad • Two-player mode • Additional difficulty levels • Device driver for button detection • Support other audio formats • Allow users to edit dance patterns

  27. Final Thoughts • Utilized techniques learned in programming courses • Gained experience programming in Windows environment as well as DirectX programming

More Related