Created
April 27, 2012 13:29
-
-
Save skyl/2509212 to your computer and use it in GitHub Desktop.
defaultdict musical score scratchpad idea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
1 2 3 4 | |
tekaTa Ta Ka tktkTA | |
16 16 8 4 4 32 32 32 32 8 | |
0 6 12 24 48 72 75 78 81 84 | |
""" | |
import random | |
from collections import defaultdict | |
from functools import partial | |
randintlist = lambda low, high, num: [random.randint(low, high) | |
for i in range(num)] | |
randnotes = partial(randintlist, 30, 50) | |
randvels = partial(randintlist, 60, 100) | |
score = defaultdict(lambda: None) | |
quarter = 24 | |
eighth = 12 | |
sixteenth = 6 | |
thirtysecond = 3 | |
tick = 0 | |
#1 | |
score[tick] = (randnotes(2), randvels(2), sixteenth) | |
tick += sixteenth | |
score[tick] = (randnotes(1), randvels(1), sixteenth) | |
tick += sixteenth | |
score[tick] = (randnotes(3), randvels(3), eighth) | |
tick += eighth | |
#2 | |
score[tick] = (randnotes(3), randvels(3), quarter) | |
tick += quarter | |
#3 | |
score[tick] = (randnotes(3), randvels(3), quarter) | |
tick += quarter | |
#4 | |
score[tick] = (randnotes(1), randvels(1), thirtysecond) | |
tick += thirtysecond | |
score[tick] = (randnotes(1), randvels(1), thirtysecond) | |
tick += thirtysecond | |
score[tick] = (randnotes(1), randvels(1), thirtysecond) | |
tick += thirtysecond | |
score[tick] = (randnotes(1), randvels(1), thirtysecond) | |
tick += thirtysecond | |
score[tick] = (randnotes(2), randvels(2), eighth) | |
tick += eighth | |
import IPython | |
IPython.embed() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Upon further review,
timing = (
(1, 16),
(1, 16),
(1, 8),
(1, 4),
(1, 4),
(1, 32),
(1, 32),
(1, 32),
(1, 32),
(1, 8),
)