Commit e93068b7480fe5b3124523798ad80d5278518b99

Authored by root
1 parent 2e02e43f

Modification programme : recup resolution temporelle

Showing 2 changed files with 39 additions and 9 deletions   Show diff stats
1 import python_midi 1 import python_midi
2 import dico_notes 2 import dico_notes
3 import sys 3 import sys
  4 +import thread_dd
  5 +
4 6
5 def main(args): 7 def main(args):
6 print "Bienvenue dans le programme de traitement des fichiers MIDI" 8 print "Bienvenue dans le programme de traitement des fichiers MIDI"
7 - (p,v,t) = python_midi.midi_treatment_file("mary.mid")  
8 - print p  
9 - print v  
10 - print t  
11 -  
12 -main(sys.argv)  
13 \ No newline at end of file 9 \ No newline at end of file
  10 + print '\n'
  11 + (p,v,t,f,r) = python_midi.midi_treatment_file("/home/pi/python-midi/mary.mid")
  12 + print (p,v,t,f,r)
  13 +main(sys.argv)
  1 +#! /usr/bin/python
  2 +
1 import sys 3 import sys
2 import os 4 import os
3 import re 5 import re
  6 +import dico_notes
4 7
5 def midi_treatment_file(midi_file): 8 def midi_treatment_file(midi_file):
6 os.system("mididump.py " + midi_file + ">musique.txt") 9 os.system("mididump.py " + midi_file + ">musique.txt")
@@ -9,8 +12,21 @@ def midi_treatment_file(midi_file): @@ -9,8 +12,21 @@ def midi_treatment_file(midi_file):
9 midi_frame = texte.split("),") 12 midi_frame = texte.split("),")
10 midi_note_events = [] 13 midi_note_events = []
11 i = 0 14 i = 0
  15 + resolution = 0
  16 + nn = 0
  17 + dd = 0
  18 + key = 0
  19 + m = 0
  20 + ntimc = 0
12 while (i < len(midi_frame)-1): 21 while (i < len(midi_frame)-1):
13 - if(("midi.NoteOn" in midi_frame[i]) or ("midi.NoteOff" in midi_frame[i])): 22 + if ("midi.TimeSignatureEvent" in midi_frame[i]):
  23 + resolution=midi_frame[i][34:37]
  24 + i+=1
  25 + elif ("midi.KeySignatureEvent" in midi_frame[i]):
  26 + key = midi_frame[i][41:42]
  27 + m = midi_frame[i][44:45]
  28 + i+=1
  29 + elif (("midi.NoteOn" in midi_frame[i]) or ("midi.NoteOff" in midi_frame[i])):
14 midi_note_events.append(midi_frame[i]) 30 midi_note_events.append(midi_frame[i])
15 i+=1 31 i+=1
16 else: 32 else:
@@ -43,7 +59,7 @@ def midi_treatment_file(midi_file): @@ -43,7 +59,7 @@ def midi_treatment_file(midi_file):
43 59
44 l = 0 60 l = 0
45 while (l < len(pitches)): 61 while (l < len(pitches)):
46 - pitches[l] = int(pitches[l]) 62 + pitches[l] = str(pitches[l])
47 l+=1 63 l+=1
48 64
49 k = 0 65 k = 0
@@ -57,4 +73,18 @@ def midi_treatment_file(midi_file): @@ -57,4 +73,18 @@ def midi_treatment_file(midi_file):
57 velocity[l] = int(velocity[l]) 73 velocity[l] = int(velocity[l])
58 l+=1 74 l+=1
59 75
60 - return (pitches,velocity,ticks) 76 + frequency = []
  77 + k = 0
  78 + while(k<len(pitches)-1):
  79 + frequency.append(dico_notes.midi_note[pitches[k]])
  80 + k+=1
  81 +
  82 + print resolution
  83 + if (key == '0'):
  84 + print "Cle de DO"
  85 + if (m == '0'):
  86 + print "MAJEUR"
  87 +
  88 + return (pitches,velocity,ticks,frequency,resolution)
  89 +
  90 +(p,v,t,f,r) = midi_treatment_file("/home/pi/python-midi/mary.mid")