Skip to content

Instantly share code, notes, and snippets.

@skyl skyl/defaultdikt.py
Created Apr 27, 2012

Embed
What would you like to do?
defaultdict musical score scratchpad idea
"""
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()
@skyl

This comment has been minimized.

Copy link
Owner Author

skyl commented Apr 27, 2012

Upon further review,

timing = (
   (1, 16),
   (1, 16),
   (1, 8),
   (1, 4),
   (1, 4),
   (1, 32),
   (1, 32),
   (1, 32),
   (1, 32),
   (1, 8),
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.