14 Sound effects

This chapter covers

  • The sound capabilities of the NES console
  • Creating sound effects in FamiStudio
  • Adding the music/sound effects engine to our game
  • Using sound effects in our game

We now have lots of gameplay features in our game and have learned several techniques for using the NES graphical hardware, but our game is silent. We need to add some sound to our game so that we can hear our main ship’s laser firing, enemies moving, explosions, and more. This will make our game even more compelling and fun to play, and we will get to learn about the distinctive sound capabilities of the NES hardware.

14.1 NES sound capabilities

The NES has a custom audio processor unit (APU) that has quite a distinctive sound, mainly due to the type of waveforms that can be generated. The APU has five channels: two pulse wave generators, a triangle wave, a noise generator, and a delta modulation channel for playing digital sound samples. The ability to play digital sound samples on an 8-bit system was particularly advanced for the time when the console was released.

The ability to not just set a pitch for each channel but also to partially control the shape of the waveform generated and how long it will last and potentially repeat frees up the CPU. In most 8-bit systems that have simpler sound chips, the CPU needs to constantly control the pitch and volume of each channel.

14.1.1 Pulse wave channels

14.1.2 Triangle channel

14.1.3 Noise channel

14.1.4 Delta modulation channel

14.2 Creating some sound effects

14.2.1 Zap

14.2.2 Boom

14.2.3 Big boom

14.3 Adding the sound engine

14.3.1 Exporting sound effects

14.3.2 Adding the sound engine code

14.4 Adding sound effects to our game

Summary