Commit dab90f8559e261140f39b9f6d403cf81a3d5b132
1 parent
79bde884
Commit MIDI File
Showing
4 changed files
with
221 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,80 @@ | @@ -0,0 +1,80 @@ | ||
1 | +midi.Pattern(format=1, resolution=220, tracks=\ | ||
2 | +[midi.Track(\ | ||
3 | + [midi.TimeSignatureEvent(tick=0, data=[4, 2, 24, 8]), | ||
4 | + midi.KeySignatureEvent(tick=0, data=[0, 0]), | ||
5 | + midi.EndOfTrackEvent(tick=1, data=[])]), | ||
6 | + midi.Track(\ | ||
7 | + [midi.ControlChangeEvent(tick=0, channel=0, data=[91, 58]), | ||
8 | + midi.ControlChangeEvent(tick=0, channel=0, data=[10, 69]), | ||
9 | + midi.ControlChangeEvent(tick=0, channel=0, data=[0, 0]), | ||
10 | + midi.ControlChangeEvent(tick=0, channel=0, data=[32, 0]), | ||
11 | + midi.ProgramChangeEvent(tick=0, channel=0, data=[24]), | ||
12 | + midi.NoteOnEvent(tick=0, channel=0, data=[64, 72]), | ||
13 | + midi.NoteOnEvent(tick=0, channel=0, data=[55, 70]), | ||
14 | + midi.NoteOnEvent(tick=231, channel=0, data=[64, 0]), | ||
15 | + midi.NoteOnEvent(tick=25, channel=0, data=[62, 72]), | ||
16 | + midi.NoteOnEvent(tick=231, channel=0, data=[62, 0]), | ||
17 | + midi.NoteOnEvent(tick=25, channel=0, data=[60, 71]), | ||
18 | + midi.NoteOnEvent(tick=231, channel=0, data=[60, 0]), | ||
19 | + midi.NoteOnEvent(tick=25, channel=0, data=[62, 79]), | ||
20 | + midi.NoteOnEvent(tick=206, channel=0, data=[55, 0]), | ||
21 | + midi.NoteOnEvent(tick=25, channel=0, data=[62, 0]), | ||
22 | + midi.NoteOnEvent(tick=25, channel=0, data=[64, 85]), | ||
23 | + midi.NoteOnEvent(tick=0, channel=0, data=[55, 79]), | ||
24 | + midi.NoteOnEvent(tick=231, channel=0, data=[64, 0]), | ||
25 | + midi.NoteOnEvent(tick=25, channel=0, data=[64, 78]), | ||
26 | + midi.NoteOnEvent(tick=231, channel=0, data=[64, 0]), | ||
27 | + midi.NoteOnEvent(tick=25, channel=0, data=[64, 74]), | ||
28 | + midi.NoteOnEvent(tick=462, channel=0, data=[55, 0]), | ||
29 | + midi.NoteOnEvent(tick=0, channel=0, data=[64, 0]), | ||
30 | + midi.NoteOnEvent(tick=50, channel=0, data=[62, 75]), | ||
31 | + midi.NoteOnEvent(tick=0, channel=0, data=[55, 77]), | ||
32 | + midi.NoteOnEvent(tick=231, channel=0, data=[62, 0]), | ||
33 | + midi.NoteOnEvent(tick=25, channel=0, data=[62, 77]), | ||
34 | + midi.NoteOnEvent(tick=231, channel=0, data=[62, 0]), | ||
35 | + midi.NoteOnEvent(tick=25, channel=0, data=[62, 75]), | ||
36 | + midi.NoteOnEvent(tick=462, channel=0, data=[55, 0]), | ||
37 | + midi.NoteOnEvent(tick=0, channel=0, data=[62, 0]), | ||
38 | + midi.NoteOnEvent(tick=50, channel=0, data=[64, 82]), | ||
39 | + midi.NoteOnEvent(tick=0, channel=0, data=[55, 79]), | ||
40 | + midi.NoteOnEvent(tick=231, channel=0, data=[64, 0]), | ||
41 | + midi.NoteOnEvent(tick=25, channel=0, data=[67, 84]), | ||
42 | + midi.NoteOnEvent(tick=231, channel=0, data=[67, 0]), | ||
43 | + midi.NoteOnEvent(tick=25, channel=0, data=[67, 75]), | ||
44 | + midi.NoteOnEvent(tick=462, channel=0, data=[55, 0]), | ||
45 | + midi.NoteOnEvent(tick=0, channel=0, data=[67, 0]), | ||
46 | + midi.NoteOnEvent(tick=50, channel=0, data=[64, 73]), | ||
47 | + midi.NoteOnEvent(tick=0, channel=0, data=[55, 78]), | ||
48 | + midi.NoteOnEvent(tick=231, channel=0, data=[64, 0]), | ||
49 | + midi.NoteOnEvent(tick=25, channel=0, data=[62, 69]), | ||
50 | + midi.NoteOnEvent(tick=231, channel=0, data=[62, 0]), | ||
51 | + midi.NoteOnEvent(tick=25, channel=0, data=[60, 71]), | ||
52 | + midi.NoteOnEvent(tick=231, channel=0, data=[60, 0]), | ||
53 | + midi.NoteOnEvent(tick=25, channel=0, data=[62, 80]), | ||
54 | + midi.NoteOnEvent(tick=206, channel=0, data=[55, 0]), | ||
55 | + midi.NoteOnEvent(tick=25, channel=0, data=[62, 0]), | ||
56 | + midi.NoteOnEvent(tick=25, channel=0, data=[64, 84]), | ||
57 | + midi.NoteOnEvent(tick=0, channel=0, data=[55, 79]), | ||
58 | + midi.NoteOnEvent(tick=231, channel=0, data=[64, 0]), | ||
59 | + midi.NoteOnEvent(tick=25, channel=0, data=[64, 76]), | ||
60 | + midi.NoteOnEvent(tick=231, channel=0, data=[64, 0]), | ||
61 | + midi.NoteOnEvent(tick=25, channel=0, data=[64, 74]), | ||
62 | + midi.NoteOnEvent(tick=231, channel=0, data=[64, 0]), | ||
63 | + midi.NoteOnEvent(tick=25, channel=0, data=[64, 77]), | ||
64 | + midi.NoteOnEvent(tick=206, channel=0, data=[55, 0]), | ||
65 | + midi.NoteOnEvent(tick=25, channel=0, data=[64, 0]), | ||
66 | + midi.NoteOnEvent(tick=25, channel=0, data=[62, 75]), | ||
67 | + midi.NoteOnEvent(tick=0, channel=0, data=[55, 78]), | ||
68 | + midi.NoteOnEvent(tick=231, channel=0, data=[62, 0]), | ||
69 | + midi.NoteOnEvent(tick=25, channel=0, data=[62, 74]), | ||
70 | + midi.NoteOnEvent(tick=231, channel=0, data=[62, 0]), | ||
71 | + midi.NoteOnEvent(tick=25, channel=0, data=[64, 81]), | ||
72 | + midi.NoteOnEvent(tick=231, channel=0, data=[64, 0]), | ||
73 | + midi.NoteOnEvent(tick=25, channel=0, data=[62, 70]), | ||
74 | + midi.NoteOnEvent(tick=206, channel=0, data=[55, 0]), | ||
75 | + midi.NoteOnEvent(tick=25, channel=0, data=[62, 0]), | ||
76 | + midi.NoteOnEvent(tick=25, channel=0, data=[60, 73]), | ||
77 | + midi.NoteOnEvent(tick=0, channel=0, data=[52, 72]), | ||
78 | + midi.NoteOnEvent(tick=974, channel=0, data=[60, 0]), | ||
79 | + midi.NoteOnEvent(tick=0, channel=0, data=[52, 0]), | ||
80 | + midi.EndOfTrackEvent(tick=1, data=[])])]) |
python-midi @ 4b7a229f6b3
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +Subproject commit 4b7a229f6b340e7424c1fccafa9ac543b9b3d605 |
@@ -0,0 +1,70 @@ | @@ -0,0 +1,70 @@ | ||
1 | +import sys | ||
2 | +import os | ||
3 | +import re | ||
4 | + | ||
5 | +def midi_treatment_file(midi_file): | ||
6 | + os.system("mididump.py " + midi_file + ">musique.txt") | ||
7 | + f = open("musique.txt","r") | ||
8 | + texte=f.read() | ||
9 | + midi_frame = texte.split("),") | ||
10 | + midi_note_events = [] | ||
11 | + i = 0 | ||
12 | + while (i < len(midi_frame)-1): | ||
13 | + if(("midi.NoteOn" in midi_frame[i]) or ("midi.NoteOff" in midi_frame[i])): | ||
14 | + midi_note_events.append(midi_frame[i]) | ||
15 | + i+=1 | ||
16 | + else: | ||
17 | + i+=1 | ||
18 | + | ||
19 | + data = [] | ||
20 | + ticks = [] | ||
21 | + j = 0 | ||
22 | + while (j < len(midi_note_events)): | ||
23 | + data.append(midi_note_events[j][45:70]) | ||
24 | + ticks.append(midi_note_events[j][26:29]) | ||
25 | + data[j] = data[j].replace('=','') | ||
26 | + data[j] = re.sub('[a-zA-Z]','',data[j]) | ||
27 | + ticks[j] = ticks[j].replace(',','') | ||
28 | + j+=1 | ||
29 | + | ||
30 | + a = 0 | ||
31 | + while (a < len(ticks)): | ||
32 | + ticks[a] = int(ticks[a]) | ||
33 | + a+=1 | ||
34 | + | ||
35 | + pitches=[] | ||
36 | + velocity=[] | ||
37 | + k = 0 | ||
38 | + while (k < len(data)): | ||
39 | + pitches.append(data[k][0:3]) | ||
40 | + pitches[k] = pitches[k].replace('[','') | ||
41 | + pitches[k] = pitches[k].replace(',','') | ||
42 | + k+=1 | ||
43 | + | ||
44 | + l = 0 | ||
45 | + while (l < len(pitches)): | ||
46 | + pitches[l] = int(pitches[l]) | ||
47 | + l+=1 | ||
48 | + | ||
49 | + k = 0 | ||
50 | + while (k < len(data)): | ||
51 | + velocity.append(data[k][4:len(data)-1]) | ||
52 | + velocity[k] = velocity[k].replace(']','') | ||
53 | + k+=1 | ||
54 | + | ||
55 | + l = 0 | ||
56 | + while (l < len(pitches)): | ||
57 | + velocity[l] = int(velocity[l]) | ||
58 | + l+=1 | ||
59 | + | ||
60 | + return (pitches,velocity,ticks) | ||
61 | + | ||
62 | +def main(args): | ||
63 | + (p,v,t) = midi_treatment_file("python-midi/mary.mid") | ||
64 | + n = 0 | ||
65 | + while (n < len(p)): | ||
66 | + print("Note : " + str(p[n]) + "Velocite : "+ str(v[n]) + "Tick : " + str(t[n])) | ||
67 | + n+=1 | ||
68 | + print "\n" | ||
69 | + | ||
70 | +main(sys.argv) |
@@ -0,0 +1,70 @@ | @@ -0,0 +1,70 @@ | ||
1 | +import sys | ||
2 | +import os | ||
3 | +import re | ||
4 | + | ||
5 | +def midi_treatment_file(midi_file): | ||
6 | + os.system("mididump.py " + midi_file + ">musique.txt") | ||
7 | + f = open("musique.txt","r") | ||
8 | + texte=f.read() | ||
9 | + midi_frame = texte.split("),") | ||
10 | + midi_note_events = [] | ||
11 | + i = 0 | ||
12 | + while (i < len(midi_frame)-1): | ||
13 | + if(("midi.NoteOn" in midi_frame[i]) or ("midi.NoteOff" in midi_frame[i])): | ||
14 | + midi_note_events.append(midi_frame[i]) | ||
15 | + i+=1 | ||
16 | + else: | ||
17 | + i+=1 | ||
18 | + | ||
19 | + data = [] | ||
20 | + ticks = [] | ||
21 | + j = 0 | ||
22 | + while (j < len(midi_note_events)): | ||
23 | + data.append(midi_note_events[j][45:70]) | ||
24 | + ticks.append(midi_note_events[j][26:29]) | ||
25 | + data[j] = data[j].replace('=','') | ||
26 | + data[j] = re.sub('[a-zA-Z]','',data[j]) | ||
27 | + ticks[j] = ticks[j].replace(',','') | ||
28 | + j+=1 | ||
29 | + | ||
30 | + a = 0 | ||
31 | + while (a < len(ticks)): | ||
32 | + ticks[a] = int(ticks[a]) | ||
33 | + a+=1 | ||
34 | + | ||
35 | + pitches=[] | ||
36 | + velocity=[] | ||
37 | + k = 0 | ||
38 | + while (k < len(data)): | ||
39 | + pitches.append(data[k][0:3]) | ||
40 | + pitches[k] = pitches[k].replace('[','') | ||
41 | + pitches[k] = pitches[k].replace(',','') | ||
42 | + k+=1 | ||
43 | + | ||
44 | + l = 0 | ||
45 | + while (l < len(pitches)): | ||
46 | + pitches[l] = int(pitches[l]) | ||
47 | + l+=1 | ||
48 | + | ||
49 | + k = 0 | ||
50 | + while (k < len(data)): | ||
51 | + velocity.append(data[k][4:len(data)-1]) | ||
52 | + velocity[k] = velocity[k].replace(']','') | ||
53 | + k+=1 | ||
54 | + | ||
55 | + l = 0 | ||
56 | + while (l < len(pitches)): | ||
57 | + velocity[l] = int(velocity[l]) | ||
58 | + l+=1 | ||
59 | + | ||
60 | + return (pitches,velocity,ticks) | ||
61 | + | ||
62 | +def main(args): | ||
63 | + (p,v,t) = midi_treatment_file("nom_fichier.mid") | ||
64 | + n = 0 | ||
65 | + while (n < len(p)): | ||
66 | + print("Note : " + str(p[n]) + "Velocite : "+ str(v[n]) + "Tick : " + str(t[n])) | ||
67 | + n+=1 | ||
68 | + print "\n" | ||
69 | + | ||
70 | +main(sys.argv) |