<s> from config import * <EOL> import midi <EOL> def instrument_num ( instrument ) : <EOL> """<STR_LIT>""" <EOL> for key , name in GUS_INSTR_PATCHES . items ( ) : <EOL> if name == instrument : <EOL> return key <EOL> raise Exception ( '<STR_LIT>' % instrument ) <EOL> pattern = midi . Pattern ( resolution = <NUM_LIT> ) <EOL> track = midi . Track ( ) <EOL> track . append ( midi . ControlChangeEvent ( tick = <NUM_LIT:0> , channel = <NUM_LIT:9> , data = [ <NUM_LIT:7> , <NUM_LIT> ] ) ) <EOL> time = <NUM_LIT> <EOL> for group in SIMILAR_GROUPS : <EOL> print "<STR_LIT>" <EOL> empty = True <EOL> for instrument in group : <EOL> inum = instrument_num ( instrument ) <EOL> if inum <= <NUM_LIT> : <EOL> print "<STR_LIT>" % ( instrument , inum ) <EOL> track . extend ( [ <EOL> midi . ProgramChangeEvent ( tick = time , channel = <NUM_LIT:0> , <EOL> data = [ inum ] ) , <EOL> midi . NoteOnEvent ( tick = <NUM_LIT:0> , channel = <NUM_LIT:0> , <EOL> velocity = <NUM_LIT> , pitch = midi . A_3 ) , <EOL> midi . NoteOffEvent ( tick = <NUM_LIT:50> , channel = <NUM_LIT:0> , <EOL> velocity = <NUM_LIT> , pitch = midi . A_3 ) , <EOL> midi . NoteOnEvent ( tick = <NUM_LIT:0> , channel = <NUM_LIT:0> , <EOL> velocity = <NUM_LIT> , pitch = midi . B_3 ) , <EOL> midi . NoteOffEvent ( tick = <NUM_LIT:50> , channel = <NUM_LIT:0> , <EOL> velocity = <NUM_LIT> , pitch = midi . B_3 ) , <EOL> ] ) <EOL> else : <EOL> print "<STR_LIT>" % ( instrument , inum - <NUM_LIT> ) <EOL> track . extend ( [ <EOL> midi . NoteOnEvent ( tick = time , channel = <NUM_LIT:9> , <EOL> velocity = <NUM_LIT> , pitch = inum - <NUM_LIT> ) , <EOL> midi . NoteOffEvent ( tick = <NUM_LIT:50> , channel = <NUM_LIT:9> , <EOL> pitch = inum - <NUM_LIT> ) , <EOL> midi . NoteOnEvent ( tick = <NUM_LIT:0> , channel = <NUM_LIT:9> , <EOL> velocity = <NUM_LIT> , pitch = inum - <NUM_LIT> ) , <EOL> midi . NoteOffEvent ( tick = <NUM_LIT:50> , channel = <NUM_LIT:9> , <EOL> pitch = inum - <NUM_LIT> ) , <EOL> ] ) <EOL> empty = False <EOL> time = <NUM_LIT:100> <EOL> if not empty : <EOL> time = <NUM_LIT> <EOL> for i in range ( <NUM_LIT:4> ) : <EOL> track . extend ( [ <EOL> midi . NoteOnEvent ( tick = <NUM_LIT:20> , channel = <NUM_LIT:9> , velocity = <NUM_LIT> , pitch = <NUM_LIT> ) , <EOL> midi . NoteOffEvent ( tick = <NUM_LIT:20> , channel = <NUM_LIT:9> , pitch = <NUM_LIT> ) , <EOL> ] ) <EOL> track . append ( midi . EndOfTrackEvent ( tick = <NUM_LIT:1> ) ) <EOL> pattern . append ( track ) <EOL> midi . write_midifile ( "<STR_LIT>" , pattern ) </s>
