spiffyscore

Check-in [0021a3fe22]
Login
Overview
SHA1:0021a3fe22fb57c5a49bfd23af44bb124c196a8b
Date: 2011-11-03 18:50:18
User: brian
Comment:Merged in diskin2 mode for cfg.orc
Timelines: family | ancestors | descendants | both | develop
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2011-11-03
19:23
[8293931a34] Added a very, very bad set of violin samples (user: brian, tags: develop)
18:50
[0021a3fe22] Merged in diskin2 mode for cfg.orc (user: brian, tags: develop)
18:49
[1bc01ba9c9] Closed-Leaf: By magic, fixed problem with not all bass notes playing via diskin2 (user: brian, tags: feature/diskin2)
2011-11-01
18:54
[072fa6ad30] Imported the todo list from MUS306 (user: brian, tags: develop)
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Modified cfg.orc from [e60884eb39] to [c58361434c].

     1      1   sr=44100
     2      2   ksmps=20
     3      3   nchnls=1
     4      4   
     5         -gifn ftgen 105, 0, 524288, -1,  "samples/bass/1.05.wav", 0, 0, 1 ; Middle C
     6         -gifn ftgen 106, 0, 524288, -1,  "samples/bass/1.06.wav", 0, 0, 1 ; Middle C
     7         -gifn ftgen 107, 0, 524288, -1,  "samples/bass/1.07.wav", 0, 0, 1 ; Middle C
     8         -gifn ftgen 108, 0, 524288, -1,  "samples/bass/1.08.wav", 0, 0, 1 ; Middle C
     9         -gifn ftgen 109, 0, 524288, -1,  "samples/bass/1.09.wav", 0, 0, 1 ; Middle C
    10         -gifn ftgen 110, 0, 524288, -1,  "samples/bass/1.10.wav", 0, 0, 1 ; Middle C
    11         -gifn ftgen 111, 0, 524288, -1,  "samples/bass/1.11.wav", 0, 0, 1 ; Middle C
    12         -gifn ftgen 200, 0, 524288, -1,  "samples/bass/2.01.wav", 0, 0, 1 ; Middle C
    13         -gifn ftgen 201, 0, 524288, -1,  "samples/bass/2.02.wav", 0, 0, 1 ; Middle C
    14         -gifn ftgen 202, 0, 524288, -1,  "samples/bass/2.03.wav", 0, 0, 1 ; Middle C
    15         -gifn ftgen 203, 0, 524288, -1,  "samples/bass/2.04.wav", 0, 0, 1 ; Middle C
    16         -gifn ftgen 204, 0, 524288, -1,  "samples/bass/2.05.wav", 0, 0, 1 ; Middle C
    17         -gifn ftgen 206, 0, 524288, -1,  "samples/bass/2.06.wav", 0, 0, 1 ; Middle C
    18         -gifn ftgen 207, 0, 524288, -1,  "samples/bass/2.07.wav", 0, 0, 1 ; Middle C
    19         -gifn ftgen 208, 0, 524288, -1,  "samples/bass/2.08.wav", 0, 0, 1 ; Middle C
    20         -gifn ftgen 209, 0, 524288, -1,  "samples/bass/2.09.wav", 0, 0, 1 ; Middle C
    21         -gifn ftgen 210, 0, 524288, -1,  "samples/bass/2.10.wav", 0, 0, 1 ; Middle C
    22         -gifn ftgen 211, 0, 524288, -1,  "samples/bass/2.11.wav", 0, 0, 1 ; Middle C
    23         -gifn ftgen 300, 0, 524288, -1,  "samples/bass/3.00.wav", 0, 0, 1 ; Middle C
    24         -gifn ftgen 301, 0, 524288, -1,  "samples/bass/3.01.wav", 0, 0, 1 ; Middle C
    25         -gifn ftgen 302, 0, 524288, -1,  "samples/bass/3.02.wav", 0, 0, 1 ; Middle C
    26         -gifn ftgen 303, 0, 524288, -1,  "samples/bass/3.03.wav", 0, 0, 1 ; Middle C
    27         -gifn ftgen 304, 0, 524288, -1,  "samples/bass/3.04.wav", 0, 0, 1 ; Middle C
    28         -gifn ftgen 305, 0, 524288, -1,  "samples/bass/3.05.wav", 0, 0, 1 ; Middle C
    29         -gifn ftgen 306, 0, 524288, -1,  "samples/bass/3.06.wav", 0, 0, 1 ; Middle C
    30         -gifn ftgen 307, 0, 524288, -1,  "samples/bass/3.07.wav", 0, 0, 1 ; Middle C
    31         -gifn ftgen 308, 0, 524288, -1,  "samples/bass/3.08.wav", 0, 0, 1 ; Middle C
    32         -gifn ftgen 309, 0, 524288, -1,  "samples/bass/3.09.wav", 0, 0, 1 ; Middle C
    33         -gifn ftgen 310, 0, 524288, -1,  "samples/bass/3.10.wav", 0, 0, 1 ; Middle C
    34         -gifn ftgen 311, 0, 524288, -1,  "samples/bass/3.11.wav", 0, 0, 1 ; Middle C
    35         -
    36      5   instr 3
    37         -    inum = p5*100
    38         -    asig loscil 1, 1, inum, 1 
            6  +    if p5=105 then
            7  +        asig diskin2 "samples/bass/1.05.wav", 1
            8  +    elseif p5=1.06 then
            9  +        asig diskin2 "samples/bass/1.06.wav", 1
           10  +    elseif p5=1.07 then
           11  +        asig diskin2 "samples/bass/1.07.wav", 1
           12  +    elseif p5=1.08 then
           13  +        asig diskin2 "samples/bass/1.08.wav", 1
           14  +    elseif p5=1.08 then
           15  +        asig diskin2 "samples/bass/1.09.wav", 1
           16  +    elseif p5=1.10 then
           17  +        asig diskin2 "samples/bass/1.10.wav", 1
           18  +    elseif p5=1.11 then
           19  +        asig diskin2 "samples/bass/1.11.wav", 1
           20  +    elseif p5=2.00 then
           21  +        asig diskin2 "samples/bass/2.00.wav", 1
           22  +    elseif p5=2.01 then
           23  +        asig diskin2 "samples/bass/2.01.wav", 1
           24  +    elseif p5=2.02 then
           25  +        asig diskin2 "samples/bass/2.02.wav", 1
           26  +    elseif p5=2.03 then
           27  +        asig diskin2 "samples/bass/2.03.wav", 1
           28  +    elseif p5=2.04 then
           29  +        asig diskin2 "samples/bass/2.04.wav", 1
           30  +    elseif p5=2.05 then
           31  +        asig diskin2 "samples/bass/2.05.wav", 1
           32  +    elseif p5=2.06 then
           33  +        asig diskin2 "samples/bass/2.06.wav", 1
           34  +    elseif p5=2.07 then
           35  +        asig diskin2 "samples/bass/2.07.wav", 1
           36  +    elseif p5=2.08 then
           37  +        asig diskin2 "samples/bass/2.08.wav", 1
           38  +    elseif p5=2.09 then
           39  +        asig diskin2 "samples/bass/2.09.wav", 1
           40  +    elseif p5=2.10 then
           41  +        asig diskin2 "samples/bass/2.10.wav", 1
           42  +    elseif p5=2.11 then
           43  +        asig diskin2 "samples/bass/2.11.wav", 1
           44  +    elseif p5=3.00 then
           45  +        asig diskin2 "samples/bass/3.00.wav", 1
           46  +    elseif p5=3.01 then
           47  +        asig diskin2 "samples/bass/3.01.wav", 1
           48  +    elseif p5=3.02 then
           49  +        asig diskin2 "samples/bass/3.02.wav", 1
           50  +    elseif p5=3.03 then
           51  +        asig diskin2 "samples/bass/3.03.wav", 1
           52  +    elseif p5=3.04 then
           53  +        asig diskin2 "samples/bass/3.04.wav", 1
           54  +    elseif p5=3.05 then
           55  +        asig diskin2 "samples/bass/3.05.wav", 1
           56  +    elseif p5=3.06 then
           57  +        asig diskin2 "samples/bass/3.06.wav", 1
           58  +    elseif p5=3.07 then
           59  +        asig diskin2 "samples/bass/3.07.wav", 1
           60  +    elseif p5=3.08 then
           61  +        asig diskin2 "samples/bass/3.08.wav", 1
           62  +    elseif p5=3.09 then
           63  +        asig diskin2 "samples/bass/3.09.wav", 1
           64  +    elseif p5=3.10 then
           65  +        asig diskin2 "samples/bass/3.10.wav", 1
           66  +    elseif p5=3.11 then
           67  +        asig diskin2 "samples/bass/3.11.wav", 1
           68  +    endif
    39     69       outs asig
    40     70   endin
    41     71   
    42     72   instr 1
    43     73       asound pluck   p4, cpspch(p5), cpspch(p6), p7, p8 p9 p10
    44     74       out asound
    45     75   endin

Modified parse.py from [2afbfc4534] to [a8d0994825].

     4      4   
     5      5   from ply import lex, yacc
     6      6   class Note():
     7      7       def __init__(self, value, duration=1, octave=8):
     8      8           self.value = value
     9      9           self.duration = duration
    10     10           self.octave = octave
    11         -        self.accidental = None
    12     11       def __repr__(self):
    13     12           return "Note %s %s %s" % (self.value, self.duration, self.octave)
    14     13   
    15     14   class Chord():
    16     15       def __init__(self, value, duration=1, chord_type="major", octave=5):
    17     16           self.value = value
    18     17           self.duration = duration
................................................................................
    42     41           "NODE",
    43     42       )
    44     43   
    45     44       t_ignore = " |"
    46     45   
    47     46       t_BASENOTE = r"[A-Ga-g]"
    48     47   #    t_BASENOTE = r"I+V?|VI*|i+v?|vi*"
    49         -    t_ACCIDENTAL = r"\^{1,2}|_{1,2}|="
           48  +    t_ACCIDENTAL = r"\^{1}|_{1}|="
    50     49       t_REST = r"z"
    51     50       t_OCTAVE = r"'+|,+"
    52     51       t_CHORD_TYPE = r"m|7|m7|0|o|\+|mb5|sus|sus4|maj7|mmaj7|7sus4|dim|dim7|7b5|m7b5|6|b6|m6|mb6|46|maj9|9|add9|7b9|m9"
    53     52       t_PAREN = "\(|\)"
    54     53       t_SYNCOPATE = "\+|-"
    55     54       t_NODE = r"\([a-zA-Z0-9_-]+\)"
    56     55   
................................................................................
   120    119           '''
   121    120           note.syncopate = p[2]
   122    121   
   123    122   
   124    123       def p_accidental(p):
   125    124           '''note : ACCIDENTAL note
   126    125           '''
   127         -        p[2].accidental = p[1]
          126  +        if p[1] == "^":
          127  +            p[2].value += "#"
          128  +        else:
          129  +            p[2].value += "b"
   128    130           p[0] = p[2]
   129    131   
   130    132       def p_octave(p):
   131    133           '''note : note OCTAVE
   132    134           '''
   133    135           count = len(p[2])
   134    136           increment_or_decrement = 1 if p[2].startswith("'") else -1
................................................................................
   151    153       def p_node(p):
   152    154           '''node : NODE
   153    155           '''
   154    156           p[0] = tree.Tree(p[1].strip("(").strip(")"))
   155    157   
   156    158   
   157    159       def p_error(p):
          160  +#        import ipdb
          161  +#        ipdb.set_trace()
   158    162           print p
   159    163           raise Exception("Syntax error at '%s' of element type %s" % (p.value, p.type))
   160    164           
   161    165       yacc.yacc()
   162    166   
   163    167       return yacc.parse(score)

Modified spiffyscore.py from [791db3d131] to [d189f30210].

   101    101                           "u": ["C/4 C/4 C/4 C/4"],
   102    102                       },
   103    103                   },
   104    104               },
   105    105           },
   106    106           "sync_test": {
   107    107               "body": {
   108         -                "lead_instr": {  # Instrument 'melody'
   109         -                    "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
   110         -                    "octave": 8,
   111         -                    "duration": 30,
   112         -                    "grammars": {  # Notes for this instrument to use in this piece
   113         -                        "u": ["A/4, B/4, C/4 D/4 (u)", "D/4' D/4' D/4' D/4' (v)"],
   114         -                        "v": ["C/4 C/4 C/4 C/4 (w)"],
   115         -                        "w": ["E/4 F/4 E/4 F/4 (u)"],
   116         -                    },
   117         -                },
          108  +#                "lead_instr": {  # Instrument 'melody'
          109  +#                    "score_line": "i1 %(time)f %(duration)f 7000 %(octave)d.%(note)s %(octave)d.%(note)s 0 6",
          110  +#                    "octave": 8,
          111  +#                    "duration": 30,
          112  +#                    "grammars": {  # Notes for this instrument to use in this piece
          113  +#                        "u": ["A/4, B/4, C/4 D/4 (u)", "D/4' D/4' D/4' D/4' (v)"],
          114  +#                        "v": ["C/4 C/4 C/4 C/4 (w)"],
          115  +#                        "w": ["E/4 F/4 E/4 F/4 (u)"],
          116  +#                    },
          117  +#                },
   118    118                   "follow_instr": {  # Instrument 'melody'
   119    119                       "score_line": "i3 %(time)f %(duration)f 7000 %(octave)d.%(note)s",
   120    120   #                    "sync": "lead_instr",
   121    121                       "octave": 2,
   122    122                       "duration": 30,
   123    123                       "grammars": {  # Notes for this instrument to use in this piece
   124         -                        "u": ["E F G E (u)"],
   125         -                        "v": ["G A A A (e)"],
   126         -                        "e": ["B' A' G' A' (v)"],
          124  +                        "u": ["A ^A B C ^C D ^D E F ^F G ^G"],
          125  +#                        "u": ["E F G E (v)"],
          126  +#                        "v": ["G A A A (e)", "G A A A (v)"],
          127  +#                        "e": ["B A G A (v)"],
   127    128                       },
   128    129                   },
   129    130               },
   130    131           },
   131    132       }
   132    133       print '''f1 0 512 10 1
   133    134   f2 0 8192 10 .24 .64 .88 .76 .06 .5 .34 .08
................................................................................
   253    254               total += n.duration
   254    255       return total
   255    256   
   256    257   
   257    258   def generate_csound_score(score, score_line, t):
   258    259       csound_note_values = {
   259    260           "C": "00",
   260         -        "C#": "01",
          261  +        "C#": "01", "Db": "01",
   261    262           "D": "02",
   262         -        "D#": "03",
          263  +        "D#": "03", "Eb": "03",
   263    264           "E": "04",
   264    265           "F": "05",
   265         -        "F#": "06",
          266  +        "F#": "06", "Gb": "06",
   266    267           "G": "07",
   267         -        "G#": "08",
          268  +        "G#": "08", "Ab": "08",
   268    269           "A": "09",
   269         -        "A#": "10",
          270  +        "A#": "10", "Bb": "10",
   270    271           "B": "11",
   271    272       }
   272    273       csound_score = []
   273    274       for token in score:
   274    275           if isinstance(token, parse.Chord):  # Chords
   275    276               for note in token.chord: 
   276    277                   note = csound_note_values[note]
          278  +                csound_score.append(score_line % {"time": t, "octave": token.octave, "note": note, "duration": token.duration})
   277    279                   csound_score.append(score_line % {"time": t, "octave": token.octave, "note": note, "duration": token.duration})
   278    280           elif isinstance(token, parse.Note):  # Individual notes
   279    281               note = csound_note_values[token.value]
   280    282               csound_score.append(score_line % {"time": t, "octave": token.octave, "note": note, "duration": token.duration})
   281    283           elif isinstance(token, tree.Tree):
   282    284               continue
   283    285           t += token.duration
   284    286       return csound_score
   285    287   
   286    288   
   287    289   if __name__ == "__main__": main() 

Deleted todo.org version [510751b73f].

     1         -* Features [4/10]
     2         -- [X] Top-down composition
     3         -- [ ] Coordinate the melody and rhythm
     4         -- [X] Set maximum song length of movement per instrument
     5         -- [ ] Set minimum song length of movement per instrument
     6         -- [ ] Need to support all chord types
     7         -- [X] Doesn't handle rest notes
     8         -- [ ] Handle full ABC BNF (yeah, right, that's gonna happen...)
     9         -- [X] Set instrument octave in score file
    10         -- [ ] Output score to separate file
    11         -- [ ] Support parallel voices - ensure e.g. a certain chord progression is always
    12         -  accompanied by a certain melody
    13         -- [ ] Syncopation
    14         -- [ ] Sustain option for notes (give score notation a sustain symbol, and use it to set how long after the notes's duration to keep holding. With sustain, the next note's start time isn't done by when the current note ends. 
    15         -
    16         -* Bugs [5/6]
    17         -- [X] TLD resets clock for each movement
    18         -- [X] TLD doesn't accept an ordering for the movements
    19         -- [X] Doesn't handle minor chords    
    20         -- [X] Calculated duration is absolute, not relative to BPM
    21         -- [X] Chords don't respect octaves
    22         -- [ ] Whole notes not held for proper duration
    23         -
    24         -* Structure [1/7]    
    25         -- [ ] Chords should be composed of Notes, not ordinary arrays
    26         -- [ ] There should be a Musical_Phrase object that holds phrases (and sets of
    27         -  phrases), and allows them to nest
    28         -- [ ] Does each instrument need a score parameter if the grammars are non-terminating?
    29         -- [ ] Duration should be in beats, not seconds. This ensures movements don't
    30         -  end in the middle of a phrase.
    31         -- [ ] Generate score with proper generation tools, not this string-replace nonsense
    32         -- [X] Store csound score lines with instruments
    33         -- [ ] Upgrade from simple string substitution for the score to something
    34         -  list-based (maybe). Idea is to keep musical phrases intact in the event of a
    35         -  truncation of the score. Also, if done right, no need for retroactive length
    36         -  parsing- a measure is has a specific length, which is known at
    37         -  generation-time, thus solving the length limit problem.