ScorePlayer


A ScorePlayer is an object which can play a Score. The ScorePlayer keeps track of the position, speed, and filters of the Score. Note that it is perfectly okay to have multiple ScorePlayers playing the same Score at once.

class ScorePlayer {
public:
  typedef UtilPtr<Score> ScorePtr;
  typedef UtilPtr<MidiFilter> MidiFilterPtr;
  static void startMultiple(ScorePlayerPtrArray*);
  static void stopMultiple(ScorePlayerPtrArray*);
  ScorePlayer(ScorePtr);
  ScorePlayer(Rogus_McBogus*, ScorePtr, void (*func)(const MidiMsg&) = defaultOutFunc);
  ~ScorePlayer();
  void start();
  void stop();
  Bool isPlaying() const;
  void setMute(Bool);
  Bool getMute() const;
  void setLoop(Bool);
  Bool getLoop() const;
  void rewind();
  void setIndex(int);
  int getIndex() const;
  void setTimeUnscaled(ScoreTime);
  ScoreTime getTimeUnscaled() const;
  void setTimeScaled(ScoreTime);
  ScoreTime getTimeScaled() const;
  void setScale(ScoreScale);
  ScoreScale getScale() const;
  void addFilter(MidiFilterPtr);
  void removeFilter(char*);
  MidiFilterPtr getFilter(char*) const;
};
static void startMultiple(ScorePlayerPtrArray* a)
Causes all of the ScorePlayers listed in a to start playing simultaneously.
static void stopMultiple(ScorePlayerPtrArray* a)
Causes all of the ScorePlayers listed in a to stop playing simultaneously.
ScorePlayer(ScorePtr s)
Creates a new ScorePlayer which can play Score s. The output function is oap->write(). When created, the ScorePlayer is not playing, is not muted, is not looped, has a scale of 1, is positioned at the beginning, and has no filters.
ScorePlayer(Rogus_McBogus*, ScorePtr, void (*func)(const MidiMsg&) = defaultOutFunc)
Creates a new ScorePlayer which can play Score s. The output function is func, which should be a function that plays the MidiMsg m in some customized way. When created, the ScorePlayer is not playing, is not muted, is not looped, has a scale of 1, is positioned at the beginning, and has no filters.
~ScorePlayer()
Destroys the ScorePlayer. The ScorePlayer stops playing when it is destroyed.
void start()
This causes the ScorePlayer to start playing the Score at the current position. Nothing happens if the ScorePlayer is already playing.
void stop()
This causes the ScorePlayer to stop playing the Score. Nothing happens if the ScorePlayer is not playing.
Bool isPlaying()
This function returns 1 if the ScorePlayer is playing and 0 if it is not.
void setMute(Bool m)
This function causes the ScorePlayer to be muted (not send out any MidiMsgs) if the argument is 1, and not be muted if the argument is 0. Note that functions in a Score will be called even if the Score is muted.
Bool getMute()
This returns the value set by setMute.
void setLoop(Bool l)
This function causes the ScorePlayer to loop (i. e. go back to the beginning when it reaches the end) if the argument is 1, and not loop (i. e. stop playing when it reaches the end) if the argument is 0. It is okay to do this whether the ScorePlayer is currently playing or not.
Bool getLoop()
This returns the value set by setLoop.
void rewind()
This moves the ScorePlayer back to the beginning of the Score. Yes, it is okay to do this while the ScorePlayer is playing.
void setIndex(int n)
This moves the ScorePlayer to event number n. Yes, it is okay to do this while the ScorePlayer is playing.
int getIndex()
This returns the current event index.
void setTimeUnscaled(ScoreTime t)
This sets the position of the ScorePlayer to t demimilliseconds from the beginning of the Score, based on the default speed of the Score. It is okay to call this function while the ScorePlayer is playing.
ScoreTime getTimeUnscaled()
This gets the position of the ScorePlayer in demimilliseconds from the beginning of the Score, based on the default speed of the Score.
void setTimeScaled(ScoreTime t)
This sets the position of the ScorePlayer to t demimilliseconds from the beginning of the Score, based on the current ScoreScale of the ScorePlayer. It is okay to call this function while the ScorePlayer is playing.
ScoreTime getTimeScaled()
This gets the position of the ScorePlayer in demimilliseconds from the beginning of the Score, based on the current ScoreScale of the ScorePlayer.
void setScale(ScoreScale s)
This sets the speed of the ScorePlayer. The default durations are multiplied by s to get the actual durations. Therefore, 1 will play the Score at the default speed, .5 will play it twice as fast, 2 will play it twice as slow, etc. And guess what? You can call this function while the ScorePlayer is playing.
ScoreScale getScale()
This returns the scaling factor that was set with setScale.
void addFilter(MidiFilterPtr f)
This member function adds a MidiFilter to the ScorePlayer. If a MidiFilter of the same type already exists (e. g. there is already a Transposer and you try to add another Transposer), then the existing one will be removed.
void removeFilter(char* x)
This member function removes the filter named x (for example, "Transposer") from the ScorePlayer
MidiFilterPtr getFilter(char* x)
This member function returns a pointer to the filter named x, if it exists in the current ScorePlayer, or a null pointer if it does not.