28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 15 ■ Implementing Game Audio Assets: Using the <strong>Java</strong>FX AudioClip Class Audio Sequencing Engine<br />

Next, let’s use the File ➤ Export work process. If you want to see this on a menu, this menu sequence can be seen<br />

in Figure 15-1, and is shown on the File menu, above Export Selection option. In the Export File dialog, which can<br />

be seen in Figure 15-7, you can save the new version of the file using a different file name, so that you have both the<br />

original uncompressed data in the left.wav file and the new compressed (stereo) data in the leftstereo.wav file. Name<br />

this file leftstereo, and click on the Save button, to save it as an uncompressed 16-bit PCM WAV file, as shown on the<br />

left side of Figure 15-7.<br />

Figure 15-7. Use the File ➤ Export dialog, name the file leftstereo, Save the file, then use File ➤ Open to check its file size<br />

The next thing that we will want to do is use the same work process shown back in Figure 15-3, and use the<br />

File ➤ Open menu sequence, to open the Select one or more audio files dialog, shown on the right side of Figure 15-7,<br />

which will allow us to mouse-over the leftstereo.wav file and see that the size is 28.0 KB, which is four times less data<br />

than the original 112 KB source file size, just as we expected!<br />

Therefore, we’ve reduced our memory requirements for this audio file that states the word “left” from one-ninth<br />

of a megabyte (112 KB), to one-thirty-sixth of a megabyte (28KB). This means that you can have 36 audio assets of this<br />

size, and still be using only one single megabyte of system memory! When I created the other five audio assets, this<br />

one turned out to be the largest, and the smallest (up and s, as you may have guessed) were less than 4KB each!<br />

The last stage of our digital audio optimization work process is the conversion of this data from a stereo file to a<br />

mono file. We will do this because we don’t need two copies of the same spoken word for our game audio assets. This<br />

is also true for most game audio special effects, such as laser blasts and explosions; mono audio works just fine in<br />

these types of audio sound effect situations. This is especially true because the <strong>Java</strong>FX AudioClip class and its pan and<br />

balance capabilities will also allow us to simulate stereo effects, using mono digital audio assets, if we want to.<br />

This will also reduce our data footprint by another 100%, giving us a 14KB audio file. We could fit 72 digital mono<br />

audio assets of this size into one megabyte of system memory, so using mono (monaural) audio assets instead of<br />

stereo digital audio assets is a great thing to do whenever you can, which is why we are going to cover this next.<br />

Stereo Versus Mono Audio: Reducing Your Memory Footprint Another 100%<br />

The last stage of our digital audio optimization work process is the conversion of our digital audio data from using a<br />

stereo audio asset into a monaural audio asset. We will do this because we don’t need two copies of the same spoken<br />

word for our game audio asset in this case. This is also true for most game-related digital audio special effects, such as<br />

laser blasts and explosions. Monaural audio will work just as well as stereo audio in these types of audio sound effect<br />

situations. This is especially true because the <strong>Java</strong>FX AudioClip class gives developers audio panning and balance<br />

capabilities. These will allow developers to simulate stereo effects using mono audio assets. Audacity has an ability to<br />

combine stereo audio asset (two tracks, one left and one right) data into one mono audio asset that sounds the same.<br />

330<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!