[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 5 ■ An Introduction to Game Design: Concepts, Multimedia, and Using Scene Builder<br />
Because a WAVE or AIFF file will not have any quality loss (as there is also no decompression needed), the PCM<br />
data can be placed straight from the JAR file into system memory! This makes PCM audio great for game sound effects<br />
that are short in duration (0.1 to 1 second), and it can be highly optimized, using 8-bit and 12-bit sample resolution<br />
and 8kHz, 22kHz, or 32kHz sample frequency. Ultimately, the only real way to find out which audio format supported<br />
by <strong>Java</strong>FX has the best digital audio compression result for any given digital audio data is to encode your digital audio<br />
in the primary codecs that you know are supported and efficient. I will be outlining this work process later on, when<br />
you add audio to the game, and you will observe the relative data footprint results between the different formats, using<br />
the same source audio sample (see Chapter 15). Then, you will listen to the audio playback quality so that you can<br />
make your final decision concerning the optimal balance between quality and file size . This is the work process that<br />
you will need to go through to develop <strong>Java</strong>FX digital audio assets for use in your <strong>Java</strong> 8 game.<br />
<strong>Java</strong>FX also supports the popular MPEG-4 AAC codec. These digital audio data can be contained in MPEG4<br />
containers (.mp4, .m4a, .m4v), or file extensions, and can be played back using any OS. It is important to note that<br />
<strong>Java</strong>FX does not contain an MPEG-4 decoder, but instead supports what is called a multimedia container, meaning<br />
that <strong>Java</strong>FX uses the OS’s MPEG-4 decoder.<br />
For this reason, and because online listening studies have concluded that the MP3 format has better quality (for<br />
music) than the MP4, you will be using the MP3 format for longer-form audio (game background musical loops) via<br />
the Media and MediaPlayer classes. You will use the PCM WAVE audio format for short-form (1 second or less) audio<br />
(game sound effects, such as shots, bells, yelps, grunts, laughter, cheering, and other such digital audio assets), which<br />
you will use via the AudioClip digital audio sequencing engine (class) that <strong>Java</strong>FX so generously provides.<br />
Digital Audio Optimization: Start with CD-Quality Audio, and Work Backward<br />
Optimizing your digital audio assets for playback across the widest range of hardware devices on the market is going<br />
to be easier than optimizing your digital video or digital imagery (and thus animation) across these devices. This<br />
is because there is a much wider disparity between target screen resolutions and display aspect ratios than there is<br />
between types of digital audio playback hardware support across hardware devices (with the possible exception of<br />
new hardware featuring 24-bit HD audio playback hardware compatibility). All hardware plays digital audio assets<br />
well, so audio optimization is a “one audio asset hits all devices” scenario, whereas with the visual (video, image,<br />
animation) part of the equation, you have display screens as large as 4,096 × 2,160 pixels (4K iTV Sets) and as small as<br />
320 × 320 pixels (flip phones and smart watches).<br />
It is important to remember that the user’s ears cannot perceive the same quality difference with digital audio<br />
that the user’s eyes can with digital imagery, 2D animation, and digital video. Generally, there are three primary “sweet<br />
spots” of digital audio support across all hardware devices that you should target for support for <strong>Java</strong> game audio.<br />
Lower-quality audio, such as short narration tracks, character exclamations, and short-duration sound effects,<br />
can achieve remarkably high quality by using a sampling rate of 8kHZ or 22kHz, along with 8-bit or 12-bit sampling<br />
resolution. Medium-quality audio, such as long narration tracks, longer-duration sound effects, and looped<br />
background (ambient) audio, can achieve a very high quality level by using a 22kHz or 32kHz sampling rate, along<br />
with a 12-bit or 16-bit sampling resolution.<br />
The high-quality audio assets, such as music, should be optimized approaching CD-quality audio and will use<br />
a 32kHz or 44.1kHz sampling rate, along with the 16-bit data sampling resolution. For HD-quality audio, being at<br />
the ultra-high end of this audio spectrum, you would use the 48kHz sampling rate, along with the 24-bit digital audio<br />
data sampling resolution. There is also an unnamed, “somewhere in the middle” high-end audio specification, using<br />
a 48kHz sampling rate, along with a 16-bit data sampling resolution, which just happens to be what Dolby THX used<br />
to use for its high-end audio experience technology in movie theaters (back in the day).<br />
Ultimately, it comes down to the quality–file size balance results that emerge from the digital audio data footprint<br />
optimization work process, which can be amazing. Therefore, your initial work process for optimizing your digital<br />
audio assets across all these hardware devices is going to be to create baseline 16-bit assets, at either 44.1kHz or<br />
48kHz, and then optimize (compress) them, using the different formats supported in <strong>Java</strong>FX. Once that work process<br />
is completed, you can see which resulting digital audio assets provide the smallest data footprint, along with the<br />
highest quality digital audio playback. After that, you can reduce your 44.1KHz or 48kHz data to 32kHz and save<br />
www.it-ebooks.info<br />
119