<< Chapter < Page
  Accessible objected-oriented     Page 5 / 17
Chapter >> Page >
  • // This is a comment in the text file
  • 1,A3,C4#,E4
  • 4,X
  • 2,A3,C4#,E4
  • 4,X
  • 3,A3,C4#,E4
  • 4,X
  • 4,A3,C4#,E4

Normally, the first character on each line must be a number or a /. Comments must begin in the first column with a forward slash (/).The program will ignore:

  • Comment lines that begin with /
  • Blank lines that result in a string with a zero length
  • Lines that begin with a space

The frequency range extends from A2 (110 Hz) to A7 (3520 Hz). Note, however, that someaudio speakers cannot produce sound at the low or high end of that spectrum. Middle-C (261.63 Hz) is specified as C4.

Shaping the notes

The amplitude versus time of each note is shaped by a scale factor. The amplitude is maximum at the beginning and decays linearly to zero at the end.

Beginning of the PlayerPiano01 class

The class named PlayerPiano01 begins in Listing 5 . Assuming that you have studied the previous modules in this series, there isnothing in Listing 5 that should require an explanation beyond the embedded comments.

Listing 5 . Beginning of the PlayerPiano01 class.
import java.io.*; import java.nio.*;import java.util.*; public class PlayerPiano01 extends AudioSignalGenerator02{//Used to store treble clef notes as a list of arrays.ArrayList trebleClef = null; //Used to store bass clef notes as a list of arrays.ArrayList bassClef = null;//Names of input text files are stored here. String trebleFileName;String bassFileName; //Routine working variablesint trebleLengthInBeats; int bassLengthInBeats;

The constructor for the PlayerPiano01 class

The constructor is shown in Listing 6 . The code in the constructor checks the length of the args array. Depending on the length, it gets and saves the file names for neither, either, or both of the text files that define the melody.

Listing 6 . The constructor for the PlayerPiano01 class.
public PlayerPiano01(AudioFormatParameters01 audioParams, String[]args, byte[]melody){ super(audioParams,args,melody);//Get names of files containing the durations and notes.if(args.length>= 3){ //Required trebleFileNametrebleFileName = args[2];}else{ System.out.println("No trebleFileName provided");}//end elseif(args.length>= 4){ //Optional bassFileNamebassFileName = args[3];}//end if }//end constructor

Beginning of the getMelody method

This program uses the same structure as several programs in previous modules. By now, you should be familiar with that structure. Theoverridden getMelody method, which is inherited from the abstract class name AudioSignalGenerator02 and called from Listing 4 , begins in Listing 7 .

This method returns a melody array that will play piano-like sounds using input musical notation like

A, A#, B, C, C#, D, D# etc.

See Listing 29 for an example of a text file containing the treble clef notes for the Greensleeves melody.

Listing 7 . Beginning of the getMelody method.
byte[] getMelody(){if(bassFileName != null){ //Specify stereo output.audioParams.channels = 2; }else{//Specify mono output. audioParams.channels = 1;//superfluous - same as default}//end else System.out.println("audioParams.channels = " + audioParams.channels);//Controls how fast or slow the notes are played. int beatsPerSec = Integer.parseInt(args[1]);

Questions & Answers

how does Neisseria cause meningitis
Nyibol Reply
what is microbiologist
Muhammad Reply
what is errata
Muhammad
is the branch of biology that deals with the study of microorganisms.
Ntefuni Reply
What is microbiology
Mercy Reply
studies of microbes
Louisiaste
when we takee the specimen which lumbar,spin,
Ziyad Reply
How bacteria create energy to survive?
Muhamad Reply
Bacteria doesn't produce energy they are dependent upon their substrate in case of lack of nutrients they are able to make spores which helps them to sustain in harsh environments
_Adnan
But not all bacteria make spores, l mean Eukaryotic cells have Mitochondria which acts as powerhouse for them, since bacteria don't have it, what is the substitution for it?
Muhamad
they make spores
Louisiaste
what is sporadic nd endemic, epidemic
Aminu Reply
the significance of food webs for disease transmission
Abreham
food webs brings about an infection as an individual depends on number of diseased foods or carriers dully.
Mark
explain assimilatory nitrate reduction
Esinniobiwa Reply
Assimilatory nitrate reduction is a process that occurs in some microorganisms, such as bacteria and archaea, in which nitrate (NO3-) is reduced to nitrite (NO2-), and then further reduced to ammonia (NH3).
Elkana
This process is called assimilatory nitrate reduction because the nitrogen that is produced is incorporated in the cells of microorganisms where it can be used in the synthesis of amino acids and other nitrogen products
Elkana
Examples of thermophilic organisms
Shu Reply
Give Examples of thermophilic organisms
Shu
advantages of normal Flora to the host
Micheal Reply
Prevent foreign microbes to the host
Abubakar
they provide healthier benefits to their hosts
ayesha
They are friends to host only when Host immune system is strong and become enemies when the host immune system is weakened . very bad relationship!
Mark
what is cell
faisal Reply
cell is the smallest unit of life
Fauziya
cell is the smallest unit of life
Akanni
ok
Innocent
cell is the structural and functional unit of life
Hasan
is the fundamental units of Life
Musa
what are emergency diseases
Micheal Reply
There are nothing like emergency disease but there are some common medical emergency which can occur simultaneously like Bleeding,heart attack,Breathing difficulties,severe pain heart stock.Hope you will get my point .Have a nice day ❣️
_Adnan
define infection ,prevention and control
Innocent
I think infection prevention and control is the avoidance of all things we do that gives out break of infections and promotion of health practices that promote life
Lubega
Heyy Lubega hussein where are u from?
_Adnan
en français
Adama
which site have a normal flora
ESTHER Reply
Many sites of the body have it Skin Nasal cavity Oral cavity Gastro intestinal tract
Safaa
skin
Asiina
skin,Oral,Nasal,GIt
Sadik
How can Commensal can Bacteria change into pathogen?
Sadik
How can Commensal Bacteria change into pathogen?
Sadik
all
Tesfaye
by fussion
Asiina
what are the advantages of normal Flora to the host
Micheal
what are the ways of control and prevention of nosocomial infection in the hospital
Micheal
what is inflammation
Shelly Reply
part of a tissue or an organ being wounded or bruised.
Wilfred
what term is used to name and classify microorganisms?
Micheal Reply
Binomial nomenclature
adeolu
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