diff --git a/main.py b/main.py index 1addb51..f3c4d69 100644 --- a/main.py +++ b/main.py @@ -1,12 +1,17 @@ import python_midi import dico_notes import sys -import thread_dd - +import thread_fd def main(args): print "Bienvenue dans le programme de traitement des fichiers MIDI" print '\n' (p,v,t,f,r) = python_midi.midi_treatment_file("/home/pi/python-midi/mary.mid") - print (p,v,t,f,r) + thread1 = thread_fd.DD(18,f,t,r) + thread2 = thread_fd.DD(13,f,t,r) + thread1.start() + thread2.start() + thread1.join() + thread2.join() + main(sys.argv) diff --git a/thread_fd.py b/thread_fd.py new file mode 100644 index 0000000..f486fc6 --- /dev/null +++ b/thread_fd.py @@ -0,0 +1,50 @@ +from threading import Thread +import time +from RPi import GPIO + +class DD(Thread): + + #Constructeur + def __init__(self, pin, t_frequences, t_tps, res): + Thread.__init__(self); + self.pin = pin + self.t_frequences = t_frequences + self.t_tps = t_tps + self.res = res + + def run(self): + p = GPIO.PWM(self.pin,220) + p.start(15) + p.ChangeFrequency(self.t_frequences[0]) + duree = (self.t_tps[0]*1.8)/1000 + time.sleep(duree) + i = 1 + while(i