public final class PhraseAnalysis
extends java.lang.Object
Phrase
or
Note
array. For each statistic there are two methods, accepting
either a Phrase or a Note array as a parameter.
This class also provides the constants used when generating those statistics.
The methods are grouped under the following categories:
getAllStatistics
is the only bulk statistic;
it returns all the feature statistics.The bulk statistics include:
The feature statistics include:
noteDensity(jm.music.data.Phrase, double)
pitchVariety(jm.music.data.Phrase)
rhythmicVariety(jm.music.data.Phrase)
climaxStrength(jm.music.data.Phrase)
restDensity(jm.music.data.Phrase, double)
tonalDeviation(jm.music.data.Phrase, double, int, int[])
keyCenteredness(jm.music.data.Phrase, double, int)
pitchRangePerSpan(jm.music.data.Phrase)
rhythmRangePerSpan(jm.music.data.Phrase)
repeatedPitchDensity(jm.music.data.Phrase)
repeatedRhythmicValueDensity(jm.music.data.Phrase)
melodicDirectionStability(jm.music.data.Phrase)
overallPitchDirection(jm.music.data.Phrase)
movementByStep(jm.music.data.Phrase, int, int[])
dissonance(jm.music.data.Phrase)
leapCompensation(jm.music.data.Phrase)
syncopation(jm.music.data.Phrase)
repeatedPitchPatterns(jm.music.data.Phrase, int)
repeatedRhythmPatterns(jm.music.data.Phrase, int)
climaxPosition(jm.music.data.Phrase)
climaxTonality(jm.music.data.Phrase, int, int[])
The accessory statistics include:
For clarification, here are definitions of terms used in the method descriptions.
Modifier and Type | Field and Description |
---|---|
static int |
BIG_JUMP_INTERVAL
Integer defining the smallest interval, measured in semitones, that
constitutes a 'big jump'.
|
static int |
FEATURE_COUNT
Integer constant describing the number of statistical features returned
by the
getAllStatistics methods. |
static java.lang.String[] |
featureNames
Array of Strings giving the identifier number and descriptive name
of each feature as returned by the
getAllStatistics methods. |
static int |
INTERVAL_WITH_REST
Used by the
pitchIntervals(jm.music.data.Phrase) method to indicate an interval with
one or more rests between its notes. |
static int[] |
MAJOR_SCALE
Integer array containing the pitches representing a major scale.
|
static int |
MAX_DISTINCT_RHYTHMS
Integer defining the maximum number of distinct rhythm values that can
appear in the melody.
|
static int |
MAX_PITCH_RANGE
Integer constant describing the maximum pitch range that a reasonable
melody can span, measured in semitones.
|
static double |
MAX_RHYTHM_RANGE
Double constant describing the maximum rhythm range that a reasonable
could utilise.
|
static int[] |
MINOR_SCALE
Integer array containing the pitches representing a minor scale.
|
static double |
NOTELIST_EXCEPTION_CONSTANT |
static java.lang.String |
NOTELIST_EXCEPTION_STRING |
static int[] |
PRIMARY_NOTES
Integer array containing the pitches that represent primary pitches.
|
static double |
QUANTISATION_EXCEPTION_CONSTANT |
static java.lang.String |
QUANTISATION_EXCEPTION_STRING |
Modifier and Type | Method and Description |
---|---|
static int |
bigJumpCount(Note[] noteArray)
Returns the number of big jumps in the specified Note array.
|
static int |
bigJumpCount(Phrase phrase)
Returns the number of big jumps in the specified Phrase.
|
static int |
bigJumpFollowedByStepBackCount(Note[] noteArray)
Returns the number of big jumps followed by a step back in the specified
Note array.
|
static int |
bigJumpFollowedByStepBackCount(Phrase phrase)
Returns the number of big jumps followed by a step back in the specified
Phrase.
|
static double |
climaxPosition(Note[] noteArray)
Returns a double representing where the climax of the melody starts.
|
static double |
climaxPosition(Phrase phrase)
Returns a double representing where the climax of the melody starts.
|
static double |
climaxStrength(Note[] noteArray)
Returns a double expressing the inverse of the count of the number of
notes sharing the highest pitch in the specified Note array.
|
static double |
climaxStrength(Phrase phrase)
Returns a double expressing the inverse of the count of the number of
notes sharing the highest pitch in the specified Phrase.
|
static double |
climaxTonality(Note[] noteArray,
int tonic,
int[] scale)
Returns a double rating the tonality of the specified Note array.
|
static double |
climaxTonality(Phrase phrase,
int tonic,
int[] scale)
Returns a double rating the tonality of the specified Phrase.
|
static int |
consecutiveIdenticalPitches(Note[] noteArray)
Returns the count of intervals whose size is 0 semitones in the specified
Note array.
|
static int |
consecutiveIdenticalPitches(Phrase phrase)
Returns the count of intervals whose size is 0 semitones in the specified
Phrase.
|
static int |
consecutiveIdenticalRhythms(Note[] noteArray)
Returns the count of intervals between notes of the same rhythm value in
the specified Note array.
|
static int |
consecutiveIdenticalRhythms(Phrase phrase)
Returns the count of intervals between Notes of the same rhythm value in
the specified Phrase.
|
static double |
dissonance(Note[] noteArray)
Returns a double expressing the average dissonance rating of all
intervals in the specified Note array.
|
static double |
dissonance(Phrase phrase)
Returns a double expressing the average dissonance rating of all
intervals in the specified Phrase.
|
static int |
distinctPitchCount(Note[] noteArray)
Returns the number of pitches that appear at least once in a specified
Note array. |
static int |
distinctPitchCount(Phrase phrase)
Returns the number of pitches that appear at least once in a specified
Phrase . |
static int |
distinctRhythmCount(Note[] noteArray)
Returns the number of rhythms that appear at least once in a specified
Note array. |
static int |
distinctRhythmCount(Phrase phrase)
Returns the number of rhythms that appear at least once in a specified
Phrase . |
static java.util.Hashtable |
getAllStatistics(Note[] noteList,
double duration,
int tonic,
int[] scale)
Returns a
Hashtable containing all the feature statistics. |
static java.util.Hashtable |
getAllStatistics(Phrase phrase,
double duration,
int tonic,
int[] scale)
Returns a
Hashtable containing all the feature statistics. |
static double[] |
getAllStatisticsAsDoubles(Note[] noteArray,
double duration,
int tonic,
int[] scale) |
static double[] |
getAllStatisticsAsDoubles(Phrase phrase,
double duration,
int tonic,
int[] scale) |
static java.lang.String[] |
getAllStatisticsAsStrings(Note[] noteArray,
double duration,
int tonic,
int[] scale) |
static java.lang.String[] |
getAllStatisticsAsStrings(Phrase phrase,
double duration,
int tonic,
int[] scale) |
static int |
intervalCount(Note[] noteArray)
Returns a count of the number of note to next note
intervals in the specified Phrase.
|
static int |
intervalCount(Phrase phrase)
Returns a count of the number of note to next note
intervals in the specified Phrase.
|
static int |
intervalSemitoneCount(Note[] noteArray)
Returns the sum of the absolute sizes of all intervals in the specified
Note array.
|
static int |
intervalSemitoneCount(Phrase phrase)
Returns the sum of the absolute sizes of all intervals in the specified
Phrase.
|
static boolean |
isQuantised(Note[] noteArray,
double duration)
Tests an array of
Notes to see if they are quantised. |
static boolean |
isQuantised(Phrase phrase,
double duration)
Tests whether a
Phrase is quantised. |
static boolean |
isScale(Note note,
int tonic,
int[] scale) |
static double |
keyCenteredness(Note[] noteArray,
double duration,
int tonic)
Returns a double expressing the total duration of all primary notes,
over the length of the melody.
|
static double |
keyCenteredness(Phrase phrase,
double duration,
int tonic)
Returns a double expressing the total duration of all primary notes,
over the length of the melody.
|
static double |
leapCompensation(Note[] noteArray)
Returns a double expressing the ratio of 'large leaps' that are not
followed by an interval in the opposite direction that is no greater than
the leap in the specified Note array.
|
static double |
leapCompensation(Phrase phrase)
Returns a double expressing the ratio of 'large leaps' that are not
followed by an interval in the opposite direction that is no greater than
the leap in the specified Phrase.
|
static double |
melodicDirectionStability(Note[] noteArray)
Returns a double expressing the ratio between the number of consecutive
pitch steps in the same direction and the total number of steps in the
specified Note array.
|
static double |
melodicDirectionStability(Phrase phrase)
Returns a double expressing the ratio between the number of consecutive
pitch steps in the same direction and the total number of steps in the
specified Phrase.
|
static double |
movementByStep(Note[] noteArray,
int tonic,
int[] scale)
Returns a double expressing the ratio between the number of pitch
movements by diatonic step over the total number of steps in the
specified Note array.
|
static double |
movementByStep(Phrase phrase,
int tonic,
int[] scale)
Returns a double expressing the ratio between the number of pitch
movements by diatonic step over the total number of steps in the
specified Phrase.
|
static int |
nonScaleQuantumCount(Note[] noteArray,
double duration,
int tonic,
int[] scale)
Returns the count of the quanta taken up by
non-scale notes in the specified Note array.
|
static int |
nonScaleQuantumCount(Phrase phrase,
double duration,
int tonic,
int[] scale)
Returns the count of the quanta taken up by
non-scale notes in the specified Phrase.
|
static int |
noteCount(Note[] noteArray)
|
static int |
noteCount(Phrase phrase)
|
static double |
noteDensity(Note[] noteArray,
double duration)
|
static double |
noteDensity(Phrase phrase,
double duration)
|
static double |
overallPitchDirection(Note[] noteArray)
Returns a double expressing the ratio between the sum of rising intervals
over the sum of all intervals in the specified Note array.
|
static double |
overallPitchDirection(Phrase phrase)
Returns a double expressing the ratio between the sum of rising intervals
over the sum of all intervals in the specified Phrase.
|
static int[] |
pitchIntervals(Note[] noteArray)
|
static int[] |
pitchIntervals(Phrase phrase)
|
static int |
pitchPatternCount(Note[] noteArray,
int chunkSize)
Returns the number of 'pitch interval' patterns of size
chunksize in the specified Note array. |
static int |
pitchPatternCount(Phrase phrase,
int chunkSize)
Returns the number of 'pitch interval' patterns of size
chunksize in the specified Phrase. |
static int |
pitchRange(Note[] noteArray)
Returns the difference between the highest and lowest pitches in the
specified
Note array. |
static int |
pitchRange(Phrase phrase)
Returns the difference between the highest and lowest pitches in the
specified
Phrase . |
static double |
pitchRangePerSpan(Note[] noteArray)
Returns a double expressing the ratio between the pitch range of the
specified Note array and
MAX_PITCH_RANGE . |
static double |
pitchRangePerSpan(Phrase phrase)
Returns a double expressing the ratio between the pitch range of the
specified phrase and
MAX_PITCH_RANGE . |
static int |
pitchToDegree(int pitch,
int tonic) |
static double |
pitchVariety(Note[] noteArray)
Returns a double expressing the ratio between the number of distinct
pitches and the total number of notes in the specified
Note
array. |
static double |
pitchVariety(Phrase phrase)
Returns a double expressing the number of distinct pitches per note in
the
Phrase . |
static int |
primaryQuantumCount(Note[] noteArray,
double duration,
int tonic)
Returns the count of the quanta taken up by
'primary notes' in the specified Note array.
|
static int |
primaryQuantumCount(Phrase phrase,
double duration,
int tonic)
Returns the count of the quanta taken up by
'primary notes' in the specified Phrase.
|
static int |
quantumCount(Note[] noteArray,
double duration)
|
static int |
quantumCount(Phrase phrase,
double duration)
|
static int |
removeRestMarker(int interval)
Removes the rest marker, if any, from integer which conform to the values
returned by
pitchIntervals(jm.music.data.Phrase) . |
static double |
repeatedPitchDensity(Note[] noteArray)
Returns a double expressing the ratio between the count of consecutive
notes of the same pitch and the count of all note to next note intervals
in the specified Note array.
|
static double |
repeatedPitchDensity(Phrase phrase)
Returns a double expressing the ratio between the count of consecutive
notes of the same pitch and the count of all note to next note intervals
in the specified Phrase.
|
static double |
repeatedPitchPatterns(Note[] noteArray,
int chunkSize)
Returns a double expressing the number of repetitions of pitch interval
patterns of a specified size, compared to the total possible number of
patterns in the specified Note array.
|
static double |
repeatedPitchPatterns(Phrase phrase,
int chunkSize)
Returns a double expressing the number of repetitions of pitch interval
patterns of a specified size, compared to the total possible number of
patterns in the specified Phrase.
|
static double |
repeatedRhythmicValueDensity(Note[] noteArray)
Returns a double expressing the ratio between the count of consecutive
notes of the same rhythm value and the count of all note to next note
intervals in the specified Note array.
|
static double |
repeatedRhythmicValueDensity(Phrase phrase)
Returns a double expressing the ratio between the count of consecutive
notes of the same rhythm value and the count of all note to next note
intervals in the specified Phrase.
|
static double |
repeatedRhythmPatterns(Note[] noteArray,
int chunkSize)
Returns a double expressing the number of repetitions of rhythm interval
patterns of a specified size, compared to the total possible number of
patterns in the specified Note array.
|
static double |
repeatedRhythmPatterns(Phrase phrase,
int chunkSize)
Returns a double expressing the number of repetitions of rhythm interval
patterns of a specified size, compared to the total possible number of
patterns in the specified Phrase.
|
static double |
restDensity(Note[] noteArray,
double duration)
Returns a double expressing the ratio between the number of rest
quanta and the number of quanta in a Note array.
|
static double |
restDensity(Phrase phrase,
double duration)
Returns a double expressing the ratio between the number of rest
quanta and the number of quanta in a Phrase.
|
static int |
restQuantumCount(Note[] noteArray,
double duration)
|
static int |
restQuantumCount(Phrase phrase,
double duration)
|
static double |
rhythmicVariety(Note[] noteArray)
Returns a double expressing the ratio between the number of distinct
rhythms and the total number of notes in the specified
Note
array. |
static double |
rhythmicVariety(Phrase phrase)
Returns a double expressing the number of distinct rhythm Values used
over the maximum possible rhythmic values.
|
static double[] |
rhythmIntervals(Note[] noteArray)
Returns an array of doubles describing the change in rhythm value in
intervals in the specified
Note array. |
static double[] |
rhythmIntervals(Phrase phrase)
Returns an array of doubles describing the change in rhythm value in
intervals in the specified
Phrase . |
static int |
rhythmPatternCount(Note[] noteArray,
int chunkSize)
Returns the number of 'rhythm interval' patterns of size
chunksize in the specified Note array. |
static int |
rhythmPatternCount(Phrase phrase,
int chunksize)
Returns the number of 'rhythm interval' patterns of size
chunksize in the specified Phrase. |
static double |
rhythmRange(Note[] noteArray)
Returns the value of the longest rhythm value, divided by the shortest
in the specified Note array.
|
static double |
rhythmRange(Phrase phrase)
Returns the value of the longest rhythm value, divided by the shortest
in the specified Phrase.
|
static double |
rhythmRangePerSpan(Note[] noteArray)
Returns a double expressing the ratio between the rhythm range of the
specified Note array and
MAX_RHYTHM_RANGE . |
static double |
rhythmRangePerSpan(Phrase phrase)
Returns a double expressing the ratio between the rhythm range of the
specified phrase and
MAX_RHYTHM_RANGE . |
static double |
rhythmValueCount(Note[] noteArray)
Returns the sum of all rhythm values in the specified Note array.
|
static double |
rhythmValueCount(Phrase phrase)
Returns the sum of all rhythm values in the specified Phrase.
|
static int |
risingSemitoneCount(Note[] noteArray)
Returns the sum of the sizes of all rising intervals in the specified
Note array.
|
static int |
risingSemitoneCount(Phrase phrase)
Returns the sum of the sizes of all rising intervals in the specified
Phrase.
|
static int |
sameDirectionIntervalCount(Note[] noteArray)
Returns the count of consecutive intevals in the same direction, in the
specified Note array.
|
static int |
sameDirectionIntervalCount(Phrase phrase)
Returns the count of consecutive intevals in the same direction, in the
specified Phrase.
|
static int |
stepIntervalCount(Note[] noteArray,
int tonic,
int[] scale)
Returns a count of all the step intervals in the specified Note array.
|
static int |
stepIntervalCount(Phrase phrase,
int tonic,
int[] scale)
Returns a count of all the step intervals in the specified Phrase.
|
static double |
syncopation(Note[] noteArray)
Returns a double expressing the ratio of the number of
notes which start off the beat and have a rhythm value of a beat of
more, compared to the total number of beats less one in the specified
Note array.
|
static double |
syncopation(Phrase phrase)
Returns a double expressing the ratio of the number of
notes which start on the beat and have a rhythm value of a beat of
more, compared to the total number of beats in the specified Phrase.
|
static double |
tonalDeviation(Note[] noteArray,
double duration,
int tonic,
int[] scale)
Returns a double expressing the total duration of all non-scale notes,
over the length of the melody.
|
static double |
tonalDeviation(Phrase phrase,
double duration,
int tonic,
int[] scale)
Returns a double expressing the total duration of all non-scale notes,
over the length of the melody.
|
public static final java.lang.String[] featureNames
getAllStatistics
methods.public static final java.lang.String NOTELIST_EXCEPTION_STRING
public static final java.lang.String QUANTISATION_EXCEPTION_STRING
public static final double NOTELIST_EXCEPTION_CONSTANT
public static final double QUANTISATION_EXCEPTION_CONSTANT
public static final int FEATURE_COUNT
getAllStatistics
methods.public static final int MAX_PITCH_RANGE
Within this class, this constant is only used by the pitchRangePerSpan
method.
As such, this constant provides little benefit except to
implementations that use the pitchRangePerSpan
method.
public static final double MAX_RHYTHM_RANGE
Within this class, this constant is only used by the rhythmRangePerSpan
method.
As such, this constant provides little benefit except to
implementations that use the rhythmRangePerSpan
method.
public static final int[] MAJOR_SCALE
Many methods of this class require a scale of this form as parameters.
It is suggested that either this constant or the MINOR_SCALE
constant be passed to these methods, depending on the key of the melody
to be analysed.
public static final int[] MINOR_SCALE
Many methods of this class require a scale of this form as parameters.
It is suggested that either this constant or the MAJOR_SCALE
constant be passed to these methods, depending on the key of the melody
to be analysed.
public static final int[] PRIMARY_NOTES
This constant is used by the primaryQuantumCount
and climaxTonality
methods.
public static final int BIG_JUMP_INTERVAL
leapCompensation
,
bigJumpFollowedByStepBackCount
,
and bigJumpCount
methods.public static final int MAX_DISTINCT_RHYTHMS
rhythmicVariety
method.public static final int INTERVAL_WITH_REST
pitchIntervals(jm.music.data.Phrase)
method to indicate an interval with
one or more rests between its notes. That method
indicates a interval with a rest by adding this constant to the size
of the interval.
This constant is guaranteed to be large enough not to cause any conflicts
between the value for extremely large rising intervals without rests, and
extremely large lowering intervals with rests.public static java.lang.String[] getAllStatisticsAsStrings(Phrase phrase, double duration, int tonic, int[] scale)
public static java.lang.String[] getAllStatisticsAsStrings(Note[] noteArray, double duration, int tonic, int[] scale)
public static double[] getAllStatisticsAsDoubles(Phrase phrase, double duration, int tonic, int[] scale)
public static double[] getAllStatisticsAsDoubles(Note[] noteArray, double duration, int tonic, int[] scale)
public static java.util.Hashtable getAllStatistics(Phrase phrase, double duration, int tonic, int[] scale)
Hashtable
containing all the feature statistics.
The keys of the hashtable contain a String describing the feature along with a numeric identification code for that feature.
The values are Strings representing the value returned by that feature: either the double returned, or a description of the exception thrown.
phrase
- the Phrase to be analysedduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.tonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).scale
- array of integers describing the scale notes in the key
of the melody. If the key is major use the MAJOR_SCALE
constant of this class; if harmonic minor
use MINOR_SCALE
. Arrays representing other
keys can also be created but they must fit the criteria
outlined in the descriptions of those constants.public static java.util.Hashtable getAllStatistics(Note[] noteList, double duration, int tonic, int[] scale)
Hashtable
containing all the feature statistics.
The keys of the hashtable contain a String describing the feature along with a numeric identification code for that feature.
The values are Strings representing the value returned by that feature: either the double returned, or a description of the exception thrown.
noteList
- the Note array to be analysedduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.tonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).scale
- array of integers describing the scale notes in the key
of the melody. If the key is major use the MAJOR_SCALE
constant of this class; if harmonic minor
use MINOR_SCALE
. Arrays representing other
keys can also be created but they must fit the criteria
outlined in the descriptions of those constants.public static double noteDensity(Phrase phrase, double duration) throws NoteListException, QuantisationException
Phrase
. The number of notes
exludes rests.phrase
- Phrase whose notes are to be countedduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.NoteListException
- if the number of quantum in the Phrase is zeroQuantisationException
- if the notes' rhythm values are not multiples of quantum
duration, or if quantum duration is less than or equal
to zeropublic static double noteDensity(Note[] noteArray, double duration) throws NoteListException, QuantisationException
Note
array. The number of notes
exludes rests.noteArray
- array of Notes to be examinedduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.NoteListException
- if the number of quantum in the Note array is zeroQuantisationException
- if the notes' rhythm values are not multiples of quantum
duration, or if quantum duration is less than or equal
to zeropublic static double pitchVariety(Phrase phrase) throws NoteListException
Phrase
.phrase
- Phrase whose pitches are to be countedNoteListException
- if there are no notes in the Phrasepublic static double pitchVariety(Note[] noteArray) throws NoteListException
Note
array.noteArray
- array of Notes to be examinedNoteListException
- if there are no notes in the Note
arraypublic static double rhythmicVariety(Phrase phrase)
MAX_DISTINCT_RHYTHMS
.phrase
- Phrase to be examinedpublic static double rhythmicVariety(Note[] noteArray)
Note
array.noteArray
- array of Note objects to be examinedpublic static double climaxStrength(Phrase phrase) throws NoteListException
Phrase
- Phrase to be examinedNoteListException
- if there are no notes in the Phrasepublic static double climaxStrength(Note[] noteArray) throws NoteListException
noteArray
- Note array to be examinedNoteListException
- if there are no notes in the Note
arraypublic static double restDensity(Phrase phrase, double duration) throws NoteListException, QuantisationException
phrase
- Phrase to be examinedduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.NoteListException
- if the length of the Phrase is zeroQuantisationException
- if the notes' rhythm values are not multiples of quantum
duration, or if quantum duration is less than or equal
to zeropublic static double restDensity(Note[] noteArray, double duration) throws NoteListException, QuantisationException
noteArray
- array of Note objects to be examinedduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.NoteListException
- if the length of the melody is zeroQuantisationException
- if the notes' rhythm values are not multiples of quantum
duration, or if quantum duration is less than or equal
to zeropublic static double tonalDeviation(Phrase phrase, double duration, int tonic, int[] scale) throws NoteListException, QuantisationException
phrase
- Phrase to be examinedduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.tonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).scale
- array of integers describing the scale notes in the key
of the melody. If the key is major use the MAJOR_SCALE
constant of this class; if harmonic minor
use MINOR_SCALE
. Arrays representing other
keys can also be created but they must fit the criteria
outlined in the descriptions of those constants.NoteListException
- if the number of quanta in the Phrase is zeroQuantisationException
- if the notes' rhythm values are not multiples of quantum
duration, or if quantum duration is less than or equal
to zeropublic static double tonalDeviation(Note[] noteArray, double duration, int tonic, int[] scale) throws NoteListException, QuantisationException
noteArray
- array of Note objects to be examinedduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.tonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).scale
- array of integers describing the scale notes in the key
of the melody. If the key is major use the MAJOR_SCALE
constant of this class; if harmonic minor
use MINOR_SCALE
. Arrays representing other
keys can also be created but they must fit the criteria
outlined in the descriptions of those constants.NoteListException
- if the number of quanta in the Phrase is zeroQuantisationException
- if the notes' rhythm values are not multiples of quantum
duration, or if quantum duration is less than or equal
to zeropublic static double keyCenteredness(Phrase phrase, double duration, int tonic) throws QuantisationException, NoteListException
phrase
- Phrase to be analysedduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.tonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).NoteListException
- if the number of quanta in the Phrase is zeroQuantisationException
- if the notes' rhythm values are not multiples of quantum
duration, or if quantum duration is less than or equal
to zeropublic static double keyCenteredness(Note[] noteArray, double duration, int tonic) throws QuantisationException, NoteListException
noteArray
- array of Notes to be analysedduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.tonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).NoteListException
- if the number of quanta in the Phrase is zeroQuantisationException
- if the notes' rhythm values are not multiples of quantum
duration, or if quantum duration is less than or equal
to zeropublic static double pitchRangePerSpan(Phrase phrase) throws NoteListException
MAX_PITCH_RANGE
. If the range of the melody
is larger than this constant, this method will return 1 instead.
MAX_PITCH_RANGE
is an arbitrary value that was useful for
the developers of this method. If this arbitrary constant means nothing
to your implementation consider using the pitchRange
method instead.
phrase
- Phrase to be analysedMAX_PITCH_RANGE
NoteListException
- if there are no notes in the Phrasepublic static double pitchRangePerSpan(Note[] noteArray) throws NoteListException
MAX_PITCH_RANGE
. If the range of the
melody is larger than this constant, this method will return 1 instead.
MAX_PITCH_RANGE
is an arbitrary value that was useful for
the developers of this method. If this arbitrary constant means nothing
to your implementation consider using the pitchRange
method instead.
noteArray
- Note array to be analysedMAX_PITCH_RANGE
NoteListException
- if there are no notes in the Note
arraypublic static double rhythmRangePerSpan(Phrase phrase) throws NoteListException
MAX_RHYTHM_RANGE
. The range of the melody
is equal to the longest rhythm value divided by the shortest. If the
range of the melody is larger than this constant, this method will return
1 instead.
MAX_RHYTHM_RANGE
is an arbitrary value that was useful
for the developers of this method. If this arbitrary constant means
nothing to your implementation consider using the rhythmRange
method instead.
phrase
- Phrase to be analysedMAX_RHYTHM_RANGE
NoteListException
- if there are no notes in the Phrasepublic static double rhythmRangePerSpan(Note[] noteArray) throws NoteListException
MAX_RHYTHM_RANGE
. The range of the
melody is equal to the longest rhythm value divided by the shortest. If
the range of the melody is larger than this constant, this method will
return 1 instead.
MAX_RHYTHM_RANGE
is an arbitrary value that was useful
for the developers of this method. If this arbitrary constant means
nothing to your implementation consider using the rhythmRange
method instead.
noteArray
- Note array to be analysedMAX_RHYTHM_RANGE
NoteListException
- if there are no notes in the Phrasepublic static double repeatedPitchDensity(Phrase phrase) throws NoteListException
phrase
- Phrase to be analysedNoteListException
- if there are less than two notes in
the Phrasepublic static double repeatedPitchDensity(Note[] noteArray) throws NoteListException
noteArray
- Note array to be analysedNoteListException
- if there are less than two notes in
the Note arraypublic static double repeatedRhythmicValueDensity(Phrase phrase) throws NoteListException
phrase
- Phrase to be analysedNoteListException
- if there are less than two notes in
the Phrasepublic static double repeatedRhythmicValueDensity(Note[] noteArray) throws NoteListException
noteArray
- Note array to be analysedNoteListException
- if there are less than two notes in
the Note arraypublic static double melodicDirectionStability(Phrase phrase) throws NoteListException
phrase
- Phrase to be analysedNoteListException
- if there are less than three notes
in the Phrasepublic static double melodicDirectionStability(Note[] noteArray) throws NoteListException
noteArray
- Note array to be analysedNoteListException
- if there are less than three notes
in the Note arraypublic static double overallPitchDirection(Phrase phrase)
This feature checks the overall tendency of the melodic contour. A melody starting and finishing on the same note will score 0.5, higher indicates an overall rise, and lower scores indicate a descending contour.
phrase
- Phrase to be analysedpublic static double overallPitchDirection(Note[] noteArray)
This feature checks the overall tendency of the melodic contour. A melody starting and finishing on the same note will score 0.5, higher indicates an overall rise, and lower scores indicate a descending contour.
noteArray
- Note array to be analysedpublic static double movementByStep(Phrase phrase, int tonic, int[] scale) throws NoteListException
phrase
- Phrase to be analysedtonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).scale
- array of integers describing the scale notes in the key
of the melody. If the key is major use the MAJOR_SCALE
constant of this class; if harmonic minor
use MINOR_SCALE
. Arrays representing other
keys can also be created but they must fit the criteria
outlined in the descriptions of those constants.NoteListException
- if there are less than two notes in
the Phrasepublic static double movementByStep(Note[] noteArray, int tonic, int[] scale) throws NoteListException
noteArray
- Note array to be analysedtonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).scale
- array of integers describing the scale notes in the key
of the melody. If the key is major use the MAJOR_SCALE
constant of this class; if harmonic minor
use MINOR_SCALE
. Arrays representing other
keys can also be created but they must fit the criteria
outlined in the descriptions of those constants.NoteListException
- if there are less than two notes in
the Note arraypublic static double dissonance(Phrase phrase)
Intervals | Dissonance rating |
---|---|
0, 1, 2, 3, 4, 5, 7, 8, 9 | 0.0 |
10 | 0.5 |
6, 11, 13 or greater | 1.0 |
If the Phrase has no intervals, it is considered to have no dissonance, and so 0 is returned.
phrase
- Phrase to be analysedpublic static double dissonance(Note[] noteArray)
Intervals | Dissonance rating |
---|---|
0, 1, 2, 3, 4, 5, 7, 8, 9 | 0.0 |
10 | 0.5 |
6, 11, 13 or greater | 1.0 |
If the Note array has no intervals, it is considered to have no dissonance, and so 0 is returned.
noteArray
- Note array to be analysedpublic static double leapCompensation(Phrase phrase)
BIG_JUMP_INTERVAL
.
If there are no large leaps this method return 0.
phrase
- Phrase to be analysedpublic static double leapCompensation(Note[] noteArray)
BIG_JUMP_INTERVAL
.
If there are no large leaps this method return 0.
noteArray
- Note array to be analysedpublic static double syncopation(Phrase phrase)
phrase
- Phrase to be analysed.public static double syncopation(Note[] noteArray)
In simple time a beat is considered to be crotchet in length. This feature indicates the degree to which the beat pulse of the music is weakened.
noteArray
- Note array to be analysed.public static double repeatedPitchPatterns(Phrase phrase, int chunkSize) throws NoteListException
phrase
- Phrase to be analysed.chunkSize
- integer describing the size of patterns to countNoteListException
- if the melody does not have more
notes than the size of the patterns searched forpublic static double repeatedPitchPatterns(Note[] noteArray, int chunkSize) throws NoteListException
noteArray
- Note array to be analysed.chunkSize
- integer describing the size of patterns to countNoteListException
- if the melody does not have more
notes than the size of the patterns searched forpublic static double repeatedRhythmPatterns(Phrase phrase, int chunkSize) throws NoteListException
phrase
- Phrase to be analysed.chunkSize
- integer describing the size of patterns to countNoteListException
- if the melody does not have more
notes than the size of the patterns searched forpublic static double repeatedRhythmPatterns(Note[] noteArray, int chunkSize) throws NoteListException
noteArray
- Note array to be analysed.chunkSize
- integer describing the size of patterns to countNoteListException
- if the melody does not have more
notes than the size of the patterns searched forpublic static double climaxPosition(Phrase phrase) throws NoteListException
The climax is defined as the last highest note.
phrase
- Phrase to be analysedNoteListException
public static double climaxPosition(Note[] noteArray) throws NoteListException
The climax is defined as the last highest note.
noteArray
- Note array to be analysedNoteListException
public static double climaxTonality(Phrase phrase, int tonic, int[] scale) throws NoteListException
Pitch | Value returned |
---|---|
Tonic or Dominant | 0.0 |
Other scale note | 0.5 |
Non-scale note | 1.0 |
How the pitch rates depends on the scale of the melody. This information is passed to this method through an integer describing the tonic, and a integer array describing the scale.
phrase
- Phrase to be analysedtonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).scale
- array of integers describing the scale notes in the key
of the melody. If the key is major use the MAJOR_SCALE
constant of this class; if harmonic minor
use MINOR_SCALE
. Arrays representing other
keys can also be created but they must fit the criteria
outlined in the descriptions of those constants.NoteListException
- if there are no notes in the Phrasepublic static double climaxTonality(Note[] noteArray, int tonic, int[] scale) throws NoteListException
Pitch | Value returned |
---|---|
Tonic or Dominant | 0.0 |
Other scale note | 0.5 |
Non-scale note | 1.0 |
How the pitch rates depends on the scale of the melody. This information is passed to this method through an integer describing the tonic, and a integer array describing the scale.
noteArray
- Note array to be analysedtonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).scale
- array of integers describing the scale notes in the key
of the melody. If the key is major use the MAJOR_SCALE
constant of this class; if harmonic minor
use MINOR_SCALE
. Arrays representing other
keys can also be created but they must fit the criteria
outlined in the descriptions of those constants.NoteListException
- if there are no notes in the Note
arraypublic static int noteCount(Phrase phrase)
phrase
- Phrase whose notes are to be countedpublic static int noteCount(Note[] noteArray)
noteArray
- Note array whose notes are to be countedpublic static int quantumCount(Phrase phrase, double duration) throws QuantisationException
phrase
- Phrase whose quanta are to be countedduration
- double representing the length of a quantum, where 1 is
a crotchet. This value must be greater than 0.QuantisationException
- if the Notes' rhythm values are not multiples of the
specified quantum duration, or if quantum duration is
less than or equal to zeropublic static int quantumCount(Note[] noteArray, double duration) throws QuantisationException
noteArray
- Note array whose quanta are to be countedduration
- double representing the length of a quantum, where 1 is
a crotchet. This value must be greater than 0.QuantisationException
- if the Notes' rhythm values are not multiples of the
specified quantum duration, or if quantum duration is
less than or equal to zeropublic static int distinctPitchCount(Phrase phrase)
Phrase
.phrase
- Phrase to be examinedpublic static int distinctPitchCount(Note[] noteArray)
Note
array.noteArray
- array of Note objects to be examinedpublic static int distinctRhythmCount(Phrase phrase)
Phrase
.phrase
- Phrase to be examinedpublic static int distinctRhythmCount(Note[] noteArray)
Note
array.noteArray
- array of Note objects to be examinedpublic static int restQuantumCount(Phrase phrase, double duration) throws QuantisationException
Phrase
. Silent quanta are quanta representing rests.
Silent quanta do not include the quanta representing notes with a
dynamic, or volume, of zero.phrase
- Phrase whose silent quanta are to be measuredduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.QuantisationException
- if the Notes' rhythm values are not multiples of quantum
duration, or if quantum duration is less than or equal
to zeropublic static int restQuantumCount(Note[] noteArray, double duration) throws QuantisationException
Note
array. Silent quanta are quanta representing
rests. Silent quanta do not include the quanta representing notes with
a dynamic, or volume, of zero.noteArray
- Note array whose silent quanta are to be measuredduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.QuantisationException
- if the Notes' rhythm values are not multiples of quantum
duration, or if quantum duration is less than or equal
to zeropublic static int nonScaleQuantumCount(Phrase phrase, double duration, int tonic, int[] scale) throws QuantisationException
The key signature of the melody is specified by parameters passed to this method, namely an integer describing the tonic, and a integer array describing the scale.
phrase
- Phrase to be analysedduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.tonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).scale
- array of integers describing the scale notes in the key
of the melody. If the key is major use the MAJOR_SCALE
constant of this class; if harmonic minor
use MINOR_SCALE
. Arrays representing other
keys can also be created but they must fit the criteria
outlined in the descriptions of those constants.QuantisationException
public static int nonScaleQuantumCount(Note[] noteArray, double duration, int tonic, int[] scale) throws QuantisationException
The key signature of the melody is specified by parameters passed to this method, namely an integer describing the tonic, and a integer array describing the scale.
noteArray
- Note array to be analysedduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.tonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).scale
- array of integers describing the scale notes in the key
of the melody. If the key is major use the MAJOR_SCALE
constant of this class; if harmonic minor
use MINOR_SCALE
. Arrays representing other
keys can also be created but they must fit the criteria
outlined in the descriptions of those constants.QuantisationException
public static int primaryQuantumCount(Phrase phrase, double duration, int tonic) throws QuantisationException
PRIMARY_NOTES
array.
The key signature of the melody is specified by parameters passed to this method, namely an integer describing the tonic, and a integer array describing the scale.
phrase
- Phrase to be analysedduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.tonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).QuantisationException
- if the Notes' rhythm values are not multiples of quantum
duration, or if quantum duration is less than or equal
to zeropublic static int primaryQuantumCount(Note[] noteArray, double duration, int tonic) throws QuantisationException
PRIMARY_NOTES
array.
The key signature of the melody is specified by parameters passed to this method, namely an integer describing the tonic, and a integer array describing the scale.
noteArray
- Note array to be analysedduration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0.tonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).QuantisationException
- if the Notes' rhythm values are not multiples of quantum
duration, or if quantum duration is less than or equal
to zeropublic static int pitchRange(Phrase phrase) throws NoteListException
Phrase
.phrase
- Phrase whose notes are to be examinedNoteListException
- if there are no notes in the Phrasepublic static int pitchRange(Note[] noteArray) throws NoteListException
Note
array.noteArray
- Note array to be examinedNoteListException
- if there are no notes in the Note
arraypublic static double rhythmRange(Phrase phrase) throws NoteListException
phrase
- Phrase whose notes are to be examinedNoteListException
- if there are no notes in the Phrasepublic static double rhythmRange(Note[] noteArray) throws NoteListException
phrase
- Phrase whose notes are to be examinedNoteListException
- if there are no notes in the Note
arraypublic static int consecutiveIdenticalPitches(Phrase phrase)
If there are no note to next note intervals in the melody, this method returns 0 as there are no consecutive identical pitches.
phrase
- Phrase to be analysedpublic static int consecutiveIdenticalPitches(Note[] noteArray)
If there are no note to next note intervals in the melody, this method returns 0 as there are no consecutive identical pitches.
noteArray
- Note array to be analysedpublic static int consecutiveIdenticalRhythms(Phrase phrase)
If there are no Notes in the melody, this method returns 0 as ther are no consecutve indentical rhythm values.
phrase
- Phrase to be analysedpublic static int consecutiveIdenticalRhythms(Note[] noteArray)
noteArray
- Note array to be analysedpublic static int sameDirectionIntervalCount(Phrase phrase)
phrase
- Phrase to be analysedpublic static int sameDirectionIntervalCount(Note[] noteArray)
noteArray
- Note array to be analysedpublic static int intervalCount(Phrase phrase)
phrase
- Phrase to be analysedpublic static int intervalCount(Note[] noteArray)
noteArray
- Note array to be analysedpublic static int[] pitchIntervals(Phrase phrase)
Phrase
. If an
interval has no rests between its notes the integer representing it is
unchanged. However, if the interval has 1 or more rests between its
notes the integer is increased by the value of the
INTERVAL_WITH_REST
constant.
Given any value in the array returned you can determine if it
represents an interval with 1 or more rests between its notes in the
following manner. If the value is greater than the largest valid rising
interval, namely (Note.MAX_PITCH
- Note.MIN_PITCH
), then
it represents an interval with a rest. Otherwise it represents an
interval without a rest.
Given a value representing an interval with a rest, you can determine the size and direction of the interval by subtracting INTERVAL_WITH_REST from the value.
phrase
- Phrase to be examinedpublic static int[] pitchIntervals(Note[] noteArray)
Note
array. If an
interval has no rests between its notes the integer representing it is
unchanged. However, if the interval has 1 or more rests between its
notes the integer is increased by the value of the
INTERVAL_WITH_REST
constant.
Given any value in the array returned you can determine if it
represents an interval with 1 or more rests between its notes in the
following manner. If the value is greater than the largest valid rising
interval, namely (Note.MAX_PITCH
- Note.MIN_PITCH
), then
it represents an interval with a rest. Otherwise it represents an
interval without a rest.
Given a value representing an interval with a rest, you can determine the size and direction of the interval by subtracting INTERVAL_WITH_REST from the value.
noteArray
- Note array to be examinedpublic static double[] rhythmIntervals(Phrase phrase)
Phrase
. The absolute value for any
given interval is the length of the second note, divided by the rhythm
value of the first. Additionally, if the first note of the interval is a
rest the sign of the value is negative.
Intervals involving any trailing rests are ignored. So the second note of the final interval is guaranteed to not be a rest.
phrase
- Phrase to be examinedpublic static double[] rhythmIntervals(Note[] noteArray)
Note
array. The absolute value for
any given interval is the length of the second note, divided by the
rhythm value of the first. Additionally, if the first note of the
interval is a rest the sign of the value is negative.
Intervals involving any trailing rests are ignored. So the second note of the final interval is guaranteed to not be a rest.
phrase
- Phrase to be examinedpublic static int intervalSemitoneCount(Phrase phrase)
phrase
- Phrase to be analysedpublic static int intervalSemitoneCount(Note[] noteArray)
noteArray
- Note array to be analysedpublic static int risingSemitoneCount(Phrase phrase)
phrase
- Phrase to be analysedpublic static int risingSemitoneCount(Note[] noteArray)
noteArray
- Note array to be analysedpublic static int stepIntervalCount(Phrase phrase, int tonic, int[] scale)
The key signature of the melody is specified by parameters passed to this method, namely an integer describing the tonic, and a integer array describing the scale.
phrase
- Phrase to be analysedtonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).scale
- array of integers describing the scale notes in the key
of the melody. If the key is major use the MAJOR_SCALE
constant of this class; if harmonic minor
use MINOR_SCALE
. Arrays representing other
keys can also be created but they must fit the criteria
outlined in the descriptions of those constants.public static int stepIntervalCount(Note[] noteArray, int tonic, int[] scale)
The key signature of the melody is specified by parameters passed to this method, namely an integer describing the tonic, and a integer array describing the scale.
noteArray
- Note array to be analysedtonic
- integer representing the pitch of the tonic in
semitones, ranging from 0 (C natural) to 11 (B flat).scale
- array of integers describing the scale notes in the key
of the melody. If the key is major use the MAJOR_SCALE
constant of this class; if harmonic minor
use MINOR_SCALE
. Arrays representing other
keys can also be created but they must fit the criteria
outlined in the descriptions of those constants.public static int bigJumpFollowedByStepBackCount(Phrase phrase)
BIG_JUMP_INTERVAL
. A step back is a interval in
the opposite direction whose size is at least one semitone and less than
or equal to BIG_JUMP_INTERVAL
.phrase
- Phrase to be analysedpublic static int bigJumpFollowedByStepBackCount(Note[] noteArray)
BIG_JUMP_INTERVAL
. A step back is a interval in
the opposite direction whose size is at least one semitone and less than
or equal to BIG_JUMP_INTERVAL
.noteArray
- Note array to be analysedpublic static int bigJumpCount(Phrase phrase)
BIG_JUMP_INTERVAL
.phrase
- Phrase to be analysedpublic static int bigJumpCount(Note[] noteArray)
BIG_JUMP_INTERVAL
.phrase
- Phrase to be analysedpublic static int pitchPatternCount(Phrase phrase, int chunkSize)
chunksize
in the specified Phrase. A 'pitch interval' is simply
the difference between the pitches of the notes, however there is a
distinction between intervals with no rests and intervals with one or
more rests in between the two notes of the interval.phrase
- Phrase to be searchedchunksize
- The size of the pattern to search forpublic static int pitchPatternCount(Note[] noteArray, int chunkSize)
chunksize
in the specified Note array. A 'pitch interval' is
simply the difference between the pitches of the notes, however there is
a distinction between intervals with no rests and intervals with one or
more rests in between the two notes of the interval.noteArray
- Note array to be searchedchunksize
- The size of the pattern to search forpublic static int rhythmPatternCount(Phrase phrase, int chunksize)
chunksize
in the specified Phrase. A 'rhythm interval' is
calculated according to the following formula. The absolute value of the
'rhythm interval' is the length of the second note, divided by the rhythm
value of the first. Additionally, if the interval has one or more rests
in between the notes, the sign of the value is negative.phrase
- Phrase to be searchedchunksize
- The size of the pattern to search forpublic static int rhythmPatternCount(Note[] noteArray, int chunkSize)
chunksize
in the specified Note array. A 'rhythm interval' is
calculated according to the following formula. The absolute value of the
'rhythm interval' is the length of the second note, divided by the rhythm
value of the first. Additionally, if the interval has one or more rests
in between the notes, the sign of the value is negative.noteArray
- Note array to be searchedchunksize
- The size of the pattern to search forpublic static double rhythmValueCount(Phrase phrase)
phrase
- Phrase to be analysedpublic static double rhythmValueCount(Note[] noteArray)
noteArray
- Note array to be analysedpublic static int removeRestMarker(int interval)
pitchIntervals(jm.music.data.Phrase)
.interval
- integer representing the intervalpublic static boolean isQuantised(Phrase phrase, double duration) throws QuantisationException
Phrase
is quantised. If the rhythm value
of any Note within the Phrase is not a multiple of duration
then false is returned.phrase
- Phrase to be tested.duration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0, otherwise an
exception is thrown.duration
; otherwise falseQuantisationException
- if the quantum duration is less than or equal to zero.Note
,
Phrase
public static boolean isQuantised(Note[] noteArray, double duration) throws QuantisationException
Notes
to see if they are quantised. If the
rhythm value of any of those Notes is not a multiple of
duration
then false is returned.noteArray
- array of Notes to be tested.duration
- double representing the length of a quantum, where 1 is
a crotchet. This must be greater than 0, otherwise an
exception is thrown.duration
; otherwise falseQuantisationException
- if the quantum duration is less than or equal to zero.Note
,
Phrase
public static int pitchToDegree(int pitch, int tonic)
public static boolean isScale(Note note, int tonic, int[] scale)