Module hw06

Interface ISequencePlayer

All Known Implementing Classes:
ASequencePlayer, SequencePlayer, SequencePlayer2

public interface ISequencePlayer
Abstract sequence player to create and play MIDI music sequences.
Author:
swong
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
    End of track marker
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    addNote​(Note note, int start)
    Add a note to the MIDI sequence with a default velocity of 64 for middle volume
    int
    addNote​(Note note, int start, int velocity)
    Add a note to the MIDI sequence.
    int
    Accessor for the current tempo
    int
    Accessor to get the current ticks per default note
    int
    Accessor for the current number of ticks per quarter note.
    boolean
    init​(int ticksPerQuarterNote, int instrument)
    Initialize the sequence player as per the supplied ticksPerQuarterNote and instrument this SequencePlayer was instantiated with.
    void
    Play the created sequence.
    void
    setTempo​(int bpm)
    Set the tempo - can't change the tempo in the middle of a sequence, the last tempo set will be used for the whole sequence.
    void
    setTicksPerDefaultNote​(int ticksPerDefaultNote)
    Accessor to set the current ticks per default note
    void
    Stop playing music and close resources.
  • Field Details

  • Method Details

    • init

      boolean init(int ticksPerQuarterNote, int instrument)
      Initialize the sequence player 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
    • addNote

      int addNote(Note note, int start)
      Add a note to the MIDI sequence with a default velocity of 64 for middle volume
      Parameters:
      note - - the note to schedule in the sequence
      start - - the tick at which this note should start playing
      Returns:
      - the tick at which this note stops playing
    • addNote

      int addNote(Note note, int start, int velocity)
      Add a note to the MIDI sequence.
      Parameters:
      note - - the note to schedule in the sequence
      start - - the tick at which this note should start playing
      velocity - - the volume (0-127)
      Returns:
      - the tick at which this note stops playing
    • play

      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

      void stop()
      Stop playing music and close resources.
    • getTicksPerDefaultNote

      int getTicksPerDefaultNote()
      Accessor to get the current ticks per default note
      Returns:
      the _ticksPerDefaultNote
    • setTicksPerDefaultNote

      void setTicksPerDefaultNote(int ticksPerDefaultNote)
      Accessor to set the current ticks per default note
      Parameters:
      ticksPerDefaultNote - the _ticksPerDefaultNote to set
    • getTempo

      int getTempo()
      Accessor for the current tempo
      Returns:
      the tempo (in beats per minute)
    • setTempo

      void setTempo(int bpm)
      Set the tempo - can't change the tempo in the middle of a sequence, the last tempo set will be used for the whole sequence.
      Parameters:
      bpm - - beats per minute
    • getTicksPerQuarterNote

      int getTicksPerQuarterNote()
      Accessor for the current number of ticks per quarter note.
      Returns:
      the number of ticks per quarter note