spiffyscore

Check-in [f02f66468f]
Login
Overview
Comment:Now supports minor chords
Timelines: family | ancestors | descendants | both | tld
Files: files | file ages | folders
SHA1: f02f66468f3954b37cc4ffd28fce21ead388e225
User & Date: spiffytech@gmail.com on 2010-11-17 05:32:12
Other Links: branch diff | manifest | tags
Context
2010-11-17
06:27
TLD now accepts ordering of movements. Also, fixed bug that caused all movements and instruments to play simultaneously. check-in: db1df2f460 user: spiffytech@gmail.com tags: tld
05:32
Now supports minor chords check-in: f02f66468f user: spiffytech@gmail.com tags: tld
00:07
Added support for top-down composition check-in: 7c7ce6adb8 user: spiffytech@gmail.com tags: tld
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Modified cfg.py from [f6edc4689f] to [79cec58b40].

     8      8   import parse
     9      9   
    10     10   def main():
    11     11       key = "A"
    12     12   
    13     13       composition = {
    14     14           "a": {  # Movement block 'a' for reuse throughout the piece
    15         -            "melody": {  # Instrument 'melody'
    16         -                "csound_parameters": {
    17         -                    "instrument": 1,
    18         -                },
    19         -                "grammars": {  # Notes for this instrument to use in this piece
    20         -                    "u": ["I V V V I I IV u u", "I IV u u", "I VII IV u u"  , "e"],
    21         -                    "e": [""],
    22         -                },
    23         -                "score": "u u u",
    24         -            },
           15  +#            "melody": {  # Instrument 'melody'
           16  +#                "csound_parameters": {
           17  +#                    "instrument": 1,
           18  +#                },
           19  +#                "grammars": {  # Notes for this instrument to use in this piece
           20  +#                    "u": ["I V V V I I IV u u", "I IV u u", "I VII IV u u"  , "e"],
           21  +#                    "e": [""],
           22  +#                },
           23  +#                "score": "u u u",
           24  +#            },
    25     25               "rhythm": {
    26     26                   "csound_parameters": {
    27     27                       "instrument": 1,
    28     28                   },
    29     29                   "grammars": {
    30         -                    "u": ['"I" "IV"/2 "V"2 "IV" "I" u u', '"I" "VII" "IV" u u', '"I" "V" "IV" u u', "e"],
           30  +#                    "u": ['"I" "ii"/4 "ii"/4 "IV"/2 "V"2 "IV" "I" u u', '"I" "vii" "IV" u u', '"I" "v" "IV" u u', "e"],
           31  +                    "u": ['"i" "I" "ii" "II" "v" "V" u', "e"],
    31     32                       "e": [""]
    32     33                   },
    33     34                   "score": "u u u",
    34     35               },
    35     36           },
    36         -        "b": {
    37         -            "melody": {  # Instrument 'melody'
    38         -                "csound_parameters": {
    39         -                    "instrument": 1,
    40         -                },
    41         -                "grammars": {  # Notes for this instrument to use in this piece
    42         -                    "u": ["I V I I/2 IV/2 u u", "I4 IV u u", "I IV IV VI V u u"  , "e"],
    43         -                    "e": [""],
    44         -                },
    45         -                "score": "u u u",
    46         -            },
    47         -            "rhythm": {
    48         -                "csound_parameters": {
    49         -                    "instrument": 1,
    50         -                },
    51         -                "grammars": {
    52         -                    "u": ['"I" "IV"/2 "V"2 "IV" "I" u u', '"I" "VII" "IV" u u', '"I" "V" "IV" u u', "e"],
    53         -                    "e": [""]
    54         -                },
    55         -                "score": "u u u",
    56         -            },
    57         -        },
           37  +#        "b": {
           38  +#            "melody": {  # Instrument 'melody'
           39  +#                "csound_parameters": {
           40  +#                    "instrument": 1,
           41  +#                },
           42  +#                "grammars": {  # Notes for this instrument to use in this piece
           43  +#                    "u": ["I V I I/2 IV/2 u u", "I4 IV u u", "I IV IV VI V u u"  , "e"],
           44  +#                    "e": [""],
           45  +#                },
           46  +#                "score": "u u u",
           47  +#            },
           48  +#            "rhythm": {
           49  +#                "csound_parameters": {
           50  +#                    "instrument": 1,
           51  +#                },
           52  +#                "grammars": {
           53  +#                    "u": ['"I" "IV"/2 "V"2 "IV" "I" u u', '"I" "VII" "IV" u u', '"I" "V" "IV" u u', "e"],
           54  +#                    "e": [""]
           55  +#                },
           56  +#                "score": "u u u",
           57  +#            },
           58  +#        },
    58     59       }
    59     60   
    60     61       for comp_name, comp in composition.iteritems():
    61     62           for instr_name, instr in comp.iteritems():
    62     63               generated_score = generate_score(instr["score"], instr["grammars"])  # Fill in the scores by generating them based on the grammars
    63     64   #                composition[comp_name][instr_name][grammar]["score"] = parse.parse(generate_score)  # Return Node/Chord objects
    64     65               score = parse.parse(generated_score)  # Return Node/Chord objects
................................................................................
   125    126       for i in range(len(score)):
   126    127           if isinstance(score[i], parse.Note):
   127    128               score[i].value = scale[scale_conversion[score[i].value]-1]
   128    129           else:
   129    130               chord = []
   130    131               root_note_index = scale.index(key) + scale_conversion[score[i].value]
   131    132               chord.append(scale[root_note_index])
   132         -            chord.append(scale[(root_note_index+3) % 8])
          133  +            if score[i].chord_type == "m":  # Minor chords, flat the 3rd
          134  +                chord.append(scale[(root_note_index+2) % 8])
          135  +            else:
          136  +                chord.append(scale[(root_note_index+3) % 8])
   133    137               chord.append(scale[(root_note_index+5) % 8])
   134    138               score[i].chord = chord
   135    139       return score
   136    140   
   137    141   
   138    142   def generate_csound_score(score):
   139    143       csound_note_values = {

Modified parse.py from [503badc6f2] to [b7fd05b171].

   100    100           p[0] = new_note
   101    101   
   102    102   
   103    103       def p_chord(p):
   104    104           '''chord : QUOTE pitch QUOTE
   105    105                   | QUOTE pitch CHORD_TYPE QUOTE
   106    106           '''
   107         -        p[0] = Chord(value=p[2].value)
          107  +        pitch = p[2].value
          108  +        pitch = pitch.upper()
          109  +        p[0] = Chord(value=pitch)
   108    110           if len(p) > 3:
   109    111               p[0].chord_type = p[3]
   110    112   
   111    113   
   112    114       def p_accidental(p):
   113    115           '''pitch : ACCIDENTAL pitch
   114    116           '''

Modified test.sco from [da39a3ee5e] to [7126d43817].

            1  +f1  0   256 10  1 0 3   ; sine wave function table
            2  +i2 0.000000 1 7000 7.11 7.11 0 6
            3  +i2 0.000000 1 7000 7.04 7.04 0 6
            4  +i2 0.000000 1 7000 8.08 8.08 0 6
            5  +i2 1.000000 1 7000 8.11 8.11 0 6
            6  +i2 1.000000 1 7000 8.04 8.04 0 6
            7  +i2 1.000000 1 7000 8.08 8.08 0 6
            8  +i2 2.000000 1 7000 8.01 8.01 0 6
            9  +i2 2.000000 1 7000 8.06 8.06 0 6
           10  +i2 2.000000 1 7000 8.09 8.09 0 6
           11  +i2 3.000000 1 7000 7.01 7.01 0 6
           12  +i2 3.000000 1 7000 7.06 7.06 0 6
           13  +i2 3.000000 1 7000 8.09 8.09 0 6
           14  +i2 4.000000 1 7000 7.06 7.06 0 6
           15  +i2 4.000000 1 7000 7.09 7.09 0 6
           16  +i2 4.000000 1 7000 7.01 7.01 0 6
           17  +i2 5.000000 1 7000 8.06 8.06 0 6
           18  +i2 5.000000 1 7000 7.09 7.09 0 6
           19  +i2 5.000000 1 7000 7.01 7.01 0 6
           20  +i2 6.000000 1 7000 7.11 7.11 0 6
           21  +i2 6.000000 1 7000 7.04 7.04 0 6
           22  +i2 6.000000 1 7000 8.08 8.08 0 6
           23  +i2 7.000000 1 7000 8.11 8.11 0 6
           24  +i2 7.000000 1 7000 7.04 7.04 0 6
           25  +i2 7.000000 1 7000 7.08 7.08 0 6
           26  +i2 8.000000 1 7000 8.01 8.01 0 6
           27  +i2 8.000000 1 7000 8.06 8.06 0 6
           28  +i2 8.000000 1 7000 7.09 7.09 0 6
           29  +i2 9.000000 1 7000 8.01 8.01 0 6
           30  +i2 9.000000 1 7000 7.06 7.06 0 6
           31  +i2 9.000000 1 7000 8.09 8.09 0 6
           32  +i2 10.000000 1 7000 8.06 8.06 0 6
           33  +i2 10.000000 1 7000 7.09 7.09 0 6
           34  +i2 10.000000 1 7000 8.01 8.01 0 6
           35  +i2 11.000000 1 7000 8.06 8.06 0 6
           36  +i2 11.000000 1 7000 8.09 8.09 0 6
           37  +i2 11.000000 1 7000 8.01 8.01 0 6
           38  +i2 12.000000 1 7000 7.11 7.11 0 6
           39  +i2 12.000000 1 7000 7.04 7.04 0 6
           40  +i2 12.000000 1 7000 8.08 8.08 0 6
           41  +i2 13.000000 1 7000 7.11 7.11 0 6
           42  +i2 13.000000 1 7000 8.04 8.04 0 6
           43  +i2 13.000000 1 7000 7.08 7.08 0 6
           44  +i2 14.000000 1 7000 7.01 7.01 0 6
           45  +i2 14.000000 1 7000 7.06 7.06 0 6
           46  +i2 14.000000 1 7000 7.09 7.09 0 6
           47  +i2 15.000000 1 7000 8.01 8.01 0 6
           48  +i2 15.000000 1 7000 8.06 8.06 0 6
           49  +i2 15.000000 1 7000 7.09 7.09 0 6
           50  +i2 16.000000 1 7000 8.06 8.06 0 6
           51  +i2 16.000000 1 7000 8.09 8.09 0 6
           52  +i2 16.000000 1 7000 7.01 7.01 0 6
           53  +i2 17.000000 1 7000 7.06 7.06 0 6
           54  +i2 17.000000 1 7000 7.09 7.09 0 6
           55  +i2 17.000000 1 7000 7.01 7.01 0 6

Modified todo.org from [9bec386f24] to [0747c315e6].

     1         -* Features [0/5]
     2         -- [ ] Top-down composition
            1  +* Features [1/4]
            2  +- [X] Top-down composition
     3      3   - [ ] Transition the melody between chords appropriately
     4      4   - [ ] Set maximum song length
            5  +- [ ] Need to support all chord types
     5      6   
     6         -* Bugs [0/1]
     7         -- [ ] Doesn't handle minor chords
            7  +* Bugs [1/5]
            8  +- [ ] TLD resets clock for each movement
            9  +- [ ] TLD doesn't accept an ordering for the movements
           10  +- [X] Doesn't handle minor chords
     8     11   - [ ] Duration syntax is absolute, not relative to BPM
           12  +- [ ] Chords don't respect octaves
           13  +
           14  +
           15  +* Structure [0/2]
           16  +- [ ] Chords should be composed of Notes, not ordinary arrays
           17  +- [ ] Generate score with proper generation tools