cello_talea = rhythm('h q. h h e e q. e e e e q. e e h', tempo=80) cello_color = keynum('c6 e d f# bf5') if __name__ == '__main__': # It's good practice to add any metadata such as tempo, midi instrument # assignments, micro tuning, etc. to track 0 in your midi file. t0 = MidiSeq.metaseq(ins={0: AcousticGrandPiano, 1: Violin}) # Track 1 will hold the composition. t1 = MidiSeq() # Create a scheduler and give it t1 as its output object.[84, 88, 86, 90, 82] q = Scheduler(t1) # Create the piano and cello composers. piano = brush(q, len=len(piano_talea) * 8 + 14, rhy=piano_talea, key=piano_color, chan=0) cello = brush(q, len=len(cello_talea) * 6, rhy=cello_talea, amp=.2, key=cello_color, chan=1) # Start our composers in the scheduler, this creates the composition. q.compose([[0, piano], [5.5, cello]]) # Write a midi file with our track data. f = MidiFile("messiaen.mid", [t0, t1]).write() # To automatially play demos use setmidiplayer() to assign a shell # command that will play midi files on your computer. Example: # setmidiplayer("fluidsynth -iq -g1 /usr/local/sf/MuseScore_General.sf2")
arf = [0, 3, 7, 0, 3, 7, 0, 3, 7, 0, 3, 7, 0, 3, 7, 0] if __name__ == '__main__': # It's good practice to add any metadata such as tempo, midi instrument # assignments, micro tuning, etc. to track 0 in your midi file. track0 = MidiFile.metatrack(microdivs=4) # Track 1 holds the composition. track1 = Seq() # Create a score and give it tr1 to hold the score event data. score = Score(out=track1) # Create the composition. score.compose([ brush(score, length=1000, pitch=pphase, rhythm=1 / 16, duration=1, amplitude=0.75, instrument=9, microdivs=4), brush(score, length=828, pitch=pphase, rhythm=1 / 32, duration=7, amplitude=0.75, instrument=1, microdivs=4), brush(score, length=1000, pitch=arf, rhythm=1 / 8,
band=[3.8, 7.1, 9.3, [7.1, 12]], end=15, tuning=tuning) s6 = spray(q, key=24, dur=5, rhy=[1, 1, .5, 2, 2], amp=A(.5), band=scale2, end=55, tuning=tuning) s7 = brush(q, key=[86.2, 93.3, 87.8, 91.1], dur=4, rhy=[.25, .25, .5], amp=A(.3), end=50, tuning=tuning) s8 = brush(q, key=[86.2, [93.3, 98.8], 87.8, 91.1], dur=4, rhy=[.25, .25, .25, .25, .5], amp=A(.25), end=10, tuning=tuning) s9 = brush(q, key=[81.3, 74.4, 78.6, 72], dur=2, rhy=[.5, .25, .25], amp=A(.25),
duration=3, rhythm=[.75, .25, .5], amplitude=A([.6, .5, .55]), band=[3.8, 7.1, 9.3, [7.1, 12]], end=15) s6 = spray(score, pitch=24, duration=5, rhythm=[1, 1, .5, 2, 2], amplitude=A(.5), band=scale2, end=55) s7 = brush(score, pitch=[86.2, 93.3, 87.8, 91.1], duration=4, rhythm=[.25, .25, .5], amplitude=A(.3), end=50) s8 = brush(score, pitch=[86.2, [93.3, 98.8], 87.8, 91.1], duration=4, rhythm=[.25, .25, .25, .25, .5], amplitude=A(.25), end=10) s9 = brush(score, pitch=[81.3, 74.4, 78.6, 72], duration=2, rhythm=[.5, .25, .25], amplitude=A(.25), end=50) s10 = brush(score,
cello_talea = rhythm('h q. h h e e q. e e e e q. e e h', tempo=80) cello_color = keynum('c6 e d f# bf5') if __name__ == '__main__': # It's good practice to add any metadata such as tempo, midi instrument # assignments, micro tuning, etc. to track 0 in your midi file. track0 = MidiFile.metatrack(ins={0: AcousticGrandPiano, 1: Violin}) # Track 1 will hold the composition. track1 = Seq() # Create a score and give it tr1 to hold the score event data. score = Score(out=track1) # Create the piano and cello composers. piano = brush(score, length=len(piano_talea) * 8 + 14, rhythm=piano_talea, pitch=piano_color, instrument=0) cello = brush(score, length=len(cello_talea) * 6, rhythm=cello_talea, amplitude=.2, pitch=cello_color, instrument=1) # Create the composition. score.compose([[0, piano], [5.5, cello]]) # Write the tracks to a midi file in the current directory. file = MidiFile("messiaen.mid", [track0, track1]).write() print(f"Wrote '{file.pathname}'.") # To automatially play demos use setmidiplayer() and playfile().