midiGenerator = MidiGenerator() sc = HARMONIC_MINOR_SCALE scale = [[x] for x in buildScale(sc, 48, 80)] l = 3 pos = 0 for k in range(2): for i in range(16): midiGenerator.add_track( 0, pos, beat=LoopingArray([(0.5, 1.0), (0.5, 1.0), (1.0, 2.0), (0.5, 0.5)]), notes=LoopingArray( scale, functioniterator=[ ('add', StaticIterator(value=1)), ('mult', LoopingArray([5 + (i), 3 + (i * 2), 2 + (i * 3)])) ], id='notes'), velocities=LoopingArray([100, 90, 110, 70, 80]), length=l) pos += l for j in range(8): for i in range(1): midiGenerator.add_track( 0, pos, beat=LoopingArray([(0.5, 1.0), (0.5, 1.0), (1.0, 2.0), (0.5, 0.5)]),
'Bass track': { 'notearrays': [ { 'beat': LoopingArray([(0.25,1.0)]), 'notearray': LoopingArray([[x] for x in scale], functioniterator=[ ('add',LoopingArray([1,2,3,4,5])), ('dec',LoopingArray([0,0,1,2])), ]), 'velocities': LoopingArray([x for x in range(100,110)], functioniterator=[ ('add',LoopingArray([1,2,4,1,3])), ('dec',LoopingArray([0,7,3,2])), ]) } ], }, } for track in tracks: print 'processing %s' % track notearrays = tracks[track]['notearrays'] for n in notearrays: beat = n['beat'] notearray = n['notearray'] velocities = n['velocities'] midiGenerator.add_track(0,0,beat=beat,notes=notearray,velocities=velocities,length=256) midiGenerator.write()
tracks = { 'running notes': { 'notearrays': [ { 'beat': LoopingArray([(1,1),(0.5,0.5),(0.25,0.25),(1.5,1.5)]), 'notearray': LoopingArray([[scale[(base+(x*2)) % len(scale)]] for x in range(5)]), 'velocities': LoopingArray([100,90,110,70,80]) }, { 'beat': LoopingArray([(0.5,0.5),(0.25,0.25),(2.0,2.0)]), 'notearray': LoopingArray([[scale[(base+(x*3)) % len(scale)]] for x in range(9)]), 'velocities': LoopingArray([90,91,49,110,93,49,69]) }, ], } } i = 0 for track in tracks: print 'processing %s' % track notearrays = tracks[track]['notearrays'] for n in notearrays: beat = n['beat'] notearray = n['notearray'] velocities = n['velocities'] midiGenerator.add_track(i,pos,beat=beat,notes=notearray,velocities=velocities,length=128) pos+=8 midiGenerator.write()
from midiutil.TrackGen import LoopingArray, StaticIterator from midiutil.MidiGenerator import MidiGenerator midiGenerator = MidiGenerator() l = 3 pos = 0 for mod in range(4): for notepattern in [[0,2,7,8],[2,5,7,10],[0,3,7,8],[3,5,7,8,10],]: scale = reduce(lambda x,y:x+y,[[y+(12*x)+48 for y in notepattern] for x in range (3)]) midiGenerator.add_track (0, pos, beat = LoopingArray([(0.5,1.0)]), notes = LoopingArray([[x] for x in scale], functioniterator = [ ('add', StaticIterator(value=1)), ('mult', LoopingArray([1,2,1+mod])) ], id='notes'), velocities = LoopingArray([100,90,110,70,80]), length = l) pos+=l for notepattern in [[5,2,7,8],[7,5,7,10],[8,3,7,8],[11,5,7,3],]: scale = reduce(lambda x,y:x+y,[[y+(12*x)+48 for y in notepattern] for x in range (3)]) midiGenerator.add_track (0, pos, beat = LoopingArray([(0.5,1.0)]), notes = LoopingArray([[x] for x in scale], functioniterator = [ ('add', StaticIterator(value=1)), ('mult', LoopingArray([1,2,1+mod])) ], id='notes'),
}, { 'beat': LoopingArray([(2, 2), (1, 1)]), 'notearray': LoopingArray([[scale[(base + (x * 2)) % len(scale)]] for x in range(13)]), 'velocities': LoopingArray([85, 91, 102, 99, 87, 11, 76, 44, 59]) }], } } i = 0 for track in tracks: print 'processing %s' % track notearrays = tracks[track]['notearrays'] for n in notearrays: beat = n['beat'] notearray = n['notearray'] velocities = n['velocities'] midiGenerator.add_track(i, pos, beat=beat, notes=notearray, velocities=velocities, length=128) pos += 8 midiGenerator.write()
sc = HARMONIC_MINOR_SCALE playable_mscale = [[x] for x in buildScale(sc, 48, 80)] pos = 0 for y in range(128): beat = LoopingArray([(0.25, 0.25)]) notes = LoopingIndexedArray(playable_mscale, [[z + (y**z)] for z in range(8)]) velocities = LoopingArray([127]) length = 4 midiGenerator.add_track(0, pos, beat=beat, notes=notes, velocities=velocities, length=length) notes = LoopingIndexedArray([[x] for x in buildScale(sc, 48 - 12, 80 - 12)], [1 + (y**1)]) midiGenerator.add_track(1, pos, beat=LoopingArray([(4, 4)]), notes=notes, velocities=velocities, length=length) pos += length
import sys sys.path.append("../") from midiutil.MidiGenerator import MidiGenerator from midiutil.Scales import MINOR, buildScale from midiutil.TrackGen import LoopingIncrementalIndexedArray, LoopingArray midiGenerator = MidiGenerator(tempo=105) sc = MINOR mscale = buildScale(sc, 48, 80) notes = LoopingArray([ [mscale[x] for x in [0, 2, 4, 6]], # chord 1 [mscale[x] for x in [3, 5, 7, 9]], # chord 2 [mscale[x] for x in [5, 7, 11]] # chord 3 ], functioniterator=[('add', LoopingArray([1, 1, 2]))]) chord_beats = LoopingArray([(4, 4), (2, 2)]) notes_beats = LoopingArray([(0.25, 0.25)]) velocities = LoopingArray([120, 120]) note_skip = LoopingArray([0, 1, 2, 3, 1], functioniterator=[('add', LoopingArray([1, 2]))]) midiGenerator.add_arpeggio(0, 0, chords_beat=chord_beats, notes_beat=notes_beats, chords=notes, velocities=velocities, note_skip=note_skip, length=32) notes = LoopingIncrementalIndexedArray([[x] for x in buildScale(sc, 36, 48)], [1, 1, 2, -1, 2]) beats = LoopingArray([(4, 4)]) velocities = LoopingArray([110, 110]) midiGenerator.add_track (1, 0, beat=beats, notes=notes, velocities=velocities, length=32) midiGenerator.write()
from midiutil.Scales import * midiGenerator = MidiGenerator() sc = HARMONIC_MINOR_SCALE scale = [[x] for x in buildScale(sc, 48, 80)] l = 3 pos = 0 for k in range(2): for i in range(16): midiGenerator.add_track (0, pos, beat = LoopingArray([(0.5,1.0), (0.5,1.0), (1.0,2.0), (0.5,0.5)]), notes = LoopingArray(scale, functioniterator = [ ('add', StaticIterator(value=1)), ('mult', LoopingArray([5+(i),3+(i*2),2+(i*3)])) ], id='notes'), velocities = LoopingArray([100,90,110,70,80]), length = l) pos+=l for j in range(8): for i in range(1): midiGenerator.add_track (0, pos, beat = LoopingArray([(0.5,1.0), (0.5,1.0), (1.0,2.0), (0.5,0.5)]), notes = LoopingArray(scale[5-j:], functioniterator = [ ('add', StaticIterator(value=2)), ('mult', LoopingArray([5+(i),3+(i*2),2+(i*3)])) ], id='notes'),
for mod in range(4): for notepattern in [ [0, 2, 7, 8], [2, 5, 7, 10], [0, 3, 7, 8], [3, 5, 7, 8, 10], ]: scale = reduce(lambda x, y: x + y, [[y + (12 * x) + 48 for y in notepattern] for x in range(3)]) midiGenerator.add_track( 0, pos, beat=LoopingArray([(0.5, 1.0)]), notes=LoopingArray([[x] for x in scale], functioniterator=[ ('add', StaticIterator(value=1)), ('mult', LoopingArray([1, 2, 1 + mod])) ], id='notes'), velocities=LoopingArray([100, 90, 110, 70, 80]), length=l) pos += l for notepattern in [ [5, 2, 7, 8], [7, 5, 7, 10], [8, 3, 7, 8], [11, 5, 7, 3], ]: scale = reduce(lambda x, y: x + y, [[y + (12 * x) + 48 for y in notepattern]