for line in f.readlines(): chords.append(parse_line(line)) for chord in chords: notes = prepareChord(chord) instruments = ['oboe', 'violin', 'viola', 'cello'] time = 3. bundles = [] while len(instruments) > 0 and len(notes) > 0: note, notes = oneOf(notes) possible_instruments = intersect(instruments, check(note)) instrument, instruments = oneOf(possible_instruments) note_used = note[0] if one(range(100)) > 10: note_used = round(note_used) bundles.append(perc(note_used, time, instrument)) oscore = o.message('/score', bundles) file_prefix = prefix() oprefix = o.message('/prefix', file_prefix) otime = o.message('/time', time + 1.) result = o.bundle(messages = [oscore, otime, oprefix]) f = open('./scores/' + file_prefix + '_percscore.txt', 'w') f.write(str(result)) f.close() send(result) print(result) print('-' * 100) sleep(time + 4.) print("Finished...")
freqs, amps = split(chord) return collect(ftom(freqs), amps) chords = [] for i in range(0, 30): with open('../../solutions/5peak' + str(i) + '.txt') as f: for line in f.readlines(): chords.append(parse_line(line)) for chord in chords: notes = prepareChord(chord) instruments = ['violin', 'viola', 'cello'] time = abs(window(4.)) + 1. note, notes = oneOf(notes) bundles = [perc(note[0], time, 'oboe')] while len(instruments) > 0 and len(notes) > 0: note, notes = oneOf(notes) possible_instruments = intersect(instruments, check(note)) instrument = one(possible_instruments) instruments.remove(instrument) voiceTime = window(time) * .2 + time note_used = note[0] if one([0, 1]) is 0: note_used = round(note_used) bundles.append(moans(note_used, voiceTime, instrument)) oscore = o.message('/score', bundles) file_prefix = prefix() oprefix = o.message('/prefix', file_prefix) otime = o.message('/time', time + 1.)