Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 21 ■ Questions and answers: Finishing the setup Methods and digital audio


Move this new method body up in the class method structure so it is near your loadImageAssets()
method and start to add your spinnerAudio = new AudioClip(); instantiation statement, as shown under
construction in Figure 21-24. This instantiation will become more complex as we construct the inner (String
sourceURL) portion of the statement. This looks like the following code, which is under construction in
NetBeans and highlighted in Figure 21-24:


spinnerAudio = new AudioClip( JavaFXGame.class.getResource(String sourceURL) );


Let’s take a couple of pages and find a professional-level CD and HD digital audio sample web site that
has free-for-commercial-usage WAVE files (uncompressed PCM digital audio at 44.1 KHz in 16-bit and 24-
bit resolutions).


Finding Free for Commercial Use Digital Audio: 99Sounds.org


Before we reference the internal file name for the spinnerAudio digital audio asset, we need to create the digital
audio asset that we will be using next, so let’s do this first. Fortunately, I found a digital audio sample library
site called 99Sounds that has gigabytes of cinematic quality audio samples that can be utilized for commercial
projects for free, as long as they are not redistributed as digital audio samples in another library. These use the
standard 44.1 Hz, CD quality, and audio sample rate, and they are either 16-bit or 24-bit resolution, using the
uncompressed PCM (WAVE) format. If you want to learn more about the digital audio editing software and
work process that is covered in this section of the chapter, check out Digital Audio Editing Fundamentals from
Apress.com. I downloaded all of the sample libraries from http://www.99SOUNDS.org just because I work on a lot of
games, web sites, e-books, iTV shows, smartwatches, and similar digital productions for clients as well as my
own company. Figure 21-25 shows the file explorer application listing with the dozens of folders (now on my
hard disk drive under a C:\Audio folder) I downloaded.


Figure 21-24. Add your internal getResource(String) portion of the AudioClip instantiation statement for
spinnerAudio

Free download pdf