from mido import Message, MidiFile, MidiTrack

fluter = 73,60,96
oboer = 68,58,91
clarinetr = 71,50,94
bassoonr = 70,34,75
hornr = 69,52,81
trumpetr = 56,55,82
tromboner = 57,40,72
timpanir = 47,40,55
hapsicordr = 6,29,89
violinr = 40,55,103
violar = 41,48,91
cellor = 42,36,76
bassr = 43,28,67

mid = MidiFile()

flute = MidiTrack()
oboe = MidiTrack()
clarinet = MidiTrack()
bassoon = MidiTrack()
horn = MidiTrack()
trumpet = MidiTrack()
trombone = MidiTrack()
timpani = MidiTrack()
hapsicord = MidiTrack()
violin = MidiTrack()
viola = MidiTrack()
cello = MidiTrack()
bass = MidiTrack()

mid.tracks.append(flute)
mid.tracks.append(oboe)
mid.tracks.append(clarinet)
mid.tracks.append(bassoon)
mid.tracks.append(horn)
mid.tracks.append(trumpet)
mid.tracks.append(trombone)
mid.tracks.append(timpani)
mid.tracks.append(hapsicord)
mid.tracks.append(violin)
mid.tracks.append(viola)
mid.tracks.append(cello)
mid.tracks.append(bass)

flute.append(Message('program_change', program=fluter[0], time=0))
oboe.append(Message('program_change', program=oboer[0], time=0))
clarinet.append(Message('program_change', program=clarinetr[0], time=0))
bassoon.append(Message('program_change', program=bassoonr[0], time=0))
horn.append(Message('program_change', program=hornr[0], time=0))
trumpet.append(Message('program_change', program=trumpetr[0], time=0))
trombone.append(Message('program_change', program=tromboner[0], time=0))
timpani.append(Message('program_change', program=timpanir[0], time=0))
hapsicord.append(Message('program_change', program=hapsicordr[0], time=0))
violin.append(Message('program_change', program=violinr[0], time=0))
viola.append(Message('program_change', program=violar[0], time=0))
cello.append(Message('program_change', program=cellor[0], time=0))
bass.append(Message('program_change', program=bassr[0], time=0))

value = 128

for i in reversed(range(0,127)):
    if i > fluter[1] and i < fluter[2]:
        flute.append(Message('note_on', note=i, velocity=127, time=0))
    else:
        flute.append(Message('note_on', note=i, velocity=0, time=0))
    if i > oboer[1] and i < oboer[2]:
        oboe.append(Message('note_on', note=i, velocity=127, time=0))
    else:
        oboe.append(Message('note_on', note=i, velocity=0, time=0))
    if i > clarinetr[1] and i < clarinetr[2]:
        clarinet.append(Message('note_on', note=i, velocity=127, time=0))
    else:
        clarinet.append(Message('note_on', note=i, velocity=0, time=0))
    if i > bassoonr[1] and i < bassoonr[2]:
        bassoon.append(Message('note_on', note=i, velocity=127, time=0))
    else:
        bassoon.append(Message('note_on', note=i, velocity=0, time=0))
    if i > hornr[1] and i < hornr[2]:
        horn.append(Message('note_on', note=i, velocity=127, time=0))
    else:
        horn.append(Message('note_on', note=i, velocity=0, time=0))
    if i > trumpetr[1] and i < trumpetr[2]:
        trumpet.append(Message('note_on', note=i, velocity=127, time=0))
    else:
        trumpet.append(Message('note_on', note=i, velocity=0, time=0))
    if i > tromboner[1] and i < tromboner[2]:
        trombone.append(Message('note_on', note=i, velocity=127, time=0))
    else:
        trombone.append(Message('note_on', note=i, velocity=0, time=0))
    if i > timpanir[1] and i < timpanir[2]:
        timpani.append(Message('note_on', note=i, velocity=127, time=0))
    else:
        timpani.append(Message('note_on', note=i, velocity=0, time=0))
    if i > hapsicordr[1] and i < hapsicordr[2]:
        hapsicord.append(Message('note_on', note=i, velocity=127, time=0))
    else:
        hapsicord.append(Message('note_on', note=i, velocity=0, time=0))
    if i > violinr[1] and i < violinr[2]:
        violin.append(Message('note_on', note=i, velocity=127, time=0))
    else:    
        violin.append(Message('note_on', note=i, velocity=0, time=0)) 
    if i > violar[1] and i < violar[2]:
        viola.append(Message('note_on', note=i, velocity=127, time=0))
    else:
        viola.append(Message('note_on', note=i, velocity=0, time=0))
    if i > cellor[1] and i < cellor[2]:
        cello.append(Message('note_on', note=i, velocity=127, time=0))
    else:
        cello.append(Message('note_on', note=i, velocity=0, time=0))
    if i > bassr[1] and i < bassr[2]:
        bass.append(Message('note_on', note=i, velocity=127, time=0))
    else:
        bass.append(Message('note_on', note=i, velocity=0, time=0))
    if i > fluter[1] and i < fluter[2]:
        flute.append(Message('note_off', note=i, velocity=127, time=value))
    else:
        flute.append(Message('note_off', note=i, velocity=0, time=value))
    if i > oboer[1] and i < oboer[2]:
        oboe.append(Message('note_off', note=i, velocity=127, time=value))
    else:
        oboe.append(Message('note_off', note=i, velocity=0, time=value))
    if i > clarinetr[1] and i < clarinetr[2]:
        clarinet.append(Message('note_off', note=i, velocity=127, time=value))
    else:
        clarinet.append(Message('note_off', note=i, velocity=0, time=value))
    if i > bassoonr[1] and i < bassoonr[2]:
        bassoon.append(Message('note_off', note=i, velocity=127, time=value))
    else:
        bassoon.append(Message('note_off', note=i, velocity=0, time=value))
    if i > hornr[1] and i < hornr[2]:
        horn.append(Message('note_off', note=i, velocity=127, time=value))
    else:
        horn.append(Message('note_off', note=i, velocity=0, time=value))
    if i > trumpetr[1] and i < trumpetr[2]:
        trumpet.append(Message('note_off', note=i, velocity=127, time=value))
    else:
        trumpet.append(Message('note_off', note=i, velocity=0, time=value))
    if i > tromboner[1] and i < tromboner[2]:
        trombone.append(Message('note_off', note=i, velocity=127, time=value))
    else:
        trombone.append(Message('note_off', note=i, velocity=0, time=value))
    if i > timpanir[1] and i < timpanir[2]:
        timpani.append(Message('note_off', note=i, velocity=127, time=value))
    else:
        timpani.append(Message('note_off', note=i, velocity=0, time=value))
    if i > hapsicordr[1] and i < hapsicordr[2]:
        hapsicord.append(Message('note_off', note=i, velocity=127, time=value))
    else:
        hapsicord.append(Message('note_off', note=i, velocity=0, time=value))
    if i > violinr[1] and i < violinr[2]:
        violin.append(Message('note_off', note=i, velocity=127, time=value))
    else:
        violin.append(Message('note_off', note=i, velocity=0, time=value))
    if i > violar[1] and i < violar[2]:
        viola.append(Message('note_off', note=i, velocity=127, time=value))
    else:
        viola.append(Message('note_off', note=i, velocity=0, time=value))
    if i > cellor[1] and i < cellor[2]:
        cello.append(Message('note_off', note=i, velocity=127, time=value))
    else:
        cello.append(Message('note_off', note=i, velocity=0, time=value))
    if i > bassr[1] and i < bassr[2]:
        bass.append(Message('note_off', note=i, velocity=127, time=value))
    else:
        bass.append(Message('note_off', note=i, velocity=0, time=value))

mid.save('full_range_3.mid')
