# 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()
csoundac_score = csoundac_score_node.getScore()
musx_csoundac.to_csoundac_score(f, csoundac_score)

print("Generated:")
print(csoundac_score.getCsoundScore())

orc = '''
    # 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")
    print(f"Wrote '{f.pathname}'.")
    #playfile(f.pathname)

    # Now the Csound stuff.

    orc = '''

sr = 48000
ksmps = 128
nchnls = 2
0dbfs = 1
示例#3
0
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:
#   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())

orc = '''
sr = 48000
ksmps = 128
nchnls = 2
示例#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.
q.compose(play)
# Write a midi file with our track data.
f = MidiFile("gestures.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())

orc = '''
sr = 48000
ksmps = 128
# 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()
csoundac_score = csoundac_score_node.getScore()
musx_csoundac.to_csoundac_score(f, csoundac_score)

print("Generated:")
print(csoundac_score.getCsoundScore())

orc = '''
sr = 48000
ksmps = 128
示例#6
0
            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())

orc = '''
sr = 48000
ksmps = 128
示例#7
0
                ],
                amp=A(.35),
                band=scale3,
                end=32,
                tuning=tuning)
    s14 = brush(q,
                key=[[36, 42.6, 43.1, 48, 51.8, 57.3, 63.8, 86.4],
                     [12, 24, 31.1, 36, 42.6]],
                len=2,
                dur=8,
                rhy=[4, 8],
                amp=A(.25),
                tuning=tuning)
    # Start our composers in the scheduler, this creates the composition.
    q.compose([[0, s1], [40, s2], [10, s3], [40, s4], [50, s5], [20, s6],
               [65, s7], [80, s8], [73, s9], [79, s10], [121, s11], [121, s12],
               [129, s13], [162, s14]])
    # Write a midi file with our track data.
    f = MidiFile("gamelan.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}'.")
    tuning_system(f)
    #playfile(f.pathname)
    csoundac_score = CsoundAC.Score()
    to_csoundac_score(f, csoundac_score)

    print("Generated:")
    print(csoundac_score.getCsoundScore(0))
示例#8
0
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:
#   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())

orc = '''
sr = 48000
ksmps = 128
    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
rate = .075
# Start our composer in the scheduler, this creates the composition.
q.compose(continuum(q, rate, minkeys, maxkeys, seclens))
# Write a midi file with our track data.
f = MidiFile("continuum.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}'.")

# Plot the keynum range of the composition if matplotlib is installed.
try:
    import matplotlib.pyplot as plt
except:
    print(
        "Sorry, can't show you the envelopes because matplotlib is not installed."
    )
else:
    p1x, p1y = [x for x in range(len(minkeys))], [y for y in minkeys]
    plt.plot(p1x, p1y)
           amp=0.8,
           end=10)
s7 = spray(q,
           dur=.2,
           rhy=[-.2, .2, .2],
           band=blues,
           key=pick(42, 54),
           chan=2,
           end=10)
s8 = spray(q, dur=.2, rhy=[-.6, .4, .4], band=blues, key=66, amp=0.6, end=10)
s9 = spray(q, dur=.2, rhy=.2, band=blues, key=66, amp=0.4, end=6)
# Start our composer in the scheduler, this creates the composition.
q.compose([[0, s1], [5, s2], [10, s3], [15, s4], [37, s5], [37, s6], [37, s7],
           [37, s8], [47, s9]])
# Write a midi file with our track data.
f = MidiFile("blues.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()
csoundac_score = csoundac_score_node.getScore()
musx_csoundac.to_csoundac_score(f, csoundac_score)

print("Generated:")
print(csoundac_score.getCsoundScore())

orc = '''
sr = 48000
ksmps = 128
示例#11
0

# 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)

print("Generated:")
print(csoundac_score.getCsoundScore())

orc = '''
sr = 48000
ksmps = 128