jcaas.midi
Class MIDIPlayer

java.lang.Object
  extended by jmusic.midi.DefaultRealTimeChannelManager
      extended by jcaas.midi.MIDIPlayer
All Implemented Interfaces:
IRealTimeChannel

public class MIDIPlayer
extends DefaultRealTimeChannelManager
implements IRealTimeChannel

MIDIPlayer is the main class for the sub-system that is responsible for playing midi sound during program execution.

Version:
last updated: 4/17/05
Author:
Conrad Hutcheson

Constructor Summary
MIDIPlayer(Score s)
          Constructor, makes a player to play staff on channel 0, do not print notes and other information.
MIDIPlayer(Score s, boolean b)
          Constructor, makes a player to play Staff on channel 0, information may be printed.
 
Method Summary
 IRealTimeChannel getChannel(int i)
           
 MMessage getInfo(int i, MMessage m)
          A method to get information about the Player and currently Playing Scores/Staffs.
 int getInstrument()
           
 NoteWrapper getNext()
           
 int getNumChans()
          getNumChans returns the number of available channels
 short getPPQN()
           
 Score getScore(int chan)
          getScore returns the Score currently being played on a given channel.
 boolean passMessage(int i, MMessage m)
          A method to inform the Player/Score of changes it should make.
 NoteWrapper peek()
           
 void play()
          play starts and runs the infinite Staff-playing loop.
 void setEnqueuer(MIDIPlayerEnqueuer enqueuer)
           
 void setPPQN(short ppqn)
           
 boolean setScore(int chan, Score stf)
          setScore changes the Score on a given channel.
 boolean setScore(Score s)
          A method to change the score of the MidiPlayer.
 
Methods inherited from class jmusic.midi.DefaultRealTimeChannelManager
getTicker
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MIDIPlayer

public MIDIPlayer(Score s)
Constructor, makes a player to play staff on channel 0, do not print notes and other information.

Parameters:
s- - The Staff that is to be set to channel 0 initially.

MIDIPlayer

public MIDIPlayer(Score s,
                  boolean b)
Constructor, makes a player to play Staff on channel 0, information may be printed.

Parameters:
s - - The Staff that is to be set to channel 0 initially.
b - - boolean that determines if note/state change information is printed.
Method Detail

play

public void play()
play starts and runs the infinite Staff-playing loop.


setScore

public boolean setScore(int chan,
                        Score stf)
setScore changes the Score on a given channel.

Parameters:
chan - - the int number of the channel to modify.
stf - - the new Score.
Returns:
true for success, fales otherwise

getNumChans

public int getNumChans()
getNumChans returns the number of available channels

Returns:
the int number of channels available.

getScore

public Score getScore(int chan)
getScore returns the Score currently being played on a given channel.

Parameters:
chan - - the int number of the channel to get the Score being played on.
Returns:
the Staff being played on the channel. null if no Score is loaded for the channel/invalid channel.

passMessage

public boolean passMessage(int i,
                           MMessage m)
A method to inform the Player/Score of changes it should make.

Parameters:
i - the index of the staff/Score to modify.
m - the message to be implemented
Returns:
true if successful change, false otherwise.

getInfo

public MMessage getInfo(int i,
                        MMessage m)
A method to get information about the Player and currently Playing Scores/Staffs.

Parameters:
i - the index of the staff/score to get information about
type - the type of information to get
Returns:
a MMessage containing the requested info

setScore

public boolean setScore(Score s)
A method to change the score of the MidiPlayer. Sets the score to channel 0

Parameters:
s - the new Score
Returns:
true for success, false otherwise

setPPQN

public void setPPQN(short ppqn)
Specified by:
setPPQN in interface IRealTimeChannel

getNext

public NoteWrapper getNext()
Specified by:
getNext in interface IRealTimeChannel

peek

public NoteWrapper peek()
Specified by:
peek in interface IRealTimeChannel

getInstrument

public int getInstrument()
Specified by:
getInstrument in interface IRealTimeChannel

getPPQN

public short getPPQN()
Specified by:
getPPQN in interface IRealTimeChannel

getChannel

public IRealTimeChannel getChannel(int i)
Overrides:
getChannel in class DefaultRealTimeChannelManager

setEnqueuer

public void setEnqueuer(MIDIPlayerEnqueuer enqueuer)