Charles Petzold



Spinning a Record Like a DJ in Windows 8

April 2, 2013
New York, N.Y.

Windows 8 has some exceptionally powerful facilities for working with sound, and in the latest installment of the DirectX Factor column in MSDN Magazine I show how to display a file picker that allows you to select an MP3 or WMA file from your Windows 8 Music Library, display cover art as well as album and artist information, load and decode the file using the Media Foundation APIs, and shovel the resultant audio buffers into XAudio2 voices to play back the file.

This may seem like a rather roundabout way to do something that the Windows 8 MediaElement does for you, but having access to the actual audio buffers allows for some interesting techniques. The downloadable DeeJay program creates a disk that looks like an old-fashioned vinyl record with a "needle" pointing to the current location:

You can adjust the playback speed (forward or reverse) using a Slider on the application bar, or you can use your fingers to spin the record manually like a DJ. The DeeJay program uses the one-finger Manipulation events with inertia for the touch interface, so you can give it a good flick and watch it spin crazily and then slow down.

Check it out. The program is pretty cool whether you're interesting in the particular programming techniques or not.