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

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

description

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?. - PowerPoint PPT Presentation

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

Page 1: 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 2nd, 2005

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

OverviewWhat is DMC?Implementation choicesEquipment usedCoding the game• Beat detection• Direct input• Graphics

IntegrationTestingDemonstrationImprovementsThoughts

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

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

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

DMC’s Features

Users choose a sound (.wav) filePlayers 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

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

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

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

Gathering Equipment

MadCatz Beat Pad for Sony PlaystationPlaystation to USB Converter/Adapter

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

Coding Overview

Beat DetectionObtaining input from dance pad using DirectXGraphics using DirectX

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

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

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

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:

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

Beat Detection Implementation

Compute magnitude of complex pairs at chosen frequency sub-band• Sub-bands

43 sub-bands Width grows exponentially with frequency

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

Beat Detection Implementation

Compare computed instant energy density with local average energy density multiplied by a sensitivity constantAdjust local average energy density by adding in newest and subtracting out oldest

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

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

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

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

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

DirectInput

“Joystick” class provides access to functions specifically for “joystick” controlThe 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();

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

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 );

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

The Axis Problem

Driver for converter detects arrow pads as axesBuffer 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

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

Contacting Soyo

Attempts were made to find alternative drivers for the converterContacted Soyo, still waiting for answer

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

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

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

Coding the Graphics

Basic Arrow Class• Arrow(int intDirection)• bool IsActive();• void ResetArrow();• void SetTexture();

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

Graphics – Setting Texture

Arrow object can be made for any directionDirection is passed as a parameter to constructorConstructor chooses the region required for texture – bitmap image drawn on top of objectCoordinates from bitmap file correspond to screen coordinates

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

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

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

Graphics - Text

Easy to implement using Direct3D’s font class and methods• LPD3DXFONT

Used to • Confirm correct step • Keep score• Display frequency and sensitivity

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

IntegrationThe 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

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

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

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

DMC Demo

Let’s play

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

Future Improvements

Graphics• Dancing model

User interface• Custom dialog box• Control through game pad

Two-player modeAdditional difficulty levelsDevice driver for button detectionSupport other audio formatsAllow users to edit dance patterns

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

Final Thoughts

Utilized techniques learned in programming coursesGained experience programming in Windows environment as well as DirectX programming