Game Development Reference
In-Depth Information
Digital Audio in JavaFX: Supported Digital Audio Co-
decs and Data Formats
There are considerably more digital audio codecs in JavaFX than digital video codecs,
as there is only one video codec, MPEG-4 H.264 AVC. Android audio support includes
.MP3 ( MPEG-3 ) files, Windows WAVE ( Pulse Code Modulation [ PCM ] audio)
.WAV files, .MP4 (or .M4A) MPEG-4 AAC ( Advanced Audio Coding ) audio, and
Apple's AIFF (PCM) file format. The most common format supported by JavaFX (and
thus Java 8) is the popular .MP3 digital audio file format. Most of you are familiar with
MP3 digital audio files, owing to music download web sites, such as Napster or Sound-
cloud, and most of us collect songs in this format to use on MP3 players and in CD-
ROM- or DVD-ROM-based music collections. The MP3 digital audio file format is
popular because it has a fairly good compression-to-quality ratio and is widely suppor-
ted.
MP3 is an acceptable format to use in a Java 8 application, so long as you get the
highest quality level possible out of it, using an optimal encoding work process. It is
important to note that, like JPEG (used for images), MP3 is a lossy audio file format, in
which some of the audio data (and thus quality) are thrown away during your com-
pression process and cannot be recovered.
JavaFX does have two lossless audio compression codecs, AIFF and WAVE. Many
of you are familiar with these, as they were the original audio formats used with the
Apple Macintosh and Microsoft Windows OSs, respectively. These files use PCM au-
dio, which is lossless (in this case, because there is no compression applied whatso-
ever!). “PCM,” which, as stated, stands for “pulse code modulation,” refers to the data
format it holds.
PCM audio is commonly used for CD-ROM content as well as telephony applica-
tions. This is because PCM WAVE audio is an uncompressed digital audio format,
with no CPU-intensive compression algorithms applied to the data stream. Thus, de-
coding (CPU data processing) is not an issue for telephony equipment or for CD play-
ers.
For this reason, when you start compressing digital audio assets into the various file
formats, you can use PCM as your baseline file format. It allows you to look at the dif-
ference between PCM (WAVE) and MP3 and MP4 audio compression results to get an
idea of how much data footprint optimization you are getting for your JAR file; more
important, you can also see how your sample resolution and sample frequency optimiz-
ation are going to affect the system memory used for your game's audio effects. Even if
you used an MP3 or MP4 format, it would still have to be decompressed into memory
Search WWH ::




Custom Search