world.sound.tunes
Class Chord

java.lang.Object
  extended by world.sound.tunes.Chord

public class Chord
extends java.lang.Object

A class to represent a collection of notes to be played on one instrument at the same time. Individual notes do not need to have the same duration. Based in part on a class originally designed by Viera K. Proulx.


Field Summary
static int DEFAULT_DUR
          The default Note duration.
static Chord noplay
          A singleton Chord representing silence
 java.util.ArrayList<Note> notes
          the list of notes in this chord
 
Constructor Summary
Chord()
          The default constructor
Chord(int... pitches)
          Creates a Chord from a sequence of Pitches (Note numbers)
Chord(Note... notes)
          Create a Chord from a sequence of Notes.
 
Method Summary
 void addNote(int pitch, int duration)
          Add a Note with the given pitch and duration to this Chord.
 void addNote(Note n)
          Add a given note to this Chord.
 boolean containsNote(Note note)
          Does this chord contain the given note?
 Chord copy()
          Make a copy of this Chord by copying its Notes
 boolean isSilent()
          Have all notes in this chord finish playing?
 Chord nextBeat()
          Reduce all the Notes in this Chord by a single beat.
 int size()
          Get the number of Notes in this Chord.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DUR

public static final int DEFAULT_DUR
The default Note duration.

See Also:
Constant Field Values

notes

public java.util.ArrayList<Note> notes
the list of notes in this chord


noplay

public static final Chord noplay
A singleton Chord representing silence

Constructor Detail

Chord

public Chord()
The default constructor


Chord

public Chord(int... pitches)
Creates a Chord from a sequence of Pitches (Note numbers)


Chord

public Chord(Note... notes)
Create a Chord from a sequence of Notes.

Method Detail

addNote

public void addNote(Note n)
Add a given note to this Chord.


addNote

public void addNote(int pitch,
                    int duration)
Add a Note with the given pitch and duration to this Chord.


nextBeat

public Chord nextBeat()
Reduce all the Notes in this Chord by a single beat. Produces a Chord representing the list of notes that have stopped playing.


isSilent

public boolean isSilent()
Have all notes in this chord finish playing?


copy

public Chord copy()
Make a copy of this Chord by copying its Notes


size

public int size()
Get the number of Notes in this Chord.


containsNote

public boolean containsNote(Note note)
Does this chord contain the given note?