Package trclib.archive
Class TrcSong
java.lang.Object
trclib.archive.TrcSong
This class implements a song object that contains a song name, an array list of notated sections and a sequencing
array specifying the order of the sections. It also keeps track of the next note position of the song and provides
a getNextNote() method to retrieve the next note to play.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classThis class implements a notated section that contains a section name, an array of notes and keeps track of the next note of the section and provides a getNextNote() method to retrieve the next note to play. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate TrcSong.Sectionprivate doubleprivate final ArrayList<TrcSong.Section>private String[]private intprivate final Stringprivate double -
Constructor Summary
ConstructorsConstructorDescriptionConstructor: Create an instance of the object.Constructor: Create an instance of the object.Constructor: Create an instance of the object.Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSection(String name, String section) This method adds a notated section to the song.private TrcSong.SectionfindSection(String sectionName) This method finds the section with the specified section name.doubleThis method returns the current volume of the song.This method retrieves the next note of the song to be played.voidrewind()This method rewinds the note pointer back to the beginning of the song.voidsetCurrentVolume(double vol) This method sets the current volume of the song.voidsetSequence(String sequence) This method sets the sequencing of the song.voidsetStartVolume(double vol) This method sets the start volume of the song.toString()This method returns the song name.
-
Field Details
-
songName
-
startVolume
private double startVolume -
sections
-
sequence
-
sequenceIndex
private int sequenceIndex -
currSection
-
currVolume
private double currVolume
-
-
Constructor Details
-
TrcSong
Constructor: Create an instance of the object.- Parameters:
name- specifies the name of the song.startVolume- specifies the starting volume.
-
TrcSong
Constructor: Create an instance of the object.- Parameters:
name- specifies the name of the song.
-
TrcSong
Constructor: Create an instance of the object.- Parameters:
name- specifies the name of the song.startVolume- specifies the starting volume.sections- specifies an array of notated song sections.sequence- specifies the song sequence array.
-
TrcSong
Constructor: Create an instance of the object.- Parameters:
name- specifies the name of the song.sections- specifies an array of notated song sections.sequence- specifies the song sequence array.
-
-
Method Details
-
toString
This method returns the song name. -
addSection
This method adds a notated section to the song.- Parameters:
name- specifies the section name.section- specifies the string that contains notated notes of the section.
-
setSequence
This method sets the sequencing of the song.- Parameters:
sequence- specifies the string that contains the sequence of section names.
-
getNextNote
This method retrieves the next note of the song to be played.- Returns:
- next notated note or null if no more note.
-
getCurrentVolume
public double getCurrentVolume()This method returns the current volume of the song.- Returns:
- current volume of the song.
-
setCurrentVolume
public void setCurrentVolume(double vol) This method sets the current volume of the song.- Parameters:
vol- specifies the current volume of the song.
-
setStartVolume
public void setStartVolume(double vol) This method sets the start volume of the song.- Parameters:
vol- specifies the start volume of the song.
-
rewind
public void rewind()This method rewinds the note pointer back to the beginning of the song. -
findSection
This method finds the section with the specified section name.- Parameters:
sectionName- specifies the section name to look for.- Returns:
- section object associated with the specified name.
-