Class Chord

java.lang.Object
  |
  +--Chord

public class Chord
extends java.lang.Object

Represents a musical chord and the operations that can be performed on it.


Constructor Summary
Chord()
          Creates an empty chord with default values for the minimum and maximum notes for the clefs.
Chord(Chord toCopy)
          Copy constructor.
Chord(int[] midiVals, java.lang.String breakpoint)
          Creates a chord from an array of integers representing MIDI values.  Resolution is done as much as possible.
Chord(int[] midiVals, java.lang.String breakpoint, java.lang.String bassMin, java.lang.String bassMax, java.lang.String trebleMin, java.lang.String trebleMax)
          Creates a chord from an array of integers representing MIDI values.  Resolution is done as much as possible.  Given values used for clef limits.
Chord(java.lang.String notes)
          Creates a chord from a string of notes in standard designation.  The CLEF_DIVIDER in the string, determines which staff notes go on.  Notes before it are added to the bass clef and notes after it are added to the treble clef.  If there is not s bar, the string is not valid input.  Default values used for clef limits.
Chord(java.lang.String notes, java.lang.String breakpoint)
          Creates a chord from a string of notes in standard designation.  The break point determines which staff the notes go on.  If there is a CLEF_DIVIDER in the string, it overrides the break point and notes before it are added to the bass clef and notes after it are added to the treble clef.  Default values used for clef limits.
Chord(java.lang.String bassMin, java.lang.String bassMax, java.lang.String trebleMin, java.lang.String trebleMax)
          Creates an empty chord using passed values for the minimum and maximum notes for the clefs.
Chord(java.lang.String notes, java.lang.String bassMin, java.lang.String bassMax, java.lang.String trebleMin, java.lang.String trebleMax)
          Creates a chord from a string of notes in standard designation.  The CLEF_DIVIDER in the string, determines which staff notes go on.  Notes before it are added to the bass clef and notes after it are added to the treble clef.  If there is not s bar, the string is not valid input.
Chord(java.lang.String notes, java.lang.String breakpoint, java.lang.String bassMin, java.lang.String bassMax, java.lang.String trebleMin, java.lang.String trebleMax)
          Creates a chord from a string of notes in standard designation.  The break point determines which staff the notes go on.
 
Method Summary
 void addNote(int midiVal, char staff)
          Adds note represented by the MIDI value to the staff designated.  If the note is already there and on the correct staff, it does nothing.
 void addNote(int midiVal, java.lang.String breakpoint)
          Adds note represented by the MIDI value as determined by the breakpoint.  If the note is already there, it does nothing.
 void addNote(java.lang.String stdDes, char staff)
          Adds note represented by stdDes to the staff designated.  If the note is already there with the same representation, it does nothing.  If it is there with an alternate representation, it toggles the value of the note.  Conflicts are not resolved because it is assumed that if a note is being added by standard designation, its position is intentional.
 void addNote(java.lang.String stdDes, java.lang.String breakpoint)
          Adds note represented by stdDes by the breakpoint given.  If the note is already there with the same representation, it does nothing.  If it is there with an alternate representation, it toggles the value of the note.  Conflicts are not resolved because it is assumed that if a note is being added by standard designation, its position is intentional.
 void addNotes(int[] midiVals, java.lang.String breakpoint)
          Adds all of the notes represented by the values in midiVals according to the breakpoint.  Conflict resolution is done as much as possible.
 void addNotes(java.lang.String notes)
          Adds all of the notes represented by notes according to the CLEF_DIVIDER.  Resolution is not done and toggling standards are the same as for adding a single note by standard designation and staff.
 void addNotes(java.lang.String notes, java.lang.String breakpoint)
          Adds all of the notes represented by notes according to the breakpoint.  A CLEF_DIVIDER in the string overrides the breakpoint.  Resolution is not done and toggling standards are the same as for adding a single note by standard designation and breakpoint or standard designation and staff if the bar is present.
 boolean canTranspose(int numSteps)
          False if transposing numSteps half steps will cause any of the notes in the chord to go out of valid MIDI bounds.
 void clear()
          Clears all notes from the chord.
 void flipPres(int midiVal, char staff)
          Adds the note represented by midiVal if it is not present and adds it if it is.  If necessary, uses the staff to determine where to put it.
 void flipPres(int midiVal, java.lang.String breakpoint)
          Adds the note represented by midiVal if it is not present and adds it if it is.  If necessary, uses the breakpoint to determine where to put it.
 void flipPres(java.lang.String stdDes, char staff)
          Adds the note represented by stdDes if it is not present and adds it if it is.
 void flipPres(java.lang.String stdDes, java.lang.String breakpoint)
          Adds the note represented by stdDes if it is not present and adds it if it is.  If necessary, uses the breakpoint to determine where to put it.
 java.lang.String getBassMax()
          Returns the highest note that can be put on the bass clef.
 int[] getBassMIDI()
          Returns an array of ints.  Each int is the MIDI value of one of the notes from the bass clef.  Notes will be sorted and in order based on their standard designation representation.
 java.lang.String getBassMin()
          Returns the lowest note that can be put on the bass clef.
 java.lang.String[] getBassStdDes()
          Returns an array of strings.  Each string is the standard desination value of one of the notes from the bass clef.  Notes will be sorted and in order based on their standard designation representation.
 java.lang.String getTitle()
          Returns the string representing the chord title.
 java.lang.String getTrebleMax()
          Returns the highest note that can be put on the treble clef.
 int[] getTrebleMIDI()
          Returns an array of ints.
 java.lang.String getTrebleMin()
          Returns the lowest note that can be put on the treble clef.
 java.lang.String[] getTrebleStdDes()
          Returns an array of strings.  Each string is the standard desination value of one of the notes from the treble clef.  Notes will be sorted and in order based on their standard designation representation.
 boolean isCleared()
          True if there are no notes in the chord and the title has no value.
 boolean isEmpty()
          True if there are no notes in the chord.
 char locate(int midiVal)
          Returns BASS if the note is on the bass clef, TREBLE if it is on the treble, and ' ' if the note is not part of the chord.
 char locate(java.lang.String stdDes)
          Returns BASS if the note is on the bass clef, TREBLE if it is on the treble, and ' ' if the note is not part of the chord.
 void play()
          Creates a new thread with a ChordPlayer object to play this chord.
 java.lang.String removeNote(int midiVal)
          Removes note with MIDI value corresponding to midiVal.  Returns the standard designation string of the note removed.
 java.lang.String removeNote(java.lang.String stdDes)
          Removes note with MIDI value corresponding that of the note represented by stdDes.  Returns the standard designation string of the note removed.  A note with a different standard desination than the one sent may be removed.
 int sameLine(java.lang.String note, char staff)
          Returns a set of flags encoded in an integer which state what variations of a note are on that line.  The sharp is the 3rd least significant bit; i.e. , 4 or 0100b.  Natural is the 2nd least significant bit; 2 or 0010b.  Flat is the least significant bit; 1 or 0001b.  These are OR'ed together to get the return value.
 void setTitle(java.lang.String title)
          Sets the chord title equal to the value of the string given.
 void transpose(int numSteps)
          Tranposing the chord by numSteps half steps.  The user is responsible for making sure each chord can be transposed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Chord

public Chord()
Creates an empty chord with default values for the minimum and maximum notes for the clefs.


Chord

public Chord(java.lang.String bassMin,
             java.lang.String bassMax,
             java.lang.String trebleMin,
             java.lang.String trebleMax)
Creates an empty chord using passed values for the minimum and maximum notes for the clefs.

Parameters:
bassMin - Standard designation value of lowest note that can go on the bass clef.
bassMax - Standard designation value of the highest note that can go on the bass clef.
trebleMin - Standard designation value of the lowest note that can go on the treble clef.
trebleMax - Standard designation value of the highest note that can go on the treble clef.

Chord

public Chord(int[] midiVals,
             java.lang.String breakpoint)
Creates a chord from an array of integers representing MIDI values.  Resolution is done as much as possible.  Default values used for clef limits.

Parameters:
midiVals - MIDI values of the notes to be put into the Chord.
breakpoint - Notes lower than this value go on the bass clef, rest go on the treble clef.

Chord

public Chord(int[] midiVals,
             java.lang.String breakpoint,
             java.lang.String bassMin,
             java.lang.String bassMax,
             java.lang.String trebleMin,
             java.lang.String trebleMax)
Creates a chord from an array of integers representing MIDI values.  Resolution is done as much as possible.  Given values used for clef limits.

Parameters:
midiVals - MIDI values of the notes to be put into the Chord.
breakpoint - Notes lower than this value go on the bass clef, rest go on the treble clef.
bassMin - Standard designation value of lowest note that can go on the bass clef.
bassMax - Standard designation value of the highest note that can go on the bass clef.
trebleMin - Standard designation value of the lowest note that can go on the treble clef.
trebleMax - Standard designation value of the highest note that can go on the treble clef.

Chord

public Chord(java.lang.String notes,
             java.lang.String breakpoint)
Creates a chord from a string of notes in standard designation.  The break point determines which staff the notes go on.  If there is a CLEF_DIVIDER in the string, it overrides the break point and notes before it are added to the bass clef and notes after it are added to the treble clef.  Default values used for clef limits.

Parameters:
notes - Notes in standard designation that are to be put into the chord.
breakpoint - Notes lower than this value go on the bass clef, rest go on the treble clef.

Chord

public Chord(java.lang.String notes,
             java.lang.String breakpoint,
             java.lang.String bassMin,
             java.lang.String bassMax,
             java.lang.String trebleMin,
             java.lang.String trebleMax)
Creates a chord from a string of notes in standard designation.  The break point determines which staff the notes go on. If there is a CLEF_DIVIDER in the string, it overrides the break point and notes before it are added to the bass clef and notes after it are added to the treble clef.  Given values used for clef limits.

Parameters:
notes - Notes in standard designation that are to be put into the chord.
breakpoint - Notes lower than this value go on the bass clef, rest go on the treble clef.
bassMin - Standard designation value of lowest note that can go on the bass clef.
bassMax - Standard designation value of the highest note that can go on the bass clef.
trebleMin - Standard designation value of the lowest note that can go on the treble clef.
trebleMax - Standard designation value of the highest note that can go on the treble clef.

Chord

public Chord(java.lang.String notes)
Creates a chord from a string of notes in standard designation.  The CLEF_DIVIDER in the string, determines which staff notes go on.  Notes before it are added to the bass clef and notes after it are added to the treble clef.  If there is not s bar, the string is not valid input.  Default values used for clef limits.

Parameters:
notes - Notes in standard designation that are to be put into the chord.

Chord

public Chord(java.lang.String notes,
             java.lang.String bassMin,
             java.lang.String bassMax,
             java.lang.String trebleMin,
             java.lang.String trebleMax)
Creates a chord from a string of notes in standard designation.  The CLEF_DIVIDER in the string, determines which staff notes go on.  Notes before it are added to the bass clef and notes after it are added to the treble clef.  If there is not s bar, the string is not valid input. Given values used for clef limits.

Parameters:
notes - Notes in standard designation that are to be put into the chord.
bassMin - Standard designation value of lowest note that can go on the bass clef.
bassMax - Standard designation value of the highest note that can go on the bass clef.
trebleMin - Standard designation value of the lowest note that can go on the treble clef.
trebleMax - Standard designation value of the highest note that can go on the treble clef.

Chord

public Chord(Chord toCopy)
Copy constructor.

Parameters:
toCopy - Chord that is copied.
Method Detail

addNotes

public void addNotes(int[] midiVals,
                     java.lang.String breakpoint)
Adds all of the notes represented by the values in midiVals according to the breakpoint.  Conflict resolution is done as much as possible. Naturals are prefered over sharps and flats whenever possible.

Parameters:
midiVals - MIDI values of the notes to be put into the Chord.
breakpoint - Notes lower than this value go on the bass clef, rest go on the treble clef.

addNotes

public void addNotes(java.lang.String notes,
                     java.lang.String breakpoint)
Adds all of the notes represented by notes according to the breakpoint.  A CLEF_DIVIDER in the string overrides the breakpoint.  Resolution is not done and toggling standards are the same as for adding a single note by standard designation and breakpoint or standard designation and staff if the bar is present.

Parameters:
notes - Notes in standard designation that are to be put into the chord.
breakpoint - Notes lower than this value go on the bass clef, rest go on the treble clef.

addNotes

public void addNotes(java.lang.String notes)
Adds all of the notes represented by notes according to the CLEF_DIVIDER.  Resolution is not done and toggling standards are the same as for adding a single note by standard designation and staff.

Parameters:
notes - Notes in standard designation that are to be put into the chord.

addNote

public void addNote(int midiVal,
                    java.lang.String breakpoint)
Adds note represented by the MIDI value as determined by the breakpoint.  If the note is already there, it does nothing.

Parameters:
midiVal - MIDI value of the note to be put into the Chord.
breakpoint - Notes lower than this value go on the bass clef, rest go on the treble clef.

addNote

public void addNote(int midiVal,
                    char staff)
Adds note represented by the MIDI value to the staff designated.  If the note is already there and on the correct staff, it does nothing.

Parameters:
midiVal - MIDI value of the note to be put into the Chord.
staff - Staff (TREBLE or BASS) that the note should go on.

addNote

public void addNote(java.lang.String stdDes,
                    java.lang.String breakpoint)
Adds note represented by stdDes by the breakpoint given.  If the note is already there with the same representation, it does nothing.  If it is there with an alternate representation, it toggles the value of the note.  Conflicts are not resolved because it is assumed that if a note is being added by standard designation, its position is intentional.

Parameters:
stdDes - Standard designation string of the note to be added.
breakpoint - Notes lower than this value go on the bass clef, rest go on the treble clef.

addNote

public void addNote(java.lang.String stdDes,
                    char staff)
Adds note represented by stdDes to the staff designated.  If the note is already there with the same representation, it does nothing.  If it is there with an alternate representation, it toggles the value of the note.  Conflicts are not resolved because it is assumed that if a note is being added by standard designation, its position is intentional.

Parameters:
stdDes - Standard designation string of the note to be added.
staff - Staff (TREBLE or BASS) that the note should go on.

removeNote

public java.lang.String removeNote(int midiVal)
Removes note with MIDI value corresponding to midiVal.  Returns the standard designation string of the note removed.

Parameters:
midiVal - MIDI number of the note to be removed.

removeNote

public java.lang.String removeNote(java.lang.String stdDes)
Removes note with MIDI value corresponding that of the note represented by stdDes.  Returns the standard designation string of the note removed.  A note with a different standard desination than the one sent may be removed.

Parameters:
stdDes - Standard designation value of the note to be removed.

flipPres

public void flipPres(int midiVal,
                     java.lang.String breakpoint)
Adds the note represented by midiVal if it is not present and adds it if it is.  If necessary, uses the breakpoint to determine where to put it.

Parameters:
midiVal - MIDI number of the note being flipped.
breakpoint - Notes lower than this value go on the bass clef, rest go on the treble clef.

flipPres

public void flipPres(int midiVal,
                     char staff)
Adds the note represented by midiVal if it is not present and adds it if it is.  If necessary, uses the staff to determine where to put it.

Parameters:
midiVal - MIDI number of the note being flipped.
staff - Staff (TREBLE or BASS) that the note should go on.

flipPres

public void flipPres(java.lang.String stdDes,
                     java.lang.String breakpoint)
Adds the note represented by stdDes if it is not present and adds it if it is.  If necessary, uses the breakpoint to determine where to put it.

Parameters:
stdDes - Standard designation value of the note to be flipped.
breakpoint - Notes lower than this value go on the bass clef, rest go on the treble clef.

flipPres

public void flipPres(java.lang.String stdDes,
                     char staff)
Adds the note represented by stdDes if it is not present and adds it if it is.   If necessary, uses the staff to determine where to put it.

Parameters:
stdDes - Standard designation value of the note to be flipped.
staff - Staff (TREBLE or BASS) that the note should go on.

clear

public void clear()
Clears all notes from the chord.


isEmpty

public boolean isEmpty()
True if there are no notes in the chord.


isCleared

public boolean isCleared()
True if there are no notes in the chord and the title has no value.


locate

public char locate(java.lang.String stdDes)
Returns BASS if the note is on the bass clef, TREBLE if it is on the treble, and ' ' if the note is not part of the chord.

Parameters:
stdDes - Standard designation value of the note to be located.

locate

public char locate(int midiVal)
Returns BASS if the note is on the bass clef, TREBLE if it is on the treble, and ' ' if the note is not part of the chord.

Parameters:
midiVal - MIDI number of the note to be located.

canTranspose

public boolean canTranspose(int numSteps)
False if transposing numSteps half steps will cause any of the notes in the chord to go out of valid MIDI bounds.

Parameters:
numSteps - Number of half steps in the transposition.

transpose

public void transpose(int numSteps)
Tranposing the chord by numSteps half steps.  The user is responsible for making sure each chord can be transposed.

Parameters:
numSteps - Number of half steps in the transposition.

play

public void play()
Creates a new thread with a ChordPlayer object to play this chord.


setTitle

public void setTitle(java.lang.String title)
Sets the chord title equal to the value of the string given.

Parameters:
title - New title for the chord.

getBassStdDes

public java.lang.String[] getBassStdDes()
Returns an array of strings.  Each string is the standard desination value of one of the notes from the bass clef.  Notes will be sorted and in order based on their standard designation representation.


getBassMIDI

public int[] getBassMIDI()
Returns an array of ints.  Each int is the MIDI value of one of the notes from the bass clef.  Notes will be sorted and in order based on their standard designation representation.


getTrebleStdDes

public java.lang.String[] getTrebleStdDes()
Returns an array of strings.  Each string is the standard desination value of one of the notes from the treble clef.  Notes will be sorted and in order based on their standard designation representation.


getTrebleMIDI

public int[] getTrebleMIDI()
Returns an array of ints.   Each int is the MIDI value of one of the notes from the bass clef.  Notes will be sorted and in order based on their standard designation representation.


sameLine

public int sameLine(java.lang.String note,
                    char staff)
Returns a set of flags encoded in an integer which state what variations of a note are on that line.  The sharp is the 3rd least significant bit; i.e. , 4 or 0100b.  Natural is the 2nd least significant bit; 2 or 0010b.  Flat is the least significant bit; 1 or 0001b.  These are OR'ed together to get the return value.

Parameters:
note - Note to be tested against.

getTitle

public java.lang.String getTitle()
Returns the string representing the chord title.


getBassMin

public java.lang.String getBassMin()
Returns the lowest note that can be put on the bass clef.


getBassMax

public java.lang.String getBassMax()
Returns the highest note that can be put on the bass clef.


getTrebleMin

public java.lang.String getTrebleMin()
Returns the lowest note that can be put on the treble clef.


getTrebleMax

public java.lang.String getTrebleMax()
Returns the highest note that can be put on the treble clef.