Esempio n. 1
0
    trk = d_crochesl(trk, bt)

    return trk


n = "struggle"
beats = [530000 for i in range(12 * 4)]
beats += [490000 for i in range(8 * 4)]
beats += [470000 for i in range(8 * 4)]
beats += [450000 for i in range((148 - 28) * 4)]
out = AudioSegment.silent(duration=1000)
for i in range(1, 4):
    mid = MidiFile()
    bt = mid.ticks_per_beat
    trkr = MidiTrack()
    trkl = MidiTrack()
    trkr = struggle_r(trkr, bt)
    trkl = struggle_l(trkl, bt)
    trkr = velocity_r(trkr, 100, 0.1)
    trkl = velocity_r(trkl, 80, 0.1)
    rs = [0.08 * i
          for j in range(148 * 4)]  # Given my count there are 144 meas
    mid.tracks.append(trkr)
    mid.tracks.append(trkl)
    mid = tempo_r(mid, beats, rs)
    mid.save("I" + n + ".mid")
    out += mid2aud("I" + n)

out.export("I" + n + ".wav")
play(out)
Esempio n. 2
0
from mido import MidiFile, MidiTrack
from lib import velocity_r, tempo_r, mid2aud
# import numpy as np
# import numpy.random as rd
from pydub import AudioSegment
from pydub.playback import play

n = "test"
mid_in = MidiFile(n + ".mid")
trkr = mid_in.tracks[1]
trkl = mid_in.tracks[2]

beats = [700000 for i in range(200)]
rs = [0.08 * 1 for j in range(200)]  # Given my count there are 144 measures
mid = MidiFile()
mid.ticks_per_beat = mid_in.ticks_per_beat
trkr = velocity_r(trkr, 80, 0.1)
trkl = velocity_r(trkl, 70, 0.1)
mid.tracks.append(trkr)
mid.tracks.append(trkl)
mid = tempo_r(mid, beats, rs)
mid.save("I" + n + ".mid")
out = mid2aud("I" + n)
out.export("I" + n + ".wav")
play(out)
Esempio n. 3
0
    trk = add_notes(trk, [[69-36], [64-12, 69-12, 64],
                          [64-12, 69-12, 64],
                          [69-12, 64], [-1]],
                    d_pat)
    return trk



n = "prelude7"
mid = MidiFile()
bt = mid.ticks_per_beat
trkr = MidiTrack()
trkl = MidiTrack()
trkr = pre7r(trkr, bt)
trkl = pre7l(trkl, bt)
beats = [1000000 for i in range(1+19*3)]
out = AudioSegment.silent(duration=3000)
for rep in range(1, 4):
    rs = [0.08*rep for j in range(1+19*3)] # Given my count there are 144 measures
    trkr = velocity_r(trkr, 90, 0.1)
    trkl = velocity_r(trkl, 50, 0.1)
    mid.tracks.append(trkr)
    mid.tracks.append(trkl)
    mid = tempo_r(mid, beats, rs)
    mid = pedal_r(mid, 3, 16, add=mid.ticks_per_beat)
    mid.save("I" + n + ".mid")
    new = mid2aud("I" + n)
    out += new
out.export("I" + n + ".wav")
play(out)
Esempio n. 4
0
    trackr.append(Message('note_off', note=71, time=200))
    mid.tracks.append(trackr)

    mid.ticks_per_beat = 100
    vols = generate_vol()
    mid = volume(mid, vols)
    return mid


silence = AudioSegment.silent(duration=1000)
out = silence
for i in range(3):
    n = "comp2"
    mid = comptineN2()
    tp = rd.randint(450000, 550000)
    beats = [tp for i in range(252)]
    end_beats = [int(i) for i in np.linspace(tp, 4 * tp, 8)]
    beats += end_beats
    rs = [0.1 for i in range(260)]
    mid = tempo_r(mid, beats, rs)
    rh = rd.randint(90, 110)
    lh = rd.randint(40, 60)
    mid.tracks[0] = velocity_r(mid.tracks[0], lh, 0.1)
    mid.tracks[1] = velocity_r(mid.tracks[1], rh, 0.1)
    mid.save("I" + n + ".mid")
    out += mid2aud("I" + n) + silence

out = out + 15
out.export("Icomp2.wav")
play(out)