<< Chapter < Page Chapter >> Page >

Then Listing 4 calls the getMelody method and saves the reference that is returned by the method in the instance variable named melody discussed earlier .

Finally, Listing 4 instantiates an object of the AudioPlayOrFile01 class, passing audioParams , melody , and args[0] as parameters, and then calls the method named playOrFileData on that object's reference. Depending on the value of args[0] , this method will either play the sound contained in melody immediately, or write it into an output audio file.

The class named AudioSignalGenerator02

The class named AudioSignalGenerator02 is shown in Listing 15 . This is another class that will probably be used throughout this series of modules on Java sound and which probably won't change, at least for the earlymodules in the series. Therefore, we will only need to discuss it this one time.

Beginning of the class named AudioSignalGenerator02

This is an abstract class that serves as the base class or superclass for several other classes that can be used to create sounds or melodies of different types.

Listing 5 . Beginning of the class named AudioSignalGenerator02.
import java.io.*; import java.nio.*;import java.util.*; public abstract class AudioSignalGenerator02{//Note: This class can only be used to generate signed 16-bit data.ByteBuffer byteBuffer; String[]args; byte[]melody; AudioFormatParameters01 audioParams;//-------------------------------------------------------------------------//

The code in Listing 5 declares four instance variables. You are already familiar with the purpose of three of them. The variable named byteBuffer isn't actually used in the program in this module, but will be used in later modules. I will explain it in the firstmodule in which it is actually used.

The constructor for AudioSignalGenerator02

The constructor is shown in Listing 6 . The constructor simply receives three input parameters and saves them in the instance variables shown in Listing 5 .

Listing 6 . The constructor for AudioSignalGenerator02.
public AudioSignalGenerator02(AudioFormatParameters01 audioParams, String[]args, byte[]melody){ this.audioParams = audioParams;this.args = args; this.melody = melody;}//end constructor //-------------------------------------------------------------------------//

The abstract method named getMelody

Listing 7 shows an abstract method named getMelody . In case you don't remember what an abstract method is, see Ap0100 : Self-assessment, The this keyword, static final variables, and initialization of instance variables .

Briefly, an abstract method is a method that is designed to be overridden. The method named getMelody in Listing 7 must be overridden in a subclass to be of any use. You will see the overridden version of the method named getMelody shortly in the class named WhiteNoise .

Recall that the method was called on a reference to a WhiteNoise object in Listing 4 . (You will get a better idea of the purpose of this abstract method when we discuss runtime polymorphism in a future module.)

Questions & Answers

what is phylogeny
Odigie Reply
evolutionary history and relationship of an organism or group of organisms
AI-Robot
ok
Deng
what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Accessible objected-oriented programming concepts for blind students using java. OpenStax CNX. Sep 01, 2014 Download for free at https://legacy.cnx.org/content/col11349/1.17
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Accessible objected-oriented programming concepts for blind students using java' conversation and receive update notifications?

Ask