Module Expr Str ImportFrom alias alias ImportFrom alias ImportFrom alias Import alias alias alias Expr Str FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr If CompareEq AttributeLoad NameLoad attr Str body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad Call NameLoad ListComp NameLoad comprehension NameStore Call AttributeLoad NameLoad attr Assign NameStore ListComp AttributeLoad NameLoad attr comprehension NameStore NameLoad Assign NameStore AttributeLoad NameLoad attr Return CompareIn NameLoad NameLoad decorator_list Expr Str FunctionDef arguments args NameParam NameParam defaults body For NameStore AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr Num Assign NameStore Call AttributeLoad NameLoad attr Num If BoolOpOr CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr CompareEq AttributeLoad NameLoad attr AttributeLoad Call AttributeLoad NameLoad attr attr CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr CompareEq AttributeLoad NameLoad attr AttributeLoad Call AttributeLoad NameLoad attr attr body Return NameLoad Return NameLoad decorator_list Expr Str FunctionDef arguments args NameParam NameParam defaults body Return CompareIn AttributeLoad NameLoad attr GeneratorExp AttributeLoad NameLoad attr comprehension NameStore AttributeLoad NameLoad attr decorator_list Expr Str FunctionDef arguments args NameParam defaults body Assign NameStore ListComp AttributeLoad NameLoad attr comprehension NameStore AttributeLoad NameLoad attr Return Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad decorator_list Expr Str FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr If CompareEq AttributeLoad NameLoad attr Str body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad Call NameLoad ListComp NameLoad comprehension NameStore Call AttributeLoad NameLoad attr Assign NameStore ListComp AttributeLoad NameLoad attr comprehension NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr ListComp AttributeLoad NameLoad attr comprehension NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad Return NameLoad decorator_list Expr Str FunctionDef arguments args NameParam defaults body Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr ListLoad Num Num Return NameLoad decorator_list Expr Str FunctionDef arguments args NameParam defaults body Return Call NameLoad NameLoad decorator_list Expr Str FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr ListLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr ListLoad AttributeLoad NameLoad attr Assign NameStore BinOpSub AttributeLoad SubscriptLoad NameLoad Index Num attr BinOpMod AttributeLoad SubscriptLoad NameLoad Index Num attr Num Assign NameStore BinOpSub AttributeLoad SubscriptLoad NameLoad Index Num attr NameLoad Assign NameStore Str Assign NameStore NameLoad Assign NameStore Num For TupleStore NameStore NameStore Call NameLoad NameLoad body TryExcept body Assign NameStore SubscriptLoad ListComp NameLoad comprehension NameStore NameLoad CompareLtE AttributeLoad NameLoad attr AttributeLoad NameLoad attr Index Num handlers ExceptHandler type NameLoad body Assign AttributeStore SubscriptLoad NameLoad Index Num attr NameLoad Assign NameStore SubscriptLoad ListComp NameLoad comprehension NameStore NameLoad CompareLtE AttributeLoad NameLoad attr AttributeLoad NameLoad attr Index Num Assign NameStore Str If Call NameLoad NameLoad AttributeLoad NameLoad attr body Assign NameStore Str orelse If BoolOpOr CompareIn AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call NameLoad NameLoad AttributeLoad NameLoad attr body Assign NameStore Str orelse If Call NameLoad NameLoad NameLoad body Assign NameStore Str orelse If Call NameLoad NameLoad NameLoad body Assign NameStore Str orelse Assign NameStore Str If CompareEq NameLoad BinOpSub Call NameLoad NameLoad Num body Assign NameStore BinOpSub BinOpAdd NameLoad Num AttributeLoad NameLoad attr orelse Assign NameStore BinOpSub AttributeLoad SubscriptLoad NameLoad Index BinOpAdd NameLoad Num attr AttributeLoad NameLoad attr Assign NameStore BinOpMod Str TupleLoad NameLoad AttributeLoad NameLoad attr Assign NameStore Str If Call NameLoad NameLoad AttributeLoad NameLoad attr body AugAssignAdd NameStore Num If CompareEq NameLoad Num body Assign NameStore NameLoad orelse Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr ListLoad NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr ListLoad NameLoad Str Assign NameStore BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore NameLoad Assign NameStore BinOpAdd NameLoad NameLoad AugAssignAdd NameStore BinOpAdd NameLoad Str Return Call AttributeLoad NameLoad attr decorator_list Expr Str FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Num Assign NameStore NameLoad For TupleStore NameStore NameStore Call NameLoad Call AttributeLoad NameLoad attr Str body Assign NameStore Call AttributeLoad NameLoad attr Str AugAssignAdd NameStore Call NameLoad SubscriptLoad NameLoad Index Num If CompareEq SubscriptLoad NameLoad Index Num Str body Assign NameStore Call AttributeLoad NameLoad attr keyword Call NameLoad SubscriptLoad NameLoad Index Num Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Continue TryExcept body Assign NameStore SubscriptLoad ListComp NameLoad comprehension NameStore NameLoad CompareLtE AttributeLoad NameLoad attr NameLoad Index Num handlers ExceptHandler type NameLoad body Assign AttributeStore SubscriptLoad NameLoad Index Num attr Num Assign NameStore SubscriptLoad ListComp NameLoad comprehension NameStore NameLoad CompareLtE AttributeLoad NameLoad attr NameLoad Index Num If CompareEq Call NameLoad NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr If CompareEq SubscriptLoad NameLoad Index Num Str body Assign NameStore Call NameLoad NameLoad orelse If CompareEq SubscriptLoad NameLoad Index Num Str body Assign NameStore Call NameLoad NameLoad orelse Assign NameStore Call NameLoad NameLoad Assign AttributeStore NameLoad attr Call NameLoad SubscriptLoad NameLoad Index Num If CompareLt AttributeLoad NameLoad attr Num body Assign AttributeStore NameLoad attr Num Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore NameLoad orelse Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad SubscriptLoad NameLoad Index Num attr Str Str Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad SubscriptLoad NameLoad Index Num attr Str Str If CompareGt AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Assign TupleStore NameStore NameStore TupleLoad NameLoad NameLoad orelse Assign TupleStore NameStore NameStore TupleLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad BinOpAdd BinOpSub AttributeLoad NameLoad attr AttributeLoad NameLoad attr Num If CompareEq SubscriptLoad NameLoad Index Num Str body Assign NameStore ListLoad For NameStore Call NameLoad Num NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr If Call NameLoad NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad If CompareGt Call NameLoad NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr ListComp NameLoad comprehension NameStore NameLoad CompareNotEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse If CompareEq Call NameLoad NameLoad Num body Assign NameStore SubscriptLoad NameLoad Index Num orelse Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr ListLoad Num Num If CompareLt AttributeLoad NameLoad attr Num body Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Call NameLoad SubscriptLoad NameLoad Index Num Expr Call AttributeLoad NameLoad attr NameLoad NameLoad orelse If CompareEq SubscriptLoad NameLoad Index Num Str body Assign NameStore ListLoad For NameStore Call NameLoad Num NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr If Call NameLoad NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad If CompareGt Call NameLoad NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr ListComp NameLoad comprehension NameStore NameLoad CompareNotEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse If CompareEq Call NameLoad NameLoad Num body Assign NameStore SubscriptLoad NameLoad Index Num orelse Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr ListLoad Num Num If CompareLt AttributeLoad NameLoad attr Num body Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Call NameLoad SubscriptLoad NameLoad Index Num Expr Call AttributeLoad NameLoad attr NameLoad NameLoad orelse Assign NameStore ListLoad For NameStore Call NameLoad Num NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr If Call NameLoad NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad If CompareGt Call NameLoad NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr ListComp NameLoad comprehension NameStore NameLoad CompareNotEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse If CompareEq Call NameLoad NameLoad Num body Assign NameStore SubscriptLoad NameLoad Index Num orelse Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr ListLoad Num Num If CompareLt AttributeLoad NameLoad attr Num body Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Call NameLoad SubscriptLoad NameLoad Index Num Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore NameLoad Return NameLoad decorator_list
N/A N/A 
Author:     Ji-Sung Kim, Evan Chow
Project:    jazzml / deepjazz
Purpose:    Extract, manipulate, process musical grammar

Directly taken then cleaned up from Evan Chow's jazzml, 
https://github.com/evancchow/jazzml,with permission.
 collections OrderedDict defaultdict itertools groupby music21 * N/A copy random pdb N/A  Helper function to determine if a note is a scale tone.  __is_scale_tone N/A N/A chord note N/A N/A N/A scaleType N/A N/A scale DorianScale N/A N/A N/A chord quality major N/A N/A scaleType N/A N/A scale MajorScale N/A scales N/A N/A scaleType derive chord N/A allPitches N/A list N/A set N/A pitch N/A pitch N/A N/A scales getPitches N/A allNoteNames N/A N/A i name N/A i allPitches N/A noteName N/A note name N/A N/A noteName allNoteNames N/A N/A  Helper function to determine if a note is an approach tone.  __is_approach_tone N/A N/A chord note N/A N/A N/A chordPitch N/A chord pitches N/A N/A stepUp N/A N/A chordPitch transpose 1 N/A stepDown N/A N/A chordPitch transpose -1 N/A N/A N/A N/A note name N/A stepDown name N/A N/A note name N/A N/A N/A stepDown getEnharmonic name N/A N/A note name N/A stepUp name N/A N/A note name N/A N/A N/A stepUp getEnharmonic name N/A N/A True N/A False N/A N/A  Helper function to determine if a note is a chord tone.  __is_chord_tone N/A N/A lastChord note N/A N/A N/A N/A N/A note name N/A N/A p name N/A p N/A lastChord pitches N/A N/A  Helper function to generate a chord tone.  __generate_chord_tone N/A N/A lastChord N/A N/A N/A lastChordNoteNames N/A N/A p nameWithOctave N/A p N/A lastChord pitches N/A N/A N/A note Note N/A N/A random choice lastChordNoteNames N/A N/A  Helper function to generate a scale tone.  __generate_scale_tone N/A N/A lastChord N/A N/A N/A scaleType N/A N/A scale WeightedHexatonicBlues N/A N/A N/A lastChord quality major N/A N/A scaleType N/A N/A scale MajorScale N/A scales N/A N/A scaleType derive lastChord N/A allPitches N/A list N/A set N/A pitch N/A pitch N/A N/A scales getPitches N/A allNoteNames N/A N/A i name N/A i allPitches N/A sNoteName N/A N/A random choice allNoteNames N/A lastChordSort N/A N/A lastChord sortAscending N/A sNoteOctave N/A N/A random choice N/A N/A i octave N/A i N/A lastChordSort pitches N/A sNote N/A N/A note Note N/A %s%s N/A sNoteName sNoteOctave N/A sNote N/A N/A  Helper function to generate an approach tone.  __generate_approach_tone N/A N/A lastChord N/A N/A N/A sNote N/A __generate_scale_tone lastChord N/A aNote N/A N/A sNote transpose N/A N/A random choice N/A 1 -1 N/A aNote N/A N/A  Helper function to generate a random tone.  __generate_arbitrary_tone N/A N/A lastChord N/A N/A N/A N/A __generate_scale_tone lastChord N/A N/A  Given the notes in a measure ('measure') and the chords in that measure
    ('chords'), generate a list of abstract grammatical symbols to represent 
    that measure as described in GTK's "Learning Jazz Grammars" (2009). 

    Inputs: 
    1) "measure" : a stream.Voice object where each element is a
        note.Note or note.Rest object.

        >>> m1
        <music21.stream.Voice 328482572>
        >>> m1[0]
        <music21.note.Rest rest>
        >>> m1[1]
        <music21.note.Note C>

        Can have instruments and other elements, removes them here.

    2) "chords" : a stream.Voice object where each element is a chord.Chord.

        >>> c1
        <music21.stream.Voice 328497548>
        >>> c1[0]
        <music21.chord.Chord E-4 G4 C4 B-3 G#2>
        >>> c1[1]
        <music21.chord.Chord B-3 F4 D4 A3>

        Can have instruments and other elements, removes them here. 

    Outputs:
    1) "fullGrammar" : a string that holds the abstract grammar for measure.
        Format: 
        (Remember, these are DURATIONS not offsets!)
        "R,0.125" : a rest element of  (1/32) length, or 1/8 quarter note. 
        "C,0.125<M-2,m-6>" : chord note of (1/32) length, generated
                             anywhere from minor 6th down to major 2nd down.
                             (interval <a,b> is not ordered).  parse_melody N/A N/A fullMeasureNotes fullMeasureChords N/A N/A N/A measure N/A N/A copy deepcopy fullMeasureNotes N/A chords N/A N/A copy deepcopy fullMeasureChords N/A N/A N/A measure removeByNotOfClass N/A N/A note Note N/A note Rest N/A N/A N/A chords removeByNotOfClass N/A N/A chord Chord N/A measureStartTime N/A N/A N/A measure N/A 0 offset N/A N/A N/A measure N/A 0 offset 4 N/A measureStartOffset N/A N/A N/A measure N/A 0 offset measureStartTime N/A fullGrammar N/A prevNote None N/A numNonRests 0 N/A N/A ix nr N/A enumerate measure N/A N/A N/A N/A lastChord N/A N/A n N/A n chords N/A N/A n offset N/A nr offset N/A -1 N/A N/A N/A IndexError N/A N/A N/A N/A chords N/A 0 offset measureStartTime N/A lastChord N/A N/A n N/A n chords N/A N/A n offset N/A nr offset N/A -1 N/A elementType N/A N/A isinstance nr N/A note Rest N/A N/A elementType R N/A N/A N/A N/A N/A nr name N/A lastChord pitchNames N/A isinstance nr N/A chord Chord N/A N/A elementType C N/A N/A N/A __is_scale_tone lastChord nr N/A N/A elementType S N/A N/A N/A __is_approach_tone lastChord nr N/A N/A elementType A N/A N/A elementType X N/A N/A ix N/A N/A len measure 1 N/A N/A diff N/A N/A measureStartTime 4.0 N/A nr offset N/A N/A diff N/A N/A N/A measure N/A N/A ix 1 offset N/A nr offset N/A noteInfo N/A %s,%.3f N/A elementType N/A nr quarterLength N/A intervalInfo N/A N/A isinstance nr N/A note Note N/A N/A numNonRests 1 N/A N/A numNonRests 1 N/A N/A prevNote nr N/A N/A noteDist N/A N/A interval Interval noteStart prevNote noteEnd nr N/A noteDistUpper N/A N/A interval add N/A noteDist m3 N/A noteDistLower N/A N/A interval subtract N/A noteDist m3 N/A intervalInfo N/A ,<%s,%s> N/A N/A noteDistUpper directedName N/A noteDistLower directedName N/A prevNote nr N/A grammarTerm N/A noteInfo intervalInfo N/A fullGrammar N/A grammarTerm N/A N/A N/A fullGrammar rstrip N/A N/A  Given a grammar string and chords for a measure, returns measure notes.  unparse_grammar N/A N/A m1_grammar m1_chords N/A N/A N/A m1_elements N/A N/A stream Voice N/A currOffset 0.0 N/A prevElement None N/A N/A ix grammarElement N/A enumerate N/A N/A m1_grammar split N/A N/A terms N/A N/A grammarElement split , N/A currOffset N/A float N/A terms N/A 1 N/A N/A N/A terms N/A 0 R N/A N/A rNote N/A N/A note Rest quarterLength N/A float N/A terms N/A 1 N/A N/A N/A m1_elements insert currOffset rNote N/A N/A N/A N/A lastChord N/A N/A n N/A n m1_chords N/A N/A n offset currOffset N/A -1 N/A N/A N/A IndexError N/A N/A N/A N/A m1_chords N/A 0 offset 0.0 N/A lastChord N/A N/A n N/A n m1_chords N/A N/A n offset currOffset N/A -1 N/A N/A N/A len terms 2 N/A N/A insertNote N/A N/A note Note N/A N/A N/A terms N/A 0 C N/A N/A insertNote N/A __generate_chord_tone lastChord N/A N/A N/A N/A terms N/A 0 S N/A N/A insertNote N/A __generate_scale_tone lastChord N/A N/A insertNote N/A __generate_approach_tone lastChord N/A N/A insertNote quarterLength N/A float N/A terms N/A 1 N/A N/A N/A insertNote octave 4 N/A N/A N/A insertNote octave 4 N/A N/A N/A m1_elements insert currOffset insertNote N/A prevElement insertNote N/A N/A interval1 N/A N/A interval Interval N/A N/A N/A terms N/A 2 replace < N/A interval2 N/A N/A interval Interval N/A N/A N/A terms N/A 3 replace > N/A N/A N/A interval1 cents N/A interval2 cents N/A N/A N/A upperInterval lowerInterval N/A interval1 interval2 N/A N/A N/A upperInterval lowerInterval N/A interval2 interval1 N/A lowPitch N/A N/A interval transposePitch N/A prevElement pitch lowerInterval N/A highPitch N/A N/A interval transposePitch N/A prevElement pitch upperInterval N/A numNotes N/A int N/A N/A N/A highPitch ps N/A lowPitch ps 1 N/A N/A N/A terms N/A 0 C N/A N/A relevantChordTones N/A N/A i N/A xrange 0 numNotes N/A N/A currNote N/A N/A note Note N/A N/A N/A N/A lowPitch transpose i simplifyEnharmonic N/A N/A __is_chord_tone lastChord currNote N/A N/A N/A N/A relevantChordTones append currNote N/A N/A N/A len relevantChordTones 1 N/A N/A insertNote N/A N/A random choice N/A i N/A i relevantChordTones N/A N/A i nameWithOctave N/A prevElement nameWithOctave N/A N/A N/A N/A len relevantChordTones 1 N/A N/A insertNote N/A relevantChordTones N/A 0 N/A N/A insertNote N/A N/A prevElement transpose N/A N/A random choice N/A -2 2 N/A N/A N/A insertNote octave 3 N/A N/A N/A insertNote octave 3 N/A N/A insertNote quarterLength N/A float N/A terms N/A 1 N/A N/A N/A m1_elements insert currOffset insertNote N/A N/A N/A N/A terms N/A 0 S N/A N/A relevantScaleTones N/A N/A i N/A xrange 0 numNotes N/A N/A currNote N/A N/A note Note N/A N/A N/A N/A lowPitch transpose i simplifyEnharmonic N/A N/A __is_scale_tone lastChord currNote N/A N/A N/A N/A relevantScaleTones append currNote N/A N/A N/A len relevantScaleTones 1 N/A N/A insertNote N/A N/A random choice N/A i N/A i relevantScaleTones N/A N/A i nameWithOctave N/A prevElement nameWithOctave N/A N/A N/A N/A len relevantScaleTones 1 N/A N/A insertNote N/A relevantScaleTones N/A 0 N/A N/A insertNote N/A N/A prevElement transpose N/A N/A random choice N/A -2 2 N/A N/A N/A insertNote octave 3 N/A N/A N/A insertNote octave 3 N/A N/A insertNote quarterLength N/A float N/A terms N/A 1 N/A N/A N/A m1_elements insert currOffset insertNote N/A N/A relevantApproachTones N/A N/A i N/A xrange 0 numNotes N/A N/A currNote N/A N/A note Note N/A N/A N/A N/A lowPitch transpose i simplifyEnharmonic N/A N/A __is_approach_tone lastChord currNote N/A N/A N/A N/A relevantApproachTones append currNote N/A N/A N/A len relevantApproachTones 1 N/A N/A insertNote N/A N/A random choice N/A i N/A i relevantApproachTones N/A N/A i nameWithOctave N/A prevElement nameWithOctave N/A N/A N/A N/A len relevantApproachTones 1 N/A N/A insertNote N/A relevantApproachTones N/A 0 N/A N/A insertNote N/A N/A prevElement transpose N/A N/A random choice N/A -2 2 N/A N/A N/A insertNote octave 3 N/A N/A N/A insertNote octave 3 N/A N/A insertNote quarterLength N/A float N/A terms N/A 1 N/A N/A N/A m1_elements insert currOffset insertNote N/A prevElement insertNote N/A m1_elements N/A