Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 2 ■ an IntroduCtIon to Content CreatIon: 2d new MedIa asset FundaMentals


For this reason and because online listening studies have concluded that MP3 has better quality
(for music) than the MP4 format, we will be using MP3 audio file format for longer-form audio (game
background musical loops), which we’ll use via the Media and MediaPlayer classes. We’ll use the PCM
Wave audio format for short-form audio (game sound effects, such as shots, bells, yelps, grunts, laughter,
cheering, and similar, one-second long or less digital audio assets), which we will use via the AudioClip
digital audio sequencing engine (class) that JavaFX so generously provides.


Digital Audio Optimization: Start with CD Quality Audio and Work


Backward


Optimizing your digital audio assets for playback across the widest range of hardware devices in the market
is going to be easier than optimizing your digital video or digital imagery (and thus animation) across
hardware devices. This is because there is a much wider disparity of target screen resolutions and display
aspect ratios than there is a disparity of digital audio playback hardware support across hardware devices
(with the possible exception for new hardware featuring 24-bit HD audio playback hardware compatibility).
All hardware plays digital audio assets well, so audio optimization is a “one audio asset hits all devices”
scenario, whereas with the visual (video, image, animation) part of the equation, you have display screens as
large as 4096x2160 pixels (4K iTV Sets) down to 320x320 pixels (flip phones and smart watches).
It’s important to remember that a user’s ears can’t perceive the same quality difference with digital
audio that a user’s eyes can with digital imagery, 2D animation, or digital video. Generally, there are three
primary “sweet spots” of digital audio support, across all hardware devices, which you should target for
support for Java game audio.
Lower-quality audio, such as short narration tracks, character exclamations, or short-duration sound
effects, can achieve remarkably high quality by using an 8 kHZ, 11.25 kHz, or 22.5 kHz sampling rate, along
with 8-bit or 12-bit sampling resolution. Medium-quality audio, like long narration tracks, long duration
sound effects, looped background (termed: ambient) audio, and the like, can achieve a very high-quality
level by using a 22.5 kHz or 32 kHz sampling rate along with a 12-bit or 16-bit sampling resolution.
High-quality audio assets, such as music, should be optimized approaching CD-quality audio and
would use a 32 kHz or 44.1 kHz sampling rate, along with the 16-bit data sampling resolution. For HD-
quality audio, being at the ultra-high-end of this audio spectrum, you would use the 48 kHz sampling rate,
along with the 24-bit digital audio data sampling resolution. There is also an unnamed “somewhere in
the middle” high-end audio specification, using a 48 kHz sampling rate along with a 16-bit data sampling
resolution, which just happens to be what Dolby THX used to use for its high-end audio experience
technology. This was used in movie theaters “back in the day” for Star Wars.
Ultimately, it comes down to the quality to file size results that emerge from the digital audio data
footprint optimization work process, which can yield some amazing results. Therefore, your initial work
process for optimizing your digital audio assets across all of these hardware devices is going to be to create
“baseline” 16-bit assets, either at 44.1 kHz or at 48 kHz, and then optimize (compress) them using the
different formats supported in JavaFX. Once that work process is completed, you can see which resulting
digital audio assets provide the smallest data footprint, along with the highest-quality digital audio playback.
After that, you can reduce your 48 kHz or 44.1 kHz data to 32 kHz and save that out using 16-bit resolution
and then using 12-bit resolution. After that, re-open the original 48 kHz data, downsample to 22.5 kHz
sample frequency, and export that using 16-bit or 12-bit resolution, and so on, and so forth. We will be
performing this work process later during this book, in Chapter 21 , so that you’ll have experience with the
audio work process.
You’ll perform this work process using the open source Audacity 2.1.3 digital audio editing and
engineering software package. You downloaded and installed this software package during Chapter 1 , and
ideally, you installed all of those free VST, Nyquist, LV2, and LADSPA plug-ins, as well as the LAME MPEG3
encoders and FFMPEG encoders for the AC3, AMR-NB, M4A, and WMA audio formats. You will want to do
this, if you have not done so already, so that you have absolutely the most powerful digital audio editing and
engineering suite possible for your Java workstation.

Free download pdf