Class TrcSong

java.lang.Object
trclib.archive.TrcSong

public class TrcSong extends Object
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.
  • Field Details

    • songName

      private final String songName
    • startVolume

      private double startVolume
    • sections

      private final ArrayList<TrcSong.Section> sections
    • sequence

      private String[] sequence
    • sequenceIndex

      private int sequenceIndex
    • currSection

      private TrcSong.Section currSection
    • currVolume

      private double currVolume
  • Constructor Details

    • TrcSong

      public TrcSong(String name, double startVolume)
      Constructor: Create an instance of the object.
      Parameters:
      name - specifies the name of the song.
      startVolume - specifies the starting volume.
    • TrcSong

      public TrcSong(String name)
      Constructor: Create an instance of the object.
      Parameters:
      name - specifies the name of the song.
    • TrcSong

      public TrcSong(String name, double startVolume, String[] sections, String sequence)
      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

      public TrcSong(String name, String[] sections, String sequence)
      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

      public String toString()
      This method returns the song name.
      Overrides:
      toString in class Object
      Returns:
      instance name.
    • addSection

      public void addSection(String name, String section)
      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

      public void setSequence(String sequence)
      This method sets the sequencing of the song.
      Parameters:
      sequence - specifies the string that contains the sequence of section names.
    • getNextNote

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

      private TrcSong.Section findSection(String sectionName)
      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.