Exemplo n.º 1
0
    "af3 ef4 gf bf ef5 gf cf6", "af3 ef4 f bf df5 f5 bf5",
    "gf3 df4 af ef af cf6 ef", "gf3 df4 bf d5 f bf d6",
    "a3 c4 d fs bf df5 gf bf df6", "bf3 cs e gs c5 d gs c6",
    "c4 d f a4 cs5 e a", "cs4 e fs bf d5 f", "fs4 g bf d5 fs a",
    "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,
Exemplo n.º 2
0
    Gesture4 is similar to gesture3 but chooses octaves and gradually
    prefers motive2 over motive1.
    """
    for i in range(numtimes):
        if odds(qtime(i, numtimes, 1.0, 0.0, .01)):
            q.compose(motive1(q, between(lowoctave, highoctave), limit, chan))
        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
Exemplo n.º 3
0
        spec = fmspectrum(f,r,x)
        keys = spec.keynums(unique=True, minkey=knum-14, maxkey=knum+14)

        if ismel:
            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}'.")
Exemplo n.º 4
0
        # the clarinet line
        midi = MidiNote(time=q.now, dur=rhy + .2, key=melody, amp=amp, chan=1)
        q.out.addevent(midi)
        # add decorations to the clarinet melody
        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()
Exemplo n.º 5
0
              [54.6, 62.2, 66.6], [57.3, 66.6, 69.3], [58, 62.2, 67.1],
              [36, 45.3, 48], [60, 66.6, 69.3], [46, 55.1, 60],
              [42.6, 50.2, 57.3], [46, 55.1, 60], [57, 66.6, 69.3],
              [57.3, 66.6, 69.3], [54.6, 62.2, 66.6]]

    # 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,
Exemplo n.º 6
0
    ampl = .9
    for meas in range(measures):
        root = next(roots)
        if 0 == meas % 12:
            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))
    """
    # random pattern of section lengths.
    pat = choose(seclens)
    # iterate all the min and max key numbers
    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
Exemplo n.º 8
0
    rhythms = choose([[2, 2], [1, 1, 1, 1], [2, 1, 1], [1, 1, 2], [1, 2, 1], [4]],
                        [.375, .125, .125, .125 ,.25, .125])
    for _ in range(num):
        n=0
        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}'.")