Module hw06

Class SequencePlayer

java.lang.Object
provided.abcMusic.player.impl.ASequencePlayer
provided.abcMusic.player.impl.SequencePlayer
All Implemented Interfaces:
ISequencePlayer

public class SequencePlayer extends ASequencePlayer
A basic sequence player to create and play MIDI music sequences.
  • Field Details

    • _sequencer

      private Sequencer _sequencer
      MIDI sequencer object
    • _synthesizer

      private Synthesizer _synthesizer
      MIDI synthesizer object
  • Constructor Details

    • SequencePlayer

      public SequencePlayer(int ticksPerQuarterNote, int instrument)
      Create a new SequencePlayer to create and play music.
      Parameters:
      ticksPerQuarterNote - - tick definition
      instrument - - MIDI instrument
  • Method Details

    • init

      public boolean init(int ticksPerQuarterNote, int instrument)
      Initialize the SequencePlayer as per the supplied ticksPerQuarterNote and instrument this SequencePlayer was instantiated with. This method is called by the constructor to initialize the player upon instantiation and can be called again to reinitialize the SequencePlayer.
      Parameters:
      ticksPerQuarterNote - - tick definition
      instrument - - MIDI instrument
      Returns:
      - true if properly initialized, false otherwise
    • play

      public void play(ISequencePlayerStatus statusCmd)
      Play the created Sequence.
      Parameters:
      statusCmd - The finished() method of this command is called when the track finishes being played, i.e. a normal termination. There is no notification if play is forcibly stopped.
    • stop

      public void stop()
      Stop playing music and close resources.