movements
Class AbcMusicPlayer

java.lang.Object
  extended bymovements.AbcMusicPlayer

public class AbcMusicPlayer
extends java.lang.Object

DOCUMENT ME!

Version:
$Revision: 1.1 $
Author:
$author$

Nested Class Summary
private  class AbcMusicPlayer.CachedNoteInfo
           
 
Field Summary
(package private)  int adjustmentToFollowingNote
          If accidentals are found (sharps, flats, or naturals) then update this field to be the adjustment to make to the next note.
private  AbcMusicPlayer.CachedNoteInfo[] cachedNotes
           
private  boolean fLengthenNote
           
private  boolean fShortenNote
           
private  int inputPosition
           
private  int introductoryTicks
          There may be introductory music that is played before the dance starts.
private  int irregularNoteDivider
           
private  int irregularNoteMultiplier
           
private  int keyAdjustment
          The sharp/flat adjustment to the signature key.
private  int keyLetterIndex
          The signature key, where 0=C thru 6=B.
private  boolean KFieldSpecified
           
private  boolean LFieldSpecified
           
private  int meterDenominator
           
private  int meterNumerator
           
private  boolean MFieldSpecified
           
private  MusicNote[] music
           
private  int musicEndTick
          The number of ticks from the start of the dance (i.e.
private static int NO_ADJUSTMENT
           
private  int noteLengthDenominator
           
private  int noteLengthNumerator
           
private  java.lang.String notes
          The input string containing the music in abc format.
private  int notesPerBar
           
private  int numberOfIrregularNotes
           
private  int numberOfNotes
           
private  int[] scaleSemiTones
           
private  int[] signature
          This array indicates, for each letter C=0 thru B=6, whether the note is sharpened or flattened.
private  double startNoteBar
           
private  int ticksPerBar
           
private  int timesThruTheMusic
          The number of times the music must be repeated to fill up the length of the dance.
private  int totalTicksInMusic
          The number of ticks between one repeat of the music and the next repeat.
 
Constructor Summary
(package private) AbcMusicPlayer(java.lang.String notes, int ticksPerBar, int numberOfBarsInTheDance)
          DOCUMENT ME!
 
Method Summary
(package private)  MusicPlayer getMusicPlayer()
          Get an object that plays the music.
private  void LowerCaseNote(int letterNumber)
          DOCUMENT ME!
private  void ParseField(int endOfField)
          DOCUMENT ME!
private  int ParseLength(int defaultValue)
          Parses the length of a note.
private  void ParseNote(int letterIndex)
          DOCUMENT ME!
private  void SetSignature()
          Set up the signature array which indicates, for each letter, whether the note is sharpened, flattened, double sharpened etc.
private  void UpperCaseNote(int letterNumber)
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

notes

private java.lang.String notes
The input string containing the music in abc format.


ticksPerBar

private int ticksPerBar

inputPosition

private int inputPosition

MFieldSpecified

private boolean MFieldSpecified

LFieldSpecified

private boolean LFieldSpecified

KFieldSpecified

private boolean KFieldSpecified

meterNumerator

private int meterNumerator

meterDenominator

private int meterDenominator

noteLengthNumerator

private int noteLengthNumerator

noteLengthDenominator

private int noteLengthDenominator

notesPerBar

private int notesPerBar

keyLetterIndex

private int keyLetterIndex
The signature key, where 0=C thru 6=B. The value of this field is set from the value of the K: field.


keyAdjustment

private int keyAdjustment
The sharp/flat adjustment to the signature key. The value is 1 if sharp, -1 if flat, 2 if double sharp etc. The value of this field is set from the value of the K: field.


signature

private int[] signature
This array indicates, for each letter C=0 thru B=6, whether the note is sharpened or flattened. 1 = sharpened, -1 = flattened, 2 = double sharp etc. The value of this field is set from the value of the K: field at the start of each bar. This array is modified if any sharps or flats are found and it remains modified until the end of the bar.


NO_ADJUSTMENT

private static final int NO_ADJUSTMENT
See Also:
#adjustmentToFollowingNote., Constant Field Values

adjustmentToFollowingNote

int adjustmentToFollowingNote
If accidentals are found (sharps, flats, or naturals) then update this field to be the adjustment to make to the next note. NO_ADJUSTMENT = Sharpen or flatten according to the key signature or to whatever adjustment has been made to a previous occurance of the same note in the bar. 0 = Make the note a natural, even if the key signature sharpens or flattens the note and even if a previous occurance of the note in the bar has been sharpened or flattened. 1 = sharpen the note 2 = double sharpen the note -1 = flatten the note -2 = double flatten the note


introductoryTicks

private int introductoryTicks
There may be introductory music that is played before the dance starts. This indicates how many ticks are needed to play the introductory music. It will be set to zero if there is no introductory music.


totalTicksInMusic

private int totalTicksInMusic
The number of ticks between one repeat of the music and the next repeat. Therefore this count does not include introductory music that is played only before the dance starts. It does include the time in any incomplete bar at the end that is usually filled with a repeat of the introductory music.


musicEndTick

private int musicEndTick
The number of ticks from the start of the dance (i.e. excluding any introductory music) until the end of the last note or rest in the last bar. If this is less than totalTicksInMusic then the difference is an incomplete last bar which is filled with a repeat of any introductory music.


timesThruTheMusic

private int timesThruTheMusic
The number of times the music must be repeated to fill up the length of the dance.


fLengthenNote

private boolean fLengthenNote

fShortenNote

private boolean fShortenNote

numberOfIrregularNotes

private int numberOfIrregularNotes

irregularNoteMultiplier

private int irregularNoteMultiplier

irregularNoteDivider

private int irregularNoteDivider

cachedNotes

private AbcMusicPlayer.CachedNoteInfo[] cachedNotes

startNoteBar

private double startNoteBar

music

private MusicNote[] music

numberOfNotes

private int numberOfNotes

scaleSemiTones

private int[] scaleSemiTones
Constructor Detail

AbcMusicPlayer

AbcMusicPlayer(java.lang.String notes,
               int ticksPerBar,
               int numberOfBarsInTheDance)
         throws MusicException
DOCUMENT ME!

Parameters:
notes - DOCUMENT ME!
ticksPerBar - DOCUMENT ME!
numberOfBarsInTheDance - This is needed because if the last bar is incomplete then the bar is filled with the introductory music. However the introductory music is not played at the end of the last time thru. In order to know if we are playing the tune the last time thru, we must know the total number of bars in the dance. Note that the total number of bars in the dance must be a multiple of the total number of bars in the music. If it is not then an exception is thrown.
Throws:
MusicException - DOCUMENT ME!
Method Detail

ParseField

private void ParseField(int endOfField)
                 throws MusicException
DOCUMENT ME!

Parameters:
endOfField - DOCUMENT ME!
Throws:
MusicException - DOCUMENT ME!

SetSignature

private void SetSignature()
Set up the signature array which indicates, for each letter, whether the note is sharpened, flattened, double sharpened etc. keyLetterIndex is 0=C thru 6=B. keyAdjustment is 1 if sharp, -1 if flat, 2 if double sharp etc.


UpperCaseNote

private void UpperCaseNote(int letterNumber)
DOCUMENT ME!

Parameters:
letterNumber - DOCUMENT ME!

LowerCaseNote

private void LowerCaseNote(int letterNumber)
DOCUMENT ME!

Parameters:
letterNumber - DOCUMENT ME!

ParseNote

private void ParseNote(int letterIndex)
DOCUMENT ME!

Parameters:
letterIndex - DOCUMENT ME!

ParseLength

private int ParseLength(int defaultValue)
Parses the length of a note. Up to two digits are read from the string and the resulting value is returned. If the next character is not a digit then the default value is returned. inputPosition is advanced to the next position after the length.

Parameters:
defaultValue - If the next character in the input string is not a digit then no length has been specified for this note and a default value must be used. This parameter gives the appropriate default value.
Returns:
The length of the note

getMusicPlayer

MusicPlayer getMusicPlayer()
Get an object that plays the music. Whereas the AbcMusicPlayer class is used while processing the ABC formatted music in the XML only, the MusicPlayer object is used while animating the dance and is therefore serializable.

Returns:
DOCUMENT ME!


Copyright © 2003 Nigel Westbury