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 />

The next thing that we will do is to go back and use the File ➤ Open menu sequence to open the left.wav file that<br />

contains only the segment of digital audio data that we wish to optimize. This is seen in the middle of Figure 15-3<br />

(the menu sequence), and on the right side of the screenshot you can see a Select one or more audio files (File Open)<br />

dialog. Notice that the left.wav file shows what its raw (original) data footprint is (113 KB).<br />

We can use this original data footprint as a baseline to see how many times we reduce the data footprint (it will<br />

eventually be 8.8 times smaller, once we are done) during this optimization process we are about to embark on.<br />

When you click on the Open button and open a file for the first time in Audacity you’ll get a Warning dialog, which<br />

is shown in Figure 15-4. This will advise you that you can make a copy of your original file for use in your editing session,<br />

instead of using the original. This is what is called “non-destructive” editing in the multimedia industry, and is always a<br />

very good idea, since it essentially provides you with a back-up file (the original), as part of the work process.<br />

Figure 15-4. Enable non-destructive audio editing in Audacity<br />

Select the “Make a copy of the files before editing (safer)” radio button option, and check the “Don’t warn again,<br />

and always use my choice above” checkbox, which will turn Audacity 2 into a non-destructive non-linear digital audio<br />

editing software package. Click on the OK button and we’ll be ready to start your digital audio data optimization work<br />

process. We will be optimizing our digital audio data, but not compressing it, and I will get into why that is next.<br />

Optimization Versus Compression: The Audio Memory Footprint<br />

You might be wondering why I am using the uncompressed, pulse code modulated (PCM) Wave (.wav) file format<br />

instead of the industry standard .MP3 file format that many of you use for your digital audio music file storage. I will<br />

cover the reason for this up front, before we start the optimization process. In digital audio, there are really two stages<br />

to data footprint optimization. First you optimize the sample resolution (32-bit original recording, 24-bit HD audio,<br />

16-bit CD Quality audio and 8-bit lower quality audio) and the sample frequency (44.1kHz, 22.05kHz, 11.025kHz are<br />

the primary frequency levels that still maintain enough data for a quality result), and then you apply the compression.<br />

The compression affects your file size; in this case it is your .JAR (<strong>Java</strong> Resources) file.<br />

So, why are we not compressing our files into MP3 format, to make our .JAR file a few kilobytes smaller? A primary<br />

reason for this is because MP3 is a “lossy” format, which throws away original data (and quality) for the audio sample.<br />

Since the <strong>Java</strong>FX AudioClip class is going to take our digital audio assets and decompress them into memory, if we<br />

use MP3, that memory will contain lower quality audio data that if we use WAV format. Given that we are going to<br />

get at least an 8X data footprint reduction during the sample optimization work process that we are about to learn<br />

in the next section of the chapter, and that all our digital audio assets are going to be optimized to between 4KB and<br />

14K of data footprint, MP3 compression is not going to give us any real JAR file data footprint reduction relative to the<br />

reduction in sample quality that it will “cost” us. Game audio is short-burst sound effects and musical loops, so we can<br />

use WAV file format and still get a good result, and not have to use any compression. The other advantage is the data<br />

size of the WAV file that you see in our file management software is also the amount of memory the sample will use.<br />

www.it-ebooks.info<br />

327

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

Saved successfully!

Ooh no, something went wrong!