Class TrcSongPlayer

java.lang.Object
trclib.archive.TrcSongPlayer

public class TrcSongPlayer extends Object
This class implements a song player that can parse a notated song in a string buffer and play the notes on a Tone device.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TrcSongPlayer(String instanceName, TrcTone tone)
    Constructor: Create and initialize an instance of the object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This method is called to pause the player.
    void
    playSong(TrcSong song, double barDuration)
    This method plays the specified song.
    void
    playSong(TrcSong song, double barDuration, boolean pause)
    This method plays the specified song.
    void
    playSong(TrcSong song, double barDuration, boolean repeat, boolean pause)
    This method plays the specified song.
    void
    playSong(TrcSong song, double barDuration, boolean pause, TrcEvent event)
    This method plays the specified song.
    void
    This method is called to resume the player.
    void
    This method rewinds the song back to the beginning.
    void
    This method stops the sound and disables the player task.
    This method returns the instance name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TrcSongPlayer

      public TrcSongPlayer(String instanceName, TrcTone tone)
      Constructor: Create and initialize an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      tone - specifies the Tone player.
  • Method Details

    • toString

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

      public void stop()
      This method stops the sound and disables the player task.
    • pause

      public void pause()
      This method is called to pause the player.
    • resume

      public void resume()
      This method is called to resume the player.
    • rewind

      public void rewind()
      This method rewinds the song back to the beginning.
    • playSong

      public void playSong(TrcSong song, double barDuration, boolean repeat, boolean pause)
      This method plays the specified song.
      Parameters:
      song - specifies the song to be played.
      barDuration - specifies the bar duration in seconds.
      repeat - specifies true to play the song repeatedly, false otherwise.
      pause - specifies true to pause the song, false to start it immediately.
    • playSong

      public void playSong(TrcSong song, double barDuration, boolean pause, TrcEvent event)
      This method plays the specified song.
      Parameters:
      song - specifies the song to be played.
      barDuration - specifies the bar duration in seconds.
      pause - specifies true to pause the song, false to start it immediately.
      event - specifies the event to be notified on song completion.
    • playSong

      public void playSong(TrcSong song, double barDuration, boolean pause)
      This method plays the specified song.
      Parameters:
      song - specifies the song to be played.
      barDuration - specifies the bar duration in seconds.
      pause - specifies true to pause the song, false to start it immediately.
    • playSong

      public void playSong(TrcSong song, double barDuration)
      This method plays the specified song.
      Parameters:
      song - specifies the song to be played.
      barDuration - Specifies the bar duration in seconds.