spiffyscore

Check-in [338933c1a8]
Login
Overview
Comment:Program now generates a single voice with a I IV V pattern and spits out (among other things) the csound-ified score
Timelines: family | ancestors | descendants | both | ply
Files: files | file ages | folders
SHA1: 338933c1a80fab31753af65cc52080657a5f8338
User & Date: spiffytech@gmail.com on 2010-11-12 20:00:57
Other Links: branch diff | manifest | tags
Context
2010-11-12
20:12
Moved all logic into neat, orderly functions. Now prints only the csound score portion. check-in: 6a17d4d36a user: spiffytech@gmail.com tags: ply
20:00
Program now generates a single voice with a I IV V pattern and spits out (among other things) the csound-ified score check-in: 338933c1a8 user: spiffytech@gmail.com tags: ply
2010-11-04
20:07
Generates a score randomly. Too little guarantee of program length (lots of empty or single-phrase strings) check-in: 6bfc2449ff user: spiffytech@gmail.com tags: ply, trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Modified cfg.py from [8ccb7c15cb] to [73244ab69d].

     7      7   random.seed(time.time())
     8      8   
     9      9   grammars = {
    10     10       "u": ["I V I IV u", "e"],
    11     11       "e": [""],
    12     12   }
    13     13   
    14         -score = "u"
           14  +# Generate the scale for the key we're in
           15  +comp_key = "C"
           16  +notes = ["A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"]
           17  +scale = [comp_key]
           18  +pos = notes.index(comp_key)
           19  +progression = [2,2,1,2,2,2,1]
           20  +for p in progression:
           21  +    pos = (pos + p) % 12
           22  +    scale.append(notes[pos])
           23  +
           24  +scale_conversion = {
           25  +    "I": 1,
           26  +    "II": 2,
           27  +    "III": 3,
           28  +    "IV": 4,
           29  +    "V": 5,
           30  +    "VI": 6,
           31  +    "VII": 7,
           32  +    "VIII": 8,
           33  +}
           34  +
           35  +csound_note_values = {
           36  +    "C": "00",
           37  +    "C#": "01",
           38  +    "D": "02",
           39  +    "D#": "03",
           40  +    "E": "04",
           41  +    "F": "05",
           42  +    "F#": "06",
           43  +    "G": "07",
           44  +    "F#": "08",
           45  +    "A": "09",
           46  +    "A#": "10",
           47  +    "B": "11",
           48  +}
           49  +
    15     50   
           51  +score = "u u u"
    16     52   print score
    17     53   while 1:
    18     54       found_substitution = False
    19     55       for key,value in grammars.iteritems():
    20         -        print "key, value =", key, value
    21     56           if score.find(key) != -1:
    22         -            print "here"
    23     57               found_substitution = True
    24     58               while score.find(key) != -1:
    25     59                   score = score.replace(key, random.choice(grammars[key]), 1)
    26     60                   print score
    27         -                time.sleep(.25)
           61  +        #        time.sleep(.25)
    28     62       if found_substitution is False:
    29     63           break
    30         -print score
           64  +
           65  +csound_score = []
           66  +for token in score.split():
           67  +    csound_score.append(scale[scale_conversion[token]-1])
           68  +
           69  +print csound_score
           70  +
           71  +t = 0 
           72  +for token in csound_score:
           73  +    note = csound_note_values[token]
           74  +    print "i2 %f 2 7000 %d.%s %d.%s 0 6" % (t, random.choice([8,9]), note, random.choice([8,9]), note)
           75  +    t += .25

Added test.orc version [a26a1f1a08].

            1  +sr=44100
            2  +ksmps=20
            3  +nchnls=1
            4  +
            5  +instr 1
            6  +    asound oscili p4, cpspch(p5), p6
            7  +    out asound
            8  +endin
            9  +instr 2
           10  +    asound pluck   p4, cpspch(p5), cpspch(p6), p7, p8 p9 p10
           11  +    out asound
           12  +endin
           13  +instr 3
           14  +    asound pluck   p4, cpspch(p5), cpspch(p6), p7, p8 p9 p10
           15  +    out asound
           16  +endin

Added test.sco version [24ff5724a8].

            1  +f1  0   256 10  1 0 3   ; sine wave function table
            2  +
            3  +i2 0.000000 2 7000 9.00 8.00 0 6
            4  +i2 0.250000 2 7000 9.07 9.07 0 6
            5  +i2 0.500000 2 7000 8.00 9.00 0 6
            6  +i2 0.750000 2 7000 9.05 8.05 0 6
            7  +i2 1.000000 2 7000 9.00 8.00 0 6
            8  +i2 1.250000 2 7000 9.07 9.07 0 6
            9  +i2 1.500000 2 7000 9.00 9.00 0 6
           10  +i2 1.750000 2 7000 9.05 8.05 0 6