Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

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


Some new hardware devices now support HD audio, such as the smartphones you see advertised,
featuring “HD-quality” audio. This means they have 24-bit audio hardware. PC and laptops these days, as
well as game consoles and iTV sets, also come standard with 24-bit audio playback hardware, so the support
is there for high-quality audio.
It is important to note that HD audio is probably not necessary for a Java 9 game, unless your game is
music oriented and makes use of high-quality music, in which case you could use HD audio samples via a
WAVE file format.
Besides digital audio sample resolution, we also have a digital audio sample frequency. This is how
many of these samples at a particular sample resolution are taken during one second of sampling time
frame. In digital image editing, the sampling frequency would be analogous to the number of colors that
are contained within a digital image. Sampling frequency can also be called the sampling rate. You are
probably familiar with the term CD-quality audio, which is defined as using a 16-bit sample resolution and a
44.1 kHz sampling rate. This is taking 44,100 samples, each of which contains 16 bits of sample resolution, or
65,536 bits of audio data held in each of these 44,100 samples. You can figure out raw data in an audio file by
multiplying the sampling bit rate by the sampling frequency by the number of seconds in the audio snippet.
You can see that it can potentially be a huge number! Audio codecs are really great at optimizing sampled
sound wave data down to an amazingly small data footprint with very little audible loss in quality.
Thus, the same trade-off that we have in digital imaging and in digital video exists with digital audio.
The more data that we include, the more high quality of a result that we will obtain! However, this always
comes at the cost of a much larger data footprint. In the visual mediums, the amount of data footprint is
defined using color depth, pixels, and, in the case of digital video and animation, frames. In a digital audio
medium, it is defined with the sampling resolution, in combination with the sampling rate. The most
common sampling rates in the digital audio industry currently include 8kHz, 11.25 kHz, 22.5kHz, 32kHz,
44.1kHz, 48kHz, 96kHz, 192kHz, and even 384kHz.
Lower sampling rates, such as 8kHz, 22kHz, and 32kHz, are the ones that we’re going to use in our
games, as with careful optimization, these can yield high-quality sound effects and arcade music. These
rates would be optimal for sampling any “voice-based” digital audio as well, such as movie dialogue or an
e-book narration track, for instance. Higher sampling rates allow audio reproduction exhibiting theater
sound quality but is not required for most games.


Digital Audio Asset Playback: Captive Audio Playback vs. Streaming


Audio


Just like with digital video data, digital audio data can be captive, held within the application distribution
file (in the case of Java, this is a JAR file); alternately, the digital audio can be streamed using remote data
servers. Similar to digital video, the upside to streaming digital audio data is that it can reduce the data
footprint of the application file, just as streaming digital video data can. The downside is reliability. Many of
the same concepts apply equally well to audio and video. Streaming audio will save data footprint because
you do not have to include all of that heavy new media digital audio data in your JAR files, so if you are
planning on coding a jukebox application, you may want to consider streaming your digital audio data.
Otherwise, try to optimize your digital audio data so that you can include it (captive) inside the JAR file. In
this way, it will always available to the application’s users when they need it!
The downside to streaming digital audio is that if a user’s connection (or the audio data server) goes
down, your digital audio file may not always be present for your end users to play and listen to using your
game application. The reliability and availability of digital audio data are key factors to be considered on
the other side of this “streaming audio data versus captive digital audio data” trade-off. The same trade-off
would apply to digital video assets as well.
Just like with digital video, one of the primary concepts in regard to streaming your digital audio is your
bit rate for that digital audio data. As you learned in the previous section, this bit rate is defined during your
compression process. As with digital video, digital audio files that need to support lower bit-rate bandwidth

Free download pdf