"fs4 a b ds5 es gs", "f4 bf d5 e g", "e4 af cs5 d", "d4 g b cs5 e", "cs4 f bf b f5", "b3 e4 af bf", "af3 cs4 f g", "gf3 cf4 ef f" ]) 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.
else: q.compose(motive2(q, between(lowoctave, highoctave), limit, chan)) yield qtime(i, numtimes, hiwait, lowwait, .2) # 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: Marimba, 2: OrchestralHarp }) # Track 1 will hold the composition. t1 = MidiSeq() # Create a scheduler and give it t1 as its output object. q = Scheduler(t1) #play = motive1(q, 5, 4, 0) #play = motive2(q, 5,5,1) #play = gesture1(q, 10, .5, 0) #play = gesture2(q, 10, .5, 5, 0) #play = gesture3(q, 20, .5, 5, 0, 3, .2) #play = gesture4(q, 30, 2, 7, 11, 0, 1.6,.2) # The gesture to play play = [ gesture4(q, 60, 2, 7, 11, 0, 1.0, .2), gesture4(q, 40, 5, 7, 11, 1, 1.6, .2), gesture4(q, 34, 3, 6, 11, 2, 2.0, .2) ] # Start our composer in the scheduler, this creates the composition.
random.shuffle(keys) sub = rhy / len(keys) if ismel else 0 print("melody:" if ismel else "chord:", "time=", q.now, "dur=", rhy, "keys=", keys) for i, k in enumerate(keys): m = MidiNote(time=q.now + (i * sub), dur=dur, key=k, amp=amp) q.out.addevent(m) yield rhy # 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() # Track 1 will hold the composition. t1 = MidiSeq() # Create a scheduler and give it t1 as its output object. q = Scheduler(t1) # Start our composer in the scheduler, this creates the composition. # q.compose(fm_chords(q, 12, 60, 1.0, 2.0, 2.0, 4.0, .8)) q.compose(fm_improv(q, contour, 1)) # Write a midi file with our track data. f = MidiFile("fm.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") print(f"Wrote '{f.pathname}'.") #playfile(f.pathname) csoundac_score_node = CsoundAC.ScoreNode()
if high: q.compose([ahead, flute(q, melody, ahead)]) q.compose([ahead * 2, harp(q, melody, rhy / 4)]) elif (rhy == 3 / 4): q.compose([1 / 2, cello(q, melody)]) yield rhy # It's good practice to add any metadata such as tempo, midi instrument # assignments, micro tuning, etc. to track 0 in your midi file. inst = {0: Flute, 1: Clarinet, 2: Cello, 3: OrchestralHarp} t0 = MidiSeq.metaseq(ins=inst) # Track 1 will hold the composition. t1 = MidiSeq() # Create a scheduler and give it t1 as its output object. q = Scheduler(t1) # Start our composer in the scheduler, this creates the composition. q.compose(ghosts(q)) # Write a midi file with our track data. f = MidiFile("ghosts.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") print(f"Wrote '{f.pathname}'.") csoundac_score_node = CsoundAC.ScoreNode() csoundac_score = csoundac_score_node.getScore() musx_csoundac.to_csoundac_score(f, csoundac_score) print("Generated:") print(csoundac_score.getCsoundScore())
voiceleading_node.chord(chord, q.now) print(" progression at: {:9.4f} to: {}".format(q.now, chord.eOP().name())) if (levels > 1): # sprout melody on tone at next level q.compose(sierpinski(q, (k + trans), shape, trans, levels - 1, dur / num, amp, highest_level)) yield dur # 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() # Track 1 will hold the composition. t1 = MidiSeq() # Create a scheduler and give it t1 as its output object. q = Scheduler(t1) # Start our composer in the scheduler, this creates the composition. # Specify levels and melody length with care! The number of events # sierpinski generates is exponentially related to the length of the # melody and the number of levels. For example the first compose() # generates 120 events, the second 726, and the third 2728! # q.compose(sierpinski(q, keynum('a0'), [0, 7, 5], 12, 4, 3, .5)) # q.compose(sierpinski(q, keynum('a0'), [0, 7, 5], 8, 5, 7, .5)) levels = 5 # def sierpinski(q, tone, shape, trans, levels, dur, amp, highest_level): q.compose(sierpinski(q, keynum('a0'), [1, -3, 3, 6, -1], 13, levels, 150, .5, levels)) # Write a midi file with our track data. f = MidiFile("sierpinski.mid", [t0, t1]).write() # To automatially play demos use setmidiplayer() to assign a shell # command that will play midi files on your computer. Example:
# Amplitude scaler to adapt to different sound fonts. this is for fluidsynth def A(a): return ([s * 1.35 for s in a] if type(a) is list else a * 1.5) # Microtonal divisions of the semitone. 2 is quartertone (50 cents) etc. tuning = 7 # 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={i: Vibraphone for i in range(tuning)}, tuning=tuning) # Track 1 holds the composition. t1 = MidiSeq() # Create a scheduler and give it t1 as its output object. q = Scheduler(t1) # The sections of the piece s1 = spray(q, key=48, dur=3, rhy=[1, .5], amp=A([.3, .35, .4]), band=scale1, end=40, tuning=tuning) s2 = spray(q, key=48, dur=3, rhy=[1, .5], amp=A([.4, .45, .5]), band=scale3,
knum = next(pattern) # Create a midi note to play it. note = MidiNote(time=q.now, dur=rate, key=knum, amp=.9) # Add the midi note to the output midi sequence. q.out.addevent(note) # Return the amount of time until this composer runs again. yield rate # 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() # Track 1 will hold the composition. t1 = MidiSeq() # Create a scheduler and give it t1 as its output object. q = Scheduler(t1) # Convert Reich's notes to a list of midi key numbers to phase. keys = keynum("e4 f# b c#5 d f#4 e c#5 b4 f# d5 c#") # Create two composer generators that run at slightly different # rates and cause the phase effect. pianos = [piano_phase(q, 180, keys, .167), piano_phase(q, 180, keys, .170)] # Start our composer in the scheduler, this creates the composition. q.compose(pianos) # Write the seq to a midi file in the current directory. f = MidiFile("reich.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") print(f"Wrote '{f.pathname}'.") csoundac_score_node = CsoundAC.ScoreNode()
ampl = between(.5, 1) q.compose(jazz_piano(q, root, tempo, ampl)) q.compose(jazz_cymbals(q, tempo, ampl)) q.compose(jazz_high_hat(q, tempo, ampl)) q.compose(jazz_drums(q, tempo, ampl)) q.compose(jazz_bass(q, root - 12, tempo, ampl)) yield intempo(4, tempo) # 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: AcousticBass}) # Track 1 will hold the composition. t1 = MidiSeq() # Create a scheduler and give it t1 as its output object. q = Scheduler(t1) # c=[] # for t in range(0, 15, 2): # t -> 0 2 4 6 8 10 12 14 # c += [[t, jazz_high_hat(q, 120, .9)], # [t, jazz_drums(q, 120, .9)], # [t, jazz_cymbals(q, 120, .9)], # [t, jazz_piano(q, 58, 120, .9)], # [t, jazz_bass(q, 46, 120, .9)] # ] q.compose(jazz_combo(q, 48, 120)) # Write a midi file with our track data. f = MidiFile("jazz.mid", [t0, t1]).write() # To automatially play demos use setmidiplayer() to assign a shell # command that will play midi files on your computer. Example:
q.out.addevent(m) if (levels > 1): # sprout melody on tone at next level q.compose( sierpinski(q, (k + trans), shape, trans, levels - 1, dur / num, amp)) yield dur # 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() # Track 1 will hold the composition. t1 = MidiSeq() # Create a scheduler and give it t1 as its output object. q = Scheduler(t1) # Start our composer in the scheduler, this creates the composition. # Specify levels and melody length with care! The number of events # sierpinski generates is exponentially related to the length of the # melody and the number of levels. For example the first compose() # generates 120 events, the second 726, and the third 2728! # q.compose(sierpinski(q, keynum('a0'), [0, 7, 5], 12, 4, 3, .5)) # q.compose(sierpinski(q, keynum('a0'), [0, 7, 5], 8, 5, 7, .5)) q.compose(sierpinski(q, keynum('a0'), [0, -1, 2, 13], 12, 5, 24, .5)) # Write a midi file with our track data. f = MidiFile("sierpinski.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") print(f"Wrote '{f.pathname}'.")
for low, high in zip(minkeys, maxkeys): # get the section's duration secdur = next(pat) # sprout the next section q.compose(register(q, rhy, secdur, low, high, .4)) # wait till end of section yield secdur # 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: Harpsichord}) # Track 1 will hold the composition. t1 = MidiSeq() # Create a scheduler and give it t1 as its output object. q = Scheduler(t1) # Lower bound on keynum choices minkeys = [ 60, 59, 58, 57, 56, 55, 54, 53, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 89 ] # Upper bound on keynum choices maxkeys = [ 62, 63, 64, 65, 66, 67, 68, 69, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 71, 72, 73, 74, 76, 79, 83, 86, 88, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89 ] # Length of sections seclens = [.5, 1, 1.5, 2, 2.5] # Speed of rhythm
from musx.paint import spray from musx.midi import MidiSeq, MidiFile from musx.ran import pick from musx.tools import playfile, setmidiplayer from musx.scheduler import Scheduler # The blues scale. blues = [0, 3, 5, 6, 7, 10, 12] # 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() # Track 1 will hold the composition. t1 = MidiSeq() # Create a scheduler and give it t1 as its output object. q = Scheduler(t1) # The sections of the piece s1 = spray(q, dur=.2, rhy=.2, band=[0, 3, 5], key=30, amp=0.35, end=36) s2 = spray(q, dur=.2, rhy=[-.2, -.4, .2, .2], band=[3, 7, 6], key=pick(30, 42), amp=0.5, end=25) s3 = spray(q, dur=.2, rhy=[-.2, .2, .2], band=blues, key=pick(42, 54), chan=2,
for r in next(rhythms): k = keynum(next(melody)) + (shift*12) r = intempo(r, 200) m = MidiNote(time=q.now+n, dur=r, key=k, amp=.5, chan=chan) q.out.addevent(m) n += r yield n # 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: StringEnsemble1}) # Track 1 will hold the composition. t1 = MidiSeq() # Create a scheduler and give it t1 as its output object. q = Scheduler(t1) # Compose a 4 voice texture with these octave transposition factors. voices = [-1, 0, 1, 2] composers = [composer_stephen_foster(q, 25, t) for t in voices] # Start our composers in the scheduler, this creates the composition. q.compose(composers) # Write a midi file with our track data. f = MidiFile("foster.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") print(f"Wrote '{f.pathname}'.") csoundac_score_node = CsoundAC.ScoreNode() csoundac_score = csoundac_score_node.getScore() musx_csoundac.to_csoundac_score(f, csoundac_score)