Initializing DirectSound ⚠ Click here to regain focus ⚠
?
?

Keyboard Navigation

Global Keys

W, A, P / S, D, N Jump to previous / next marker
t / T Toggle theatre / SUPERtheatre mode
z Toggle filter mode V Revert filter to original state

Menu toggling

q Quotes r References f Filter c Credits

Movement

a
w
s
d
h j k l


Quotes and References Menus

Enter Jump to timecode

Quotes, References and Credits Menus

o Open URL (in new tab)

Filter Menu

x, Space Toggle category and focus next
X, ShiftSpace Toggle category and focus previous
v Invert topics / media as per focus

Credits Menu

Enter Open URL (in new tab)
0:53Fix: Windows API return values and stubs
0:53Fix: Windows API return values and stubs
0:53Fix: Windows API return values and stubs
2:29Fix: XInput on Windows 8
2:29Fix: XInput on Windows 8
2:29Fix: XInput on Windows 8
3:48Fix: Restore Alt-F4 functionality
3:48Fix: Restore Alt-F4 functionality
3:48Fix: Restore Alt-F4 functionality
9:21Bool datatype idiosyncraries
9:21Bool datatype idiosyncraries
9:21Bool datatype idiosyncraries
12:55Review Alt-F4 fix
12:55Review Alt-F4 fix
12:55Review Alt-F4 fix
13:55Foreshadowing an XInput performance issue
13:55Foreshadowing an XInput performance issue
13:55Foreshadowing an XInput performance issue
16:44Intro to sound programming for games
16:44Intro to sound programming for games
16:44Intro to sound programming for games
23:55Initializing DirectSound Overview
23:55Initializing DirectSound Overview
23:55Initializing DirectSound Overview
27:03Load the library
27:03Load the library
27:03Load the library
32:00Create a DirectSound Object
32:00Create a DirectSound Object
32:00Create a DirectSound Object
33:54Configuring the DirectSound Object
33:54Configuring the DirectSound Object
33:54Configuring the DirectSound Object
38:04Creating and Configuring the Primary Buffer
38:04Creating and Configuring the Primary Buffer
38:04Creating and Configuring the Primary Buffer
51:36Creating and Configuring the Secondary Buffer
51:36Creating and Configuring the Secondary Buffer
51:36Creating and Configuring the Secondary Buffer
56:38Let's try it
56:38Let's try it
56:38Let's try it
1:00:46Final Thoughts
1:00:46Final Thoughts
1:00:46Final Thoughts
1:02:05Q&A
1:02:05Q&A
1:02:05Q&A
1:04:05Fixing WaveFormat order
1:04:05Fixing WaveFormat order
1:04:05Fixing WaveFormat order
1:06:07Do you use data-structures like linked-list, binary trees..?
1:06:07Do you use data-structures like linked-list, binary trees..?
1:06:07Do you use data-structures like linked-list, binary trees..?
1:06:34Can you explain again why you need two buffers instead of just doing everything in one?
1:06:34Can you explain again why you need two buffers instead of just doing everything in one?
1:06:34Can you explain again why you need two buffers instead of just doing everything in one?
1:09:23Are there any case we'd want more than two [audio] channels?
1:09:23Are there any case we'd want more than two [audio] channels?
1:09:23Are there any case we'd want more than two [audio] channels?
1:11:05If the framerate would ever drop, can there be audio dropouts?
1:11:05If the framerate would ever drop, can there be audio dropouts?
1:11:05If the framerate would ever drop, can there be audio dropouts?
1:13:41The nBlockAlign and nAverageBytesPerSecond are redundant.
1:13:41The nBlockAlign and nAverageBytesPerSecond are redundant.
1:13:41The nBlockAlign and nAverageBytesPerSecond are redundant.
1:14:57On Linux will we be doing ALSA or higher level like PulseAudio/Jack?
1:14:57On Linux will we be doing ALSA or higher level like PulseAudio/Jack?
1:14:57On Linux will we be doing ALSA or higher level like PulseAudio/Jack?
1:16:00What newer sound API would you recommend instead of old DirectSound?
1:16:00What newer sound API would you recommend instead of old DirectSound?
1:16:00What newer sound API would you recommend instead of old DirectSound?
1:16:46The two second buffer doesn't sound acceptable / not-noticeable if you're playing music.
1:16:46The two second buffer doesn't sound acceptable / not-noticeable if you're playing music.
1:16:46The two second buffer doesn't sound acceptable / not-noticeable if you're playing music.
1:17:27Have or do you work in the industry?
1:17:27Have or do you work in the industry?
1:17:27Have or do you work in the industry?
1:17:54Have you thought about guest programmers tagging in to teach things like linux or whatever topic is their expertise?
1:17:54Have you thought about guest programmers tagging in to teach things like linux or whatever topic is their expertise?
1:17:54Have you thought about guest programmers tagging in to teach things like linux or whatever topic is their expertise?
1:18:35VirtualAlloc: MEM_COMMIT to MEM_RESERVE|MEM_COMMIT
1:18:35VirtualAlloc: MEM_COMMIT to MEM_RESERVE|MEM_COMMIT
1:18:35VirtualAlloc: MEM_COMMIT to MEM_RESERVE|MEM_COMMIT
1:20:23About game development as a career field
1:20:23About game development as a career field
1:20:23About game development as a career field
1:22:57Will you show us how to use bone animations or will you use spritesheets?
1:22:57Will you show us how to use bone animations or will you use spritesheets?
1:22:57Will you show us how to use bone animations or will you use spritesheets?
1:24:15More on our usage of DirectSound (Not a buffer)
1:24:15More on our usage of DirectSound (Not a buffer)
1:24:15More on our usage of DirectSound (Not a buffer)
1:25:33About game programming optimisation
1:25:33About game programming optimisation
1:25:33About game programming optimisation
1:27:56Why don't we use the second buffer to grab the handle instead of creating something just to grab a handle?
1:27:56Why don't we use the second buffer to grab the handle instead of creating something just to grab a handle?
1:27:56Why don't we use the second buffer to grab the handle instead of creating something just to grab a handle?
1:29:26Isn't this learning how to carve stone with chisel instead of using modern machinery?
1:29:26Isn't this learning how to carve stone with chisel instead of using modern machinery?
1:29:26Isn't this learning how to carve stone with chisel instead of using modern machinery?

Initializing DirectSound

Input Cleanup and Fixes

This episode starts with some cleanup and fixes to the input handling code from yesterday.

  • Windows API often uses a 0 return value to indicate success. Our stubs probably shouldn't return 0.
  • Windows 8 ships with xinput1_4.dll only. So we need to try each version in turn
  • When you handle WM_SYSKEY* messages, you lose built in Alt-F4 functionality, and have to reimplement it.

Sound Programming for Games

Casey starts with a high level overview of sound programing for games. The key ideas here are that we are allocating a circular buffer for sound, and the system will play it continually on a loop. If you haven't worked with circular buffers (or ring buffers) before, much of this code will be confusing. It's worth taking some time to familiarize yourself with them.

Resources:

Working with DirectSound

The basic process for initializing DirectSound is as follows:

  1. Load the Library - LoadLibrary("dsound.dll")
  2. Create a DirectSound object - DirectSoundCreate()
  3. Set the Cooperative Level - IDirectSound8::SetCooperativeLevel()
  4. "Create" a primary buffer - IDirectSound8::CreateSoundBuffer()
  5. Create a secondary buffer
  6. Tell DirectSound to start playing the secondary buffer - IDirectSoundBuffer8::Play()

In the next episode we will look closely at how to fill this buffer and implement it in the game loop.