Class GetPatternStats


  • public class GetPatternStats
    extends java.lang.Object
    Provides Pattern and 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.
    • Constructor Detail

      • GetPatternStats

        public GetPatternStats()
    • Method Detail

      • parsePattern

        public void parsePattern​(Pattern pattern,
                                 java.lang.Boolean clear)
        Parses JFugue Pattern to 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.InvalidMidiDataException
        Parses 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.IOException
        javax.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 parsed
        Pattern - 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()
        Gets Stats object containing pitch N, Average (mean - min), SD, and Range.
        Returns:
        Stats object for pitch
      • getDurationStats

        public GetPatternStats.Stats getDurationStats()
        Gets Stats object containing note duration N, Average (mean - min), SD, and Range.
        Returns:
        Stats object for note duration
      • getRestStats

        public GetPatternStats.Stats getRestStats()
        Gets Stats object containing rest duration N, Average (mean - min), SD, and Range. Only silences greater than a 16th note are evaluated.
        Returns:
        Stats object for rest duration
      • getIntervalStats

        public GetPatternStats.Stats getIntervalStats()
        Gets Stats object containing pitch interval N, Average (mean - min), SD, and Range. Intervals are in half-steps.
        Returns:
        Stats object for pitch interval
      • getIOIStats

        public GetPatternStats.Stats getIOIStats()
        Gets Stats object 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:
        Stats object 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:
        Stats object for rhythm
      • getHarmonicStats

        public GetPatternStats.Stats getHarmonicStats()
        Gets Stats object 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:
        Stats object for harmonics
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object