Package org.jfugue.tools
Class GetPatternStats
- java.lang.Object
-
- org.jfugue.tools.GetPatternStats
-
public class GetPatternStats extends java.lang.ObjectProvidesPatternand MIDI analysis of the following elements: General descriptors, Pitch descriptors, Duration descriptors, Silence descriptors (rests), Interval descriptors (half-steps), Inter Onset Interval (IOI), Harmonic Descriptors (Non-diatonics), Rhythm Descriptors (Syncopations), Normality Descriptors.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classGetPatternStats.Stats
-
Constructor Summary
Constructors Constructor Description GetPatternStats()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublecomparePatterns(Pattern p1, Pattern p2)Parses two patterns to find average difference of all statsGetPatternStats.StatsgetDurationStats()GetsStatsobject containing note duration N, Average (mean - min), SD, and Range.int[]getGeneralStats()Gets general statistics (Number of notes, number of rests, number of measures)GetPatternStats.StatsgetHarmonicStats()GetsStatsobject containing harmonics N, Average (mean - min), SD, and Range.GetPatternStats.StatsgetIntervalStats()GetsStatsobject containing pitch interval N, Average (mean - min), SD, and Range.GetPatternStats.StatsgetIOIStats()GetsStatsobject containing inter-onset-interval(IOI) N, Average (mean - min), SD, and Range.GetPatternStats.StatsgetPitchStats()GetsStatsobject containing pitch N, Average (mean - min), SD, and Range.GetPatternStats.StatsgetRestStats()GetsStatsobject containing rest duration N, Average (mean - min), SD, and Range.intgetRhythmStats()Gets number of syncopations.voidparsePattern(java.io.File midiFile, java.lang.Boolean clear)Parses MIDI file to calculate statistics for all descriptorsvoidparsePattern(Pattern pattern, java.lang.Boolean clear)Parses JFuguePatternto calculate statistics for all descriptors.java.lang.StringtoString()
-
-
-
Method Detail
-
parsePattern
public void parsePattern(Pattern pattern, java.lang.Boolean clear)
Parses JFuguePatternto calculate statistics for all descriptors.- Parameters:
pattern- The JFuge Pattern to be parsed.clear- True to clear previous data, false to add to previous data
-
parsePattern
public void parsePattern(java.io.File midiFile, java.lang.Boolean clear) throws java.io.IOException, javax.sound.midi.InvalidMidiDataExceptionParses MIDI file to calculate statistics for all descriptors- Parameters:
midiFile- The MIDI file to be parsed.clear- True to clear previous data, false to add to previous data- Throws:
java.io.IOExceptionjavax.sound.midi.InvalidMidiDataException
-
comparePatterns
public double comparePatterns(Pattern p1, Pattern p2)
Parses two patterns to find average difference of all stats- Parameters:
Pattern- Pattern 1 to be parsedPattern- Pattern 2 to be parsed- Returns:
- The average difference between patterns
-
getGeneralStats
public int[] getGeneralStats()
Gets general statistics (Number of notes, number of rests, number of measures)- Returns:
- Array index 0: N of Notes; index 1: N of rests; index 2: N of measures
-
getPitchStats
public GetPatternStats.Stats getPitchStats()
GetsStatsobject containing pitch N, Average (mean - min), SD, and Range.- Returns:
Statsobject for pitch
-
getDurationStats
public GetPatternStats.Stats getDurationStats()
GetsStatsobject containing note duration N, Average (mean - min), SD, and Range.- Returns:
Statsobject for note duration
-
getRestStats
public GetPatternStats.Stats getRestStats()
GetsStatsobject containing rest duration N, Average (mean - min), SD, and Range. Only silences greater than a 16th note are evaluated.- Returns:
Statsobject for rest duration
-
getIntervalStats
public GetPatternStats.Stats getIntervalStats()
GetsStatsobject containing pitch interval N, Average (mean - min), SD, and Range. Intervals are in half-steps.- Returns:
Statsobject for pitch interval
-
getIOIStats
public GetPatternStats.Stats getIOIStats()
GetsStatsobject containing inter-onset-interval(IOI) N, Average (mean - min), SD, and Range. Inter-onset-intervals are the number of MIDI pulses between the onset of non-rest notes.- Returns:
Statsobject for IOI
-
getRhythmStats
public int getRhythmStats()
Gets number of syncopations. Syncopations are calculated as any note that begins between beats and extends beyond the next beat. ie. C5H C5W C5H - the middle note is syncopated.- Returns:
Statsobject for rhythm
-
getHarmonicStats
public GetPatternStats.Stats getHarmonicStats()
GetsStatsobject containing harmonics N, Average (mean - min), SD, and Range. Non-diatonic notes based off of the parsed key signature or default of Cmaj. Average is average of 0-4, as a degree of non-diatonic notes. ie. 0: ♭II, 1: ♭III (♮III for minor key), 2: ♭V, 3: ♭VI, 4: ♭VII. SD is also computed using degree of non-diatonic notes.- Returns:
Statsobject for harmonics
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-