<< Chapter < Page | Chapter >> Page > |
It is unlikely that the class named AudioPlayOrFile01 will be modified throughout the next several modules. Therefore, unless I change the name of the class, (which I will do if I modify the file) , you will only need to copy and compile the source code once. After that, you can simply copy the compiled class file from oneproject folder to the next.
An object of the class named AudioFormatParameters01 is simply a container for some of the parameters required by the class named AudioPlayOrFile01 . A complete listing of the class named AudioFormatParameters01 is provided in Listing 13 .
With the exception of bigEndian , the comments should be sufficient to describe the parameters. If you would like to learn more about bigEndian , simply Google it.
Although there are more elegant ways to organize your disk by making use of the classpath environment variable, unless stated otherwise, the disk organization that I will use in this collection of sound modules will not usethe classpath environment variable.
With the exception of the classes in the Java Standard Edition library, these modules will assume that source code files or compiled class files for allrequired classes are physically contained in the folder from which the program is executed. For the program that I will explain in this module, this means that the following source code orcompiled class files must be contained in the execution folder:
An object of this class creates and plays three seconds of monaural white or pink noise. It works in conjunction with the following classes:
The sound can be played immediately or can be saved in an audio file of type AU for playback later. (Click WhiteNoise to download and play the audio file produced by this program.)
A complete listing of the class named MusicComposer04 is provided in Listing 14 . I will break this code down and explain it in fragments. The first fragment isshown in Listing 1 .
Listing 1 shows the beginning of the class named MusicComposer04 along with the main method.
Listing 1 . Beginning of the class named MusicComposer04. |
---|
public class MusicComposer04{
AudioFormatParameters01 audioParams = new AudioFormatParameters01();byte[] melody;String[] args;//-------------------------------------------------------------------------//
public static void main(String[]args){
new MusicComposer04(args);}//end main
//-------------------------------------------------------------------------// |
The first instance variable named audioParams instantiates and saves a reference to anobject containing audio format parameters with predefined values. They may be modified by the signal generator later at runtime. Values that areallowed by Java SDK 1.4.1 are shown in comments in the class definition for the class named AudioFormatParameters01 .
Notification Switch
Would you like to follow the 'Accessible objected-oriented programming concepts for blind students using java' conversation and receive update notifications?