jm.music.data
Class Phrase

java.lang.Object
  extended by jm.music.data.Phrase
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Alignments, DrumMap, Durations, Dynamics, Frequencies, Noises, Panning, Pitches, ProgramChanges, RhythmValues, Scales, Tunings, Volumes, Waveforms, JMC

public class Phrase
extends java.lang.Object
implements JMC, java.lang.Cloneable, java.io.Serializable

The Phrase class is representative of a single musical phrase. Phrases are held in Parts and can be played at any time based on there start times. They may be played sequentially or in parallel. Phrases can be added to an Part like this...

     Part inst = new Part("Flute");
     //Phrase for the right hand
     Phrase rightHand = new Phrase(0.0) //start this phrase on the first beat
     //Phrase for the left hand
     Phrase leftHane = new Phrase(4.0) //start this phrase on the fifth beat
     inst.addPhrase(rightHand);
     inst.addPhrase(leftHand);
 

Author:
Andrew Sorensen and Andrew Brown
See Also:
Note, Part, Serialized Form

Field Summary
static boolean DEFAULT_APPEND
           
static int DEFAULT_DENOMINATOR
           
static int DEFAULT_INSTRUMENT
           
static int DEFAULT_NUMERATOR
           
static double DEFAULT_PAN
           
static double DEFAULT_START_TIME
           
static double DEFAULT_TEMPO
           
static java.lang.String DEFAULT_TITLE
           
static int DEFAULT_VOLUME
           
static double MIN_START_TIME
          The smallest start time in beats
 
Fields inherited from interface jm.JMC
AMPLITUDE, DEBUG, DYNAMIC, EIGHT_BIT, FREQUENCY, KEY_SIG_EVT, MONO, NO_DENOMINATOR, NO_INSTRUMENT, NO_KEY_QUALITY, NO_KEY_SIGNATURE, NO_NUMERATOR, OCTAPHONIC, PAN, PITCH, PROG_EVT, QUADRAPHONIC, RHYTHM, SIXTEEN_BIT, STEREO, TEMP_EVT, THIRTY_TWO_BIT, TIME_SIG_EVT, VERBOSE
 
Fields inherited from interface jm.constants.Durations
C, CD, CDD, CROTCHET, CROTCHET_TRIPLET, CT, DC, DDC, DDEN, DDHN, DDM, DDQ, DDQN, DEMI_SEMI_QUAVER, DEMI_SEMI_QUAVER_TRIPLET, DEN, DHN, DM, DOTTED_CROTCHET, DOTTED_EIGHTH_NOTE, DOTTED_HALF_NOTE, DOTTED_MINIM, DOTTED_QUARTER_NOTE, DOTTED_QUAVER, DOTTED_SEMI_QUAVER, DOTTED_SIXTEENTH_NOTE, DOUBLE_DOTTED_CROTCHET, DOUBLE_DOTTED_EIGHTH_NOTE, DOUBLE_DOTTED_HALF_NOTE, DOUBLE_DOTTED_MINIM, DOUBLE_DOTTED_QUARTER_NOTE, DOUBLE_DOTTED_QUAVER, DQ, DQN, DSN, DSQ, DSQT, EIGHTH_NOTE, EIGHTH_NOTE_TRIPLET, EN, ENT, HALF_NOTE, HALF_NOTE_TRIPLET, HN, HNT, M, MD, MDD, MINIM, MINIM_TRIPLET, MT, Q, QD, QDD, QN, QNT, QT, QUARTER_NOTE, QUARTER_NOTE_TRIPLET, QUAVER, QUAVER_TRIPLET, SB, SEMI_QUAVER, SEMI_QUAVER_TRIPLET, SEMIBREVE, SIXTEENTH_NOTE, SIXTEENTH_NOTE_TRIPLET, SN, SNT, SQ, SQD, SQT, THIRTYSECOND_NOTE, THIRTYSECOND_NOTE_TRIPLET, TN, TNT, TSN, TSNT, WHOLE_NOTE, WN
 
Fields inherited from interface jm.constants.Pitches
a0, A0, a1, A1, a2, A2, a3, A3, a4, A4, a5, A5, a6, A6, a7, A7, a8, A8, af0, AF0, af1, AF1, af2, AF2, af3, AF3, af4, AF4, af5, AF5, af6, AF6, af7, AF7, af8, AF8, afn1, AFN1, an1, AN1, as0, AS0, as1, AS1, as2, AS2, as3, AS3, as4, AS4, as5, AS5, as6, AS6, as7, AS7, as8, AS8, asn1, ASN1, b0, B0, b1, B1, b2, B2, b3, B3, b4, B4, b5, B5, b6, B6, b7, B7, b8, B8, bf0, BF0, bf1, BF1, bf2, BF2, bf3, BF3, bf4, BF4, bf5, BF5, bf6, BF6, bf7, BF7, bf8, BF8, bfn1, BFN1, bn1, BN1, bs0, BS0, bs1, BS1, bs2, BS2, bs3, BS3, bs4, BS4, bs5, BS5, bs6, BS6, bs7, BS7, bs8, BS8, bsn1, BSN1, c0, C0, c1, C1, c2, C2, c3, C3, c4, C4, c5, C5, c6, C6, c7, C7, c8, C8, c9, C9, cf0, CF0, cf1, CF1, cf2, CF2, cf3, CF3, cf4, CF4, cf5, CF5, cf6, CF6, cf7, CF7, cf8, CF8, cf9, CF9, cn1, CN1, cs0, CS0, cs1, CS1, cs2, CS2, cs3, CS3, cs4, CS4, cs5, CS5, cs6, CS6, cs7, CS7, cs8, CS8, cs9, CS9, csn1, CSN1, d0, D0, d1, D1, d2, D2, d3, D3, d4, D4, d5, D5, d6, D6, d7, D7, d8, D8, d9, D9, df0, DF0, df1, DF1, df2, DF2, df3, DF3, df4, DF4, df5, DF5, df6, DF6, df7, DF7, df8, DF8, df9, DF9, dfn1, DFN1, dn1, DN1, ds0, DS0, ds1, DS1, ds2, DS2, ds3, DS3, ds4, DS4, ds5, DS5, ds6, DS6, ds7, DS7, ds8, DS8, ds9, DS9, dsn1, DSN1, e0, E0, e1, E1, e2, E2, e3, E3, e4, E4, e5, E5, e6, E6, e7, E7, e8, E8, e9, E9, ef0, EF0, ef1, EF1, ef2, EF2, ef3, EF3, ef4, EF4, ef5, EF5, ef6, EF6, ef7, EF7, ef8, EF8, ef9, EF9, efn1, EFN1, en1, EN1, es0, ES0, es1, ES1, es2, ES2, es3, ES3, es4, ES4, es5, ES5, es6, ES6, es7, ES7, es8, ES8, es9, ES9, esn1, ESN1, f0, F0, f1, F1, f2, F2, f3, F3, f4, F4, f5, F5, f6, F6, f7, F7, f8, F8, f9, F9, ff0, FF0, ff1, FF1, ff2, FF2, ff3, FF3, ff4, FF4, ff5, FF5, ff6, FF6, ff7, FF7, ff8, FF8, ff9, FF9, ffn1, FFN1, fn1, FN1, fs0, FS0, fs1, FS1, fs2, FS2, fs3, FS3, fs4, FS4, fs5, FS5, fs6, FS6, fs7, FS7, fs8, FS8, fs9, FS9, fsn1, FSN1, g0, G0, g1, G1, g2, G2, g3, G3, g4, G4, g5, G5, g6, G6, g7, G7, g8, G8, g9, G9, gf0, GF0, gf1, GF1, gf2, GF2, gf3, GF3, gf4, GF4, gf5, GF5, gf6, GF6, gf7, GF7, gf8, GF8, gf9, GF9, gfn1, GFN1, gn1, GN1, gs0, GS0, gs1, GS1, gs2, GS2, gs3, GS3, gs4, GS4, gs5, GS5, gs6, GS6, gs7, GS7, gs8, GS8, gsn1, GSN1, REST
 
Fields inherited from interface jm.constants.Frequencies
FRQ
 
Fields inherited from interface jm.constants.Tunings
EQUAL, JUST, MEAN, PYTHAGOREAN
 
Fields inherited from interface jm.constants.Volumes
F, FF, FFF, FORTE, FORTISSIMO, MEZZO_FORTE, MEZZO_PIANO, MF, MP, P, PIANISSIMO, PP, PPP, SILENT
 
Fields inherited from interface jm.constants.Panning
PAN_CENTER, PAN_CENTRE, PAN_LEFT, PAN_RIGHT
 
Fields inherited from interface jm.constants.ProgramChanges
AAH, ABASS, AC_GUITAR, ACCORDION, ACOUSTIC_BASS, ACOUSTIC_GRAND, ACOUSTIC_GUITAR, AGOGO, AHHS, ALTO, ALTO_SAX, ALTO_SAXOPHONE, APPLAUSE, ATMOSPHERE, BAG_PIPES, BAGPIPE, BAGPIPES, BANDNEON, BANJO, BARI, BARI_SAX, BARITONE, BARITONE_SAX, BARITONE_SAXOPHONE, BASS, BASSOON, BELL, BELLS, BIRD, BOTTLE, BOTTLE_BLOW, BOWED_GLASS, BRASS, BREATH, BREATHNOISE, BRIGHT_ACOUSTIC, BRIGHTNESS, CALLOPE, CELESTA, CELESTE, CELLO, CGUITAR, CHARANG, CHIFFER, CHIFFER_LEAD, CHOIR, CHURCH_ORGAN, CLAR, CLARINET, CLAV, CLAVINET, CLEAN_GUITAR, CONCERTINA, CONTRA_BASS, CONTRABASS, CRYSTAL, CYMBAL, DGUITAR, DIST_GUITAR, DISTORTED_GUITAR, DOUBLE_BASS, DROPS, DRUM, DX_EPIANO, EBASS, ECHO, ECHO_DROP, ECHO_DROPS, ECHOS, EL_BASS, EL_GUITAR, ELECTRIC_BASS, ELECTRIC_GRAND, ELECTRIC_GUITAR, ELECTRIC_ORGAN, ELECTRIC_PIANO, ELPIANO, ENGLISH_HORN, EPIANO, EPIANO2, FANTASIA, FBASS, FIDDLE, FINGERED_BASS, FLUTE, FRENCH_HORN, FRET, FRET_NOISE, FRETLESS, FRETLESS_BASS, FRETNOISE, FRETS, GLOCK, GLOCKENSPIEL, GMSAW_WAVE, GMSQUARE_WAVE, GOBLIN, GT_HARMONICS, GUITAR, GUITAR_HARMONICS, HALO, HALO_PAD, HAMMOND_ORGAN, HARMONICA, HARMONICS, HARP, HARPSICHORD, HELICOPTER, HONKYTONK, HONKYTONK_PIANO, HORN, ICE_RAIN, ICERAIN, JAZZ_GUITAR, JAZZ_ORGAN, JGUITAR, KALIMBA, KOTO, MARIMBA, METAL_PAD, MGUITAR, MUSIC_BOX, MUTED_GUITAR, MUTED_TRUMPET, NGUITAR, NYLON_GUITAR, OBOE, OCARINA, OGUITAR, OOH, OOHS, ORCHESTRA_HIT, ORGAN, ORGAN2, ORGAN3, OVERDRIVE_GUITAR, PAD, PAN_FLUTE, PANFLUTE, PBASS, PHONE, PIANO, PIANO_ACCORDION, PIC, PICC, PICCOLO, PICKED_BASS, PIPE_ORGAN, PIPES, PITZ, PIZZ, PIZZICATO_STRINGS, POLY_SYNTH, POLYSYNTH, PSTRINGS, RAIN, RECORDER, REED_ORGAN, REVERSE_CYMBAL, RHODES, SAW, SAWTOOTH, SAX, SAXOPHONE, SBASS, SEA, SEASHORE, SFX, SGUITAR, SHAKUHACHI, SHAMISEN, SHANNAI, SITAR, SLAP, SLAP_BASS, SLOW_STRINGS, SOLO_VOX, SOP, SOPRANO, SOPRANO_SAX, SOPRANO_SAXOPHONE, SOUNDEFFECTS, SOUNDFX, SOUNDTRACK, SPACE_VOICE, SQUARE, STAR_THEME, STEEL_DRUM, STEEL_DRUMS, STEEL_GUITAR, STEELDRUM, STEELDRUMS, STR, STREAM, STRINGS, SWEEP, SWEEP_PAD, SYN_CALLIOPE, SYN_STRINGS, SYNTH_BASS, SYNTH_BRASS, SYNTH_CALLIOPE, SYNTH_DRUM, SYNTH_DRUMS, SYNTH_STRINGS, SYNVOX, TAIKO, TELEPHONE, TENOR, TENOR_SAX, TENOR_SAXOPHONE, THUMB_PIANO, THUNDER, TIMP, TIMPANI, TINKLE_BELL, TOM, TOM_TOM, TOM_TOMS, TOMS, TREMOLO, TREMOLO_STRINGS, TROMBONE, TRUMPET, TUBA, TUBULAR_BELL, TUBULAR_BELLS, VIBES, VIBRAPHONE, VIOLA, VIOLIN, VIOLIN_CELLO, VOICE, VOX, WARM_PAD, WHISTLE, WIND, WOODBLOCK, WOODBLOCKS, XYLOPHONE
 
Fields inherited from interface jm.constants.DrumMap
ACOUSTIC_BASS_DRUM, ACOUSTIC_SNARE, BASS_DRUM_1, CABASA, CHINESE_CYMBAL, CLAVES, CLOSED_HI_HAT, COWBELL, CRASH_CYMBAL_1, CRASH_CYMBAL_2, ELECTRIC_SNARE, HAND_CLAP, HI_BONGO, HI_MID_TOM, HI_WOOD_BLOCK, HIGH_AGOGO, HIGH_FLOOR_TOM, HIGH_TIMBALE, HIGH_TOM, LONG_GUIRO, LONG_WHISTLE, LOW_AGOGO, LOW_BONGO, LOW_CONGA, LOW_FLOOR_TOM, LOW_MID_TOM, LOW_TIMBALE, LOW_TOM, LOW_WOOD_BLOCK, MARACAS, MUTE_CUICA, MUTE_HI_CONGA, MUTE_TRIANGLE, OPEN_CUICA, OPEN_HI_CONGA, OPEN_HI_HAT, OPEN_TRIANGLE, PEDAL_HI_HAT, RIDE_BELL, RIDE_CYMBAL_1, RIDE_CYMBAL_2, SHORT_GUIRO, SHORT_WHISTLE, SIDE_STICK, SPLASH_CYMBAL, TAMBOURINE, VIBRASLAP
 
Fields inherited from interface jm.constants.Scales
AEOLIAN_SCALE, BLUES_SCALE, CHROMATIC_SCALE, DIATONIC_MINOR_SCALE, DORIAN_SCALE, HARMONIC_MINOR_SCALE, INDIAN_SCALE, LYDIAN_SCALE, MAJOR_SCALE, MELODIC_MINOR_SCALE, MINOR_SCALE, MIXOLYDIAN_SCALE, NATURAL_MINOR_SCALE, PENTATONIC_SCALE, TURKISH_SCALE
 
Fields inherited from interface jm.constants.Waveforms
COSINE_WAVE, PULSE_WAVE, SABERSAW_WAVE, SAWDOWN_WAVE, SAWTOOTH_WAVE, SINE_WAVE, SQUARE_WAVE, TRIANGLE_WAVE
 
Fields inherited from interface jm.constants.Noises
BROWN_NOISE, FRACTAL_NOISE, SMOOTH_NOISE, STEP_NOISE, WHITE_NOISE
 
Fields inherited from interface jm.constants.Alignments
AFTER, BEFORE, CENTER_ALIGN, CENTER_ON_END, CENTER_ON_START, CENTRE_ALIGN, CENTRE_ON_END, CENTRE_ON_START, END_ON_CENTER, END_ON_CENTRE, END_TOGETHER, START_ON_CENTER, START_ON_CENTRE, START_TOGETHER
 
Constructor Summary
Phrase()
          Creates an empty Phrase.
Phrase(double startTime)
          Creates an empty Phrase starting at the specified beat.
Phrase(double startTime, int instrument)
          Creates an empty Phrase
Phrase(Note note)
          Constructs a new Phrase containing the specified note.
Phrase(Note[] notes)
          Constructs a new Phrase containing the specified notes.
Phrase(Note[] notes, java.lang.String title)
          Constructs a new Phrase containing the specified notes with the specified title.
Phrase(Note note, double startTime)
          Constructs a new Phrase containing the specified note with the specified title.
Phrase(Note note, java.lang.String title)
          Constructs a new Phrase containing the specified note with the specified title.
Phrase(java.lang.String title)
          Creates an empty Phrase
Phrase(java.lang.String title, double startTime)
          Creates an empty Phrase.
Phrase(java.lang.String title, double startTime, int instrument)
          Creates an empty Phrase.
Phrase(java.lang.String title, double startTime, int instrument, boolean append)
          Creates an empty Phrase.
 
Method Summary
 void add(Note note)
          Add a note to this Phrase
 void addChord(int[] pitches, double rv)
          Adds Multiple notes to the phrase all of which start at the same time and share the same duration.
 void addNote(int pitch, double rv)
          Add a note to this Phrase
 void addNote(Note note)
          Add a note to this Phrase
 void addNoteList(double[] pitchAndRhythmArray)
          Adds Multiple notes to the phrase from one array of pitch, rhythm pairs
 void addNoteList(double[] freqArray, double rhythmValue)
          Adds Multiple notes to the phrase from an array of frequency values
 void addNoteList(double[] freqArray, double[] rhythmArray)
          Adds Multiple notes to the phrase from several arrays
 void addNoteList(double[] freqArray, double[] rhythmArray, int[] dynamic)
          Adds Multiple notes to the phrase from several arrays
 void addNoteList(double[] freqArray, double[] rhythmArray, int[] dynamic, boolean append)
          Adds Multiple notes to the phrase from several arrays A boolean option when true appends the notes to the end of the list if non true the current list is errased and replaced by the new notes
 void addNoteList(double frequency, double[] rhythms)
          Adds Multiple notes to the phrase from one pitch and an array of rhythm values
 void addNoteList(int[] pitchArray, double rhythmValue)
          Adds Multiple notes to the phrase from a pitch array and rhythm value
 void addNoteList(int[] pitchArray, double[] rhythmArray)
          Adds Multiple notes to the phrase from several arrays
 void addNoteList(int[] pitchArray, double[] rhythmArray, int[] dynamic)
          Adds Multiple notes to the phrase from several arrays
 void addNoteList(int[] pitchArray, double[] rhythmArray, int[] dynamic, boolean append)
          Adds Multiple notes to the phrase from several arrays A boolean option when true appends the notes to the end of the list if non true the current list is errased and replaced by the new notes
 void addNoteList(int[] pitchArray, double rhythmValue, int dynamic)
          Adds Multiple notes to the phrase from a pitch array, rhythm value, and dynmaic value
 void addNoteList(int pitch, double[] rhythms)
          Adds Multiple notes to the phrase from one pitch and an array of rhythm values
 void addNoteList(Note[] notes)
          Appends the specified notes to the end of this Phrase.
 void addNoteList(Note[] noteArray, boolean append)
          Adds an array of notes to the phrase.
 void addNoteList(java.util.Vector noteVector, boolean append)
          Adds a vector of notes to the phrase.
 void addRest(Rest newRest)
          Add a rest to this Phrase
 Phrase alias()
          Returns a carbon copy of a specified Phrase Changes to notes in the original or the alias will be echoed in the other.
 boolean attemptAnchoringTo(Phrase anchor, Alignment alignment, double offset)
          The positions tries the phrase relative to another using the alignment specified.
 Phrase copy()
          Returns a copy of the entire Phrase
 Phrase copy(double startLoc, double endLoc)
          Returns a copy of a specified section of the Phrase, pads beginning and end with shortedend notes and rests if notes or phrase boundaries don't align with locations.
 Phrase copy(double startLoc, double endLoc, boolean requireNoteStart)
          Returns a copy of a specified section of the Phrase, pads beginning and end with shortedend notes and rests if notes or phrase boundaries don't align with locations.
 Phrase copy(double startLoc, double endLoc, boolean trimmed, boolean truncated, boolean startTimeShifts)
          Returns a copy of a specified section of the Phrase, pads beginning and end with shortedend notes and rests if notes or phrase boundaries don't align with locations.
 Phrase copy(int highestPitch, int lowestPitch)
          Returns a copy of the entire Phrase only ontaining notes between highest and lowset specified pitch.
 Note createNote()
          Generates and returns a new note with default values and adds it to this phrase.
 void empty()
          Empty removes all elements in the note list vector
 Anchoring getAnchoring()
          Returns details of how this is aligned relative to another phrase.
 boolean getAppend()
          Return this phrases append status
 double getBeatLength()
          Return the Duration of the phrase in beats.
 int getDenominator()
          Returns the denominator of the Phrase's time signature
 int[] getDynamicArray()
           
 double getEndTime()
          Return the phrases endTime
 int getHighestPitch()
          Return the pitch value of the highest note in the phrase.
 int getInstrument()
          Return the program change assigned by this phrase
 Phrase getLinkedPhrase()
          Return this phrases this phrase is linked to
 double getLongestRhythmValue()
          Return the value of the longest rhythm value in the phrase.
 int getLowestPitch()
          Return the pitch value of the lowest note in the phrase.
 boolean getMute()
          Retrieve the current mute status.
 Part getMyPart()
          returns a reference to the part that contains this phrase
 Note getNote(int number)
          Get an individual note object by its number
 Note[] getNoteArray()
          Returns the all notes in the phrase as a array of notes
 java.util.Vector getNoteList()
          Returns the entire note list contained in a single voice
 double getNoteStartTime(int noteIndex)
          Calculate the start time, in beats, of the note at the specified index.
 int getNumerator()
          Returns the numerator of the Phrase's time signature
 double getPan()
          Return the pan position for this phrase
 int[] getPitchArray()
           
 double[] getRhythmArray()
           
 double getShortestRhythmValue()
          Return the value of the shortest rhythm value in the phrase.
 int getSize()
          Get the number of notes in this phrase
 double getStartTime()
          Return the phrase's startTime
 double getTempo()
          Return the tempo in beats per minute for this phrase
 java.lang.String getTitle()
          Return this phrases title
 int getVolume()
          Retreive the current volume setting for this phrase.
 int length()
          Get the number of notes in this phrase
 void removeLastNote()
          Deletes the last note in the phrase
 void removeNote(int noteNumb)
          Deletes the specified note in the phrase
 void removeNote(Note note)
          Deletes the first occurence of the specified note in the phrase
 void setAppend(boolean append)
          Gives the Phrase a new append status
 void setDenominator(int dem)
          Specifies the denominator of the Phrase's time signature
 void setDuration(double val)
          Change the Duration value of each note in the phrase.
 void setDynamic(int dyn)
          Change the dynamic value of each note in the phrase.
 void setInstrument(int value)
          Sets the program change value
 void setLength(double newLength)
          Change both the rhythmValue and duration of each note in the phrase.
 void setLinkedPhrase(Phrase link)
          Make a link from this phrase to another
 void setMute(boolean state)
          Specify the mute status of this phrase.
 void setMyPart(Part part)
          Sets a reference to the part containing this phrase
 void setNote(Note n, int index)
           
 void setNoteList(java.util.Vector newNoteList)
          Replaces the entire note list with a new note list vector
 void setNumerator(int num)
          Specifies the numerator of the Phrase's time signature
 void setPan(double pan)
          Determine the pan position for all notes in this phrase.
 void setPitch(int val)
          Change the pitch value of each note in the phrase.
 void setRhythmValue(double val)
          Change the rhythmValue value of each note in the phrase.
 void setStartTime(double startTime)
          Sets the phrases startTime
 void setTempo(double newTempo)
          Determine the tempo in beats per minute for this phrase
 void setTitle(java.lang.String title)
          Gives the Phrase a new title
 void setVolume(int val)
          Specify a new volume amount for this phrase.
 int size()
          Get the number of notes in this phrase
 java.lang.String toString()
          Prints the tracks attributes to stdout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_START_TIME

public static final double MIN_START_TIME
The smallest start time in beats

See Also:
Constant Field Values

DEFAULT_TITLE

public static final java.lang.String DEFAULT_TITLE
See Also:
Constant Field Values

DEFAULT_START_TIME

public static final double DEFAULT_START_TIME
See Also:
Constant Field Values

DEFAULT_INSTRUMENT

public static final int DEFAULT_INSTRUMENT
See Also:
Constant Field Values

DEFAULT_APPEND

public static final boolean DEFAULT_APPEND
See Also:
Constant Field Values

DEFAULT_TEMPO

public static final double DEFAULT_TEMPO
See Also:
Constant Field Values

DEFAULT_PAN

public static final double DEFAULT_PAN
See Also:
Constant Field Values

DEFAULT_NUMERATOR

public static final int DEFAULT_NUMERATOR
See Also:
Constant Field Values

DEFAULT_DENOMINATOR

public static final int DEFAULT_DENOMINATOR
See Also:
Constant Field Values

DEFAULT_VOLUME

public static final int DEFAULT_VOLUME
See Also:
Constant Field Values
Constructor Detail

Phrase

public Phrase()
Creates an empty Phrase. The default start time is a flag which means the phrase will be appended to the end of any part it is added to.


Phrase

public Phrase(double startTime)
Creates an empty Phrase starting at the specified beat.

Parameters:
startTime - The beat at which the phrase will be positioned in its part.

Phrase

public Phrase(double startTime,
              int instrument)
Creates an empty Phrase

Parameters:
startTime - The beat at which the phrase will be positioned in its part.
instrument - The sound or instrument number to be used for this phrase.

Phrase

public Phrase(java.lang.String title)
Creates an empty Phrase

Parameters:
title - The name for the phrase.

Phrase

public Phrase(java.lang.String title,
              double startTime)
Creates an empty Phrase.

Parameters:
title - The name for the phrase.
startTime - The beat at which the phrase will be positioned in its part.

Phrase

public Phrase(java.lang.String title,
              double startTime,
              int instrument)
Creates an empty Phrase.

Parameters:
title - The name for the phrase.
startTime - The beat at which the phrase will be positioned in its part.
instrument - The sound or instrument number to be used for this phrase.

Phrase

public Phrase(java.lang.String title,
              double startTime,
              int instrument,
              boolean append)
Creates an empty Phrase.

Parameters:
title - The name for the phrase.
startTime - The beat at which the phrase will be positioned in its part.
instrument - The sound or instrument number to be used for this phrase.
append - A flag specifying wheather or not this phrase should be added to the end of the part it is added too, or should use its start time value.

Phrase

public Phrase(Note note)
Constructs a new Phrase containing the specified note.

Parameters:
note - Note to be containing by the phrase.

Phrase

public Phrase(Note[] notes)
Constructs a new Phrase containing the specified notes.

Parameters:
notes - array of Note to be contained by the phrase.

Phrase

public Phrase(Note note,
              java.lang.String title)
Constructs a new Phrase containing the specified note with the specified title.

Parameters:
note - Note to be containing by the phrase.
title - String describing the title of the Phrase.

Phrase

public Phrase(Note[] notes,
              java.lang.String title)
Constructs a new Phrase containing the specified notes with the specified title.

Parameters:
notes - array of Note to be contained by the phrase.
title - String describing the title of the Phrase.

Phrase

public Phrase(Note note,
              double startTime)
Constructs a new Phrase containing the specified note with the specified title.

Parameters:
note - Note to be containing by the phrase.
title - String describing the title of the Phrase.
Method Detail

getInstrument

public int getInstrument()
Return the program change assigned by this phrase

Returns:
int

setInstrument

public void setInstrument(int value)
Sets the program change value

Parameters:
int - program change

addNote

public void addNote(Note note)
Add a note to this Phrase

Parameters:
Note - note - add a note to this phrase

addNote

public void addNote(int pitch,
                    double rv)
Add a note to this Phrase

Parameters:
pitch - -the pitch of the note
rv - - the rhythmValue of the note

add

public void add(Note note)
Add a note to this Phrase

Parameters:
Note - note - add a note to this phrase

addRest

public void addRest(Rest newRest)
Add a rest to this Phrase

Parameters:
Rest - rest - The rest to be added to this phrase

addNoteList

public void addNoteList(Note[] notes)
Appends the specified notes to the end of this Phrase.

Parameters:
array - of Notes to append.

addNoteList

public void addNoteList(java.util.Vector noteVector,
                        boolean append)
Adds a vector of notes to the phrase. A boolean option when true appends the notes to the end of the list, if false the notes in noteVector will replace the notes currently in the phrase.

Parameters:
noteVector - the vector of notes to add
append - do we append or not?

addNoteList

public void addNoteList(Note[] noteArray,
                        boolean append)
Adds an array of notes to the phrase. A boolean option when true appends the notes to the end of the list.

Parameters:
noteArray - the array of notes to add
append - do we append or not?

addNoteList

public void addNoteList(int[] pitchArray,
                        double rhythmValue)
Adds Multiple notes to the phrase from a pitch array and rhythm value

Parameters:
pitchArray - array of pitch values
rhythmValue - a rhythmic value

addNoteList

public void addNoteList(int[] pitchArray,
                        double rhythmValue,
                        int dynamic)
Adds Multiple notes to the phrase from a pitch array, rhythm value, and dynmaic value

Parameters:
pitchArray - - An array of pitch values
rhythmValue - - A rhythmic value
dynamic - - A dynmaic value (1-127)

addNoteList

public void addNoteList(double[] freqArray,
                        double rhythmValue)
Adds Multiple notes to the phrase from an array of frequency values

Parameters:
freqArray - array of freequency values
rhythmValue - a rhythmic value

addNoteList

public void addNoteList(int[] pitchArray,
                        double[] rhythmArray)
Adds Multiple notes to the phrase from several arrays

Parameters:
pitchArray - array of pitch values
rhythmArray - array of rhythmic values

addNoteList

public void addNoteList(double[] freqArray,
                        double[] rhythmArray)
Adds Multiple notes to the phrase from several arrays

Parameters:
freqArray - array of frequency values
rhythmArray - array of rhythmic values

addNoteList

public void addNoteList(int[] pitchArray,
                        double[] rhythmArray,
                        int[] dynamic)
Adds Multiple notes to the phrase from several arrays

Parameters:
pitchArray - array of pitch values
rhythmArray - array of rhythmic values
dynmaic - array of dynamic values

addNoteList

public void addNoteList(double[] freqArray,
                        double[] rhythmArray,
                        int[] dynamic)
Adds Multiple notes to the phrase from several arrays

Parameters:
freqArray - array of frequency values
rhythmArray - array of rhythmic values
dynmaic - array of dynamic values

addNoteList

public void addNoteList(int[] pitchArray,
                        double[] rhythmArray,
                        int[] dynamic,
                        boolean append)
Adds Multiple notes to the phrase from several arrays A boolean option when true appends the notes to the end of the list if non true the current list is errased and replaced by the new notes

Parameters:
pitchArray - array of pitch values
rhythmArray - array of rhythmic values
dynamic - int
append - do we append or not?

addNoteList

public void addNoteList(double[] freqArray,
                        double[] rhythmArray,
                        int[] dynamic,
                        boolean append)
Adds Multiple notes to the phrase from several arrays A boolean option when true appends the notes to the end of the list if non true the current list is errased and replaced by the new notes

Parameters:
freqArray - array of frequency values
rhythmArray - array of rhythmic values
dynamic - int
append - do we append or not?

addNoteList

public void addNoteList(double[] pitchAndRhythmArray)
Adds Multiple notes to the phrase from one array of pitch, rhythm pairs

Parameters:
pitchAndRhythmArray - - an array of pitch and rhythm values

addNoteList

public void addNoteList(int pitch,
                        double[] rhythms)
Adds Multiple notes to the phrase from one pitch and an array of rhythm values

Parameters:
pitch - The pitch values for the notes
rhythms - An array of rhythm values

addNoteList

public void addNoteList(double frequency,
                        double[] rhythms)
Adds Multiple notes to the phrase from one pitch and an array of rhythm values

Parameters:
frequency - The pitch values for the notes in hertz
rhythms - An array of rhythm values

addChord

public void addChord(int[] pitches,
                     double rv)
Adds Multiple notes to the phrase all of which start at the same time and share the same duration.

Parameters:
pitches - An array of pitch values
rv - the rhythmValue

getPitchArray

public int[] getPitchArray()

getRhythmArray

public double[] getRhythmArray()

getDynamicArray

public int[] getDynamicArray()

removeNote

public void removeNote(int noteNumb)
Deletes the specified note in the phrase

Parameters:
int - noteNumb the index of the note to be deleted

removeNote

public void removeNote(Note note)
Deletes the first occurence of the specified note in the phrase

Parameters:
note - the note object to be deleted.

removeLastNote

public void removeLastNote()
Deletes the last note in the phrase


getNoteList

public java.util.Vector getNoteList()
Returns the entire note list contained in a single voice

Returns:
Vector A vector containing all Note objects in this phrase

setNoteList

public void setNoteList(java.util.Vector newNoteList)
Replaces the entire note list with a new note list vector

Parameters:
Vector - of notes

getNoteArray

public Note[] getNoteArray()
Returns the all notes in the phrase as a array of notes

Returns:
Note[] An array containing all Note objects in this phrase

getStartTime

public double getStartTime()
Return the phrase's startTime

Returns:
double The phrases startTime in beats from the beginning of the part or score.

setStartTime

public void setStartTime(double startTime)
Sets the phrases startTime

This positions the phrase absolutely. If this phrase is currently positioned relative to another phrase that anchoring will be lost.

To position this relative to another class use the anchor method instead.

Parameters:
double - the time at which to start the phrase

attemptAnchoringTo

public boolean attemptAnchoringTo(Phrase anchor,
                                  Alignment alignment,
                                  double offset)

The positions tries the phrase relative to another using the alignment specified. If the arrangement causes this class to start before a start time of 0.0, the repositioning is considered invalid and will fail. The original positioning will be restored and this method will return false. If successful, the previous positioning whether absolute or relative will be lost.

To position this absolutely use the setStartTime method instead.

Parameters:
anchor - the phrase against which this should be positioned
alignment - how this should be positioned relative to anchor

getAnchoring

public Anchoring getAnchoring()
Returns details of how this is aligned relative to another phrase. Alternatively, if this phrase is aligned absolutely returns null.


getEndTime

public double getEndTime()
Return the phrases endTime

Returns:
double the phrases endTime

getTitle

public java.lang.String getTitle()
Return this phrases title

Returns:
String the phrases title

setTitle

public void setTitle(java.lang.String title)
Gives the Phrase a new title

Parameters:
phrases - title

getAppend

public boolean getAppend()
Return this phrases append status

Returns:
boolean the phrases append value

setAppend

public void setAppend(boolean append)
Gives the Phrase a new append status

Parameters:
boolean - the append status

getLinkedPhrase

public Phrase getLinkedPhrase()
Return this phrases this phrase is linked to

Returns:
Phrase the phrases linked to

setLinkedPhrase

public void setLinkedPhrase(Phrase link)
Make a link from this phrase to another

Parameters:
Phrase - the phrase to link to

getPan

public double getPan()
Return the pan position for this phrase

Returns:
double the phrases pan setting

setPan

public void setPan(double pan)
Determine the pan position for all notes in this phrase.

Parameters:
double - the phrase's pan setting

getTempo

public double getTempo()
Return the tempo in beats per minute for this phrase

Returns:
double the phrase's tempo setting

setTempo

public void setTempo(double newTempo)
Determine the tempo in beats per minute for this phrase

Parameters:
double - the phrase's tempo

getNote

public Note getNote(int number)
Get an individual note object by its number

Parameters:
int - number - the number of the Track to return
Returns:
Note answer - the note object to return

length

public int length()
Get the number of notes in this phrase

Returns:
int The number of notes

size

public int size()
Get the number of notes in this phrase

Returns:
int length - the number of notes

getSize

public int getSize()
Get the number of notes in this phrase

Returns:
int length - the number of notes

getNumerator

public int getNumerator()
Returns the numerator of the Phrase's time signature

Returns:
int time signature numerator

setNumerator

public void setNumerator(int num)
Specifies the numerator of the Phrase's time signature

Parameters:
int - time signature numerator

getDenominator

public int getDenominator()
Returns the denominator of the Phrase's time signature

Returns:
int time signature denominator

setDenominator

public void setDenominator(int dem)
Specifies the denominator of the Phrase's time signature

Parameters:
int - time signature denominator

setMyPart

public void setMyPart(Part part)
Sets a reference to the part containing this phrase


getMyPart

public Part getMyPart()
returns a reference to the part that contains this phrase


copy

public Phrase copy()
Returns a copy of the entire Phrase

Returns:
Phrase a copy of the Phrase

copy

public Phrase copy(double startLoc,
                   double endLoc)
Returns a copy of a specified section of the Phrase, pads beginning and end with shortedend notes and rests if notes or phrase boundaries don't align with locations.

Parameters:
double - start location
double - end location
Returns:
Phrase a copy of the Phrase

copy

public Phrase copy(double startLoc,
                   double endLoc,
                   boolean requireNoteStart)
Returns a copy of a specified section of the Phrase, pads beginning and end with shortedend notes and rests if notes or phrase boundaries don't align with locations.

Parameters:
double - start location
double - end location
boolean - requireNoteStart If true, only notes that start inside the copy range are included in the copy. Notes starting prior but overlapping are replaced by rests. Otherwise sections of notes inseide the bounds are included.
Returns:
Phrase a copy of the Phrase

copy

public Phrase copy(double startLoc,
                   double endLoc,
                   boolean trimmed,
                   boolean truncated,
                   boolean startTimeShifts)
Returns a copy of a specified section of the Phrase, pads beginning and end with shortedend notes and rests if notes or phrase boundaries don't align with locations.

Parameters:
boolean - trimmed wether to truncte notes (as per the other versions of copy) or not
boolean - startTimeShifts wether to shift the start time or to add a rest if if the start is afte startloc
double - start location
double - end location
Returns:
Phrase a copy of the Phrase

copy

public Phrase copy(int highestPitch,
                   int lowestPitch)
Returns a copy of the entire Phrase only ontaining notes between highest and lowset specified pitch.

Returns:
Phrase a partical copy of the Phrase

toString

public java.lang.String toString()
Prints the tracks attributes to stdout

Overrides:
toString in class java.lang.Object

empty

public void empty()
Empty removes all elements in the note list vector


alias

public Phrase alias()
Returns a carbon copy of a specified Phrase Changes to notes in the original or the alias will be echoed in the other. Note: that for this to work other phrase classes must to change the noteList attribute to point to another object, but instead should always update the noteList itself. See shuffle() as an example.


getHighestPitch

public int getHighestPitch()
Return the pitch value of the highest note in the phrase.


getLowestPitch

public int getLowestPitch()
Return the pitch value of the lowest note in the phrase.


getLongestRhythmValue

public double getLongestRhythmValue()
Return the value of the longest rhythm value in the phrase.


getShortestRhythmValue

public double getShortestRhythmValue()
Return the value of the shortest rhythm value in the phrase.


setDynamic

public void setDynamic(int dyn)
Change the dynamic value of each note in the phrase.


setPitch

public void setPitch(int val)
Change the pitch value of each note in the phrase.


setRhythmValue

public void setRhythmValue(double val)
Change the rhythmValue value of each note in the phrase.


setDuration

public void setDuration(double val)
Change the Duration value of each note in the phrase.


getBeatLength

public double getBeatLength()
Return the Duration of the phrase in beats.


createNote

public Note createNote()
Generates and returns a new note with default values and adds it to this phrase.


setVolume

public void setVolume(int val)
Specify a new volume amount for this phrase.


getVolume

public int getVolume()
Retreive the current volume setting for this phrase.


setNote

public void setNote(Note n,
                    int index)

setMute

public void setMute(boolean state)
Specify the mute status of this phrase.

Parameters:
state - True or False, muted or not.

getMute

public boolean getMute()
Retrieve the current mute status.

Returns:
boolean True or False, muted ot not.

setLength

public void setLength(double newLength)
Change both the rhythmValue and duration of each note in the phrase.

Parameters:
newLength - The new rhythmValue for the note (Duration is a proportion of this value)

getNoteStartTime

public double getNoteStartTime(int noteIndex)
Calculate the start time, in beats, of the note at the specified index.

Parameters:
noteIndex - The note's position in the phrase.
Returns:
double The absolute (taking into account phrase start time) beat position where the note starts. -1 is returned when an index out of range is encounterd.