<< 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

how do I set up the problem?
Harshika Reply
what is a solution set?
Harshika
find the subring of gaussian integers?
Rofiqul
hello, I am happy to help!
Shirley Reply
please can go further on polynomials quadratic
Abdullahi
hi mam
Mark
I need quadratic equation link to Alpa Beta
Abdullahi Reply
find the value of 2x=32
Felix Reply
divide by 2 on each side of the equal sign to solve for x
corri
X=16
Michael
Want to review on complex number 1.What are complex number 2.How to solve complex number problems.
Beyan
yes i wantt to review
Mark
use the y -intercept and slope to sketch the graph of the equation y=6x
Only Reply
how do we prove the quadratic formular
Seidu Reply
please help me prove quadratic formula
Darius
hello, if you have a question about Algebra 2. I may be able to help. I am an Algebra 2 Teacher
Shirley Reply
thank you help me with how to prove the quadratic equation
Seidu
may God blessed u for that. Please I want u to help me in sets.
Opoku
what is math number
Tric Reply
4
Trista
x-2y+3z=-3 2x-y+z=7 -x+3y-z=6
Sidiki Reply
can you teacch how to solve that🙏
Mark
Solve for the first variable in one of the equations, then substitute the result into the other equation. Point For: (6111,4111,−411)(6111,4111,-411) Equation Form: x=6111,y=4111,z=−411x=6111,y=4111,z=-411
Brenna
(61/11,41/11,−4/11)
Brenna
x=61/11 y=41/11 z=−4/11 x=61/11 y=41/11 z=-4/11
Brenna
Need help solving this problem (2/7)^-2
Simone Reply
x+2y-z=7
Sidiki
what is the coefficient of -4×
Mehri Reply
-1
Shedrak
the operation * is x * y =x + y/ 1+(x × y) show if the operation is commutative if x × y is not equal to -1
Alfred Reply
An investment account was opened with an initial deposit of $9,600 and earns 7.4% interest, compounded continuously. How much will the account be worth after 15 years?
Kala Reply
lim x to infinity e^1-e^-1/log(1+x)
given eccentricity and a point find the equiation
Moses Reply
A soccer field is a rectangle 130 meters wide and 110 meters long. The coach asks players to run from one corner to the other corner diagonally across. What is that distance, to the nearest tenths place.
Kimberly Reply
Jeannette has $5 and $10 bills in her wallet. The number of fives is three more than six times the number of tens. Let t represent the number of tens. Write an expression for the number of fives.
August Reply
What is the expressiin for seven less than four times the number of nickels
Leonardo Reply
How do i figure this problem out.
how do you translate this in Algebraic Expressions
linda Reply
why surface tension is zero at critical temperature
Shanjida
I think if critical temperature denote high temperature then a liquid stats boils that time the water stats to evaporate so some moles of h2o to up and due to high temp the bonding break they have low density so it can be a reason
s.
Need to simplify the expresin. 3/7 (x+y)-1/7 (x-1)=
Crystal Reply
. After 3 months on a diet, Lisa had lost 12% of her original weight. She lost 21 pounds. What was Lisa's original weight?
Chris Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!





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