Game Development Reference
In-Depth Information
before the audio asset could be used with the AudioClip class and employed as a sound
effect in a Java 8 game.
Because a WAVE or AIFF file will not have any quality loss (as there is also no de-
compression needed), the PCM data can be placed straight from the JAR file into sys-
tem memory! This makes PCM audio great for game sound effects that are short in
duration (0.1 to 1 second), and it can be highly optimized, using 8-bit and 12-bit
sample resolution and 8kHz, 22kHz, or 32kHz sample frequency. Ultimately, the only
real way to find out which audio format supported by JavaFX has the best digital audio
compression result for any given digital audio data is to encode your digital audio in
the primary codecs that you know are supported and efficient. I will be outlining this
work process later on, when you add audio to the game, and you will observe the relat-
ive data footprint results between the different formats, using the same source audio
sample (see Chapter 15 ) . Then, you will listen to the audio playback quality so that you
can make your final decision concerning the optimal balance between quality and file
size . This is the work process that you will need to go through to develop JavaFX di-
gital audio assets for use in your Java 8 game.
JavaFX also supports the popular MPEG-4 AAC codec. These digital audio data
can be contained in MPEG4 containers (.mp4, .m4a, .m4v), or file extensions, and can
be played back using any OS. It is important to note that JavaFX does not contain an
MPEG-4 decoder, but instead supports what is called a multimedia container, meaning
that JavaFX uses the OS's MPEG-4 decoder.
For this reason, and because online listening studies have concluded that the MP3
format has better quality (for music) than the MP4, you will be using the MP3 format
for longer-form audio (game background musical loops) via the Media and MediaPlay-
er classes. You will use the PCM WAVE audio format for short-form (1 second or less)
audio (game sound effects, such as shots, bells, yelps, grunts, laughter, cheering, and
other such digital audio assets), which you will use via the AudioClip digital audio se-
quencing engine (class) that JavaFX so generously provides.
Digital Audio Optimization: Start with CD-Quality Au-
dio, and Work Backward
Optimizing your digital audio assets for playback across the widest range of hardware
devices on the market is going to be easier than optimizing your digital video or digital
imagery (and thus animation) across these devices. This is because there is a much
wider disparity between target screen resolutions and display aspect ratios than there is
between types of digital audio playback hardware support across hardware devices
Search WWH ::




Custom Search