Ejemplo n.º 1
0
 def serve(self,pump_number,on_off):
     '''send midi note to output client
     parameters:
         pump_number : note
         on_off : note type (0 for NOTEOFF, 1 for NOTEON)
         '''
     if int(on_off) == 1:
         miditype = SEQ_EVENT_NOTEON
     else:
         miditype = SEQ_EVENT_NOTEOFF
     play = SeqEvent(miditype)
     play.source = (self.client_id, 1)
     print("4 source = %s" % str(self.client_id))
     try:
         play.dest = (self.outClientId, self.outClientPort)
         print("4 destination = %s" % str(self.outClientId))
     except:
         print("No output connexion, exiting", file=sys.stderr)
         return
     play.queue = self.queue
     play.set_data({'note.note' : int(pump_number), 'note.velocity' : 64})
     print('2 ' + str(play) + " envoyé")
     self.output_event(play)
     self.drain_output()
     self.sync_output_queue()
Ejemplo n.º 2
0
    def play(self, e_stop):
        self.running = True
        self.paused = False
        self.out = False
        i = 0
        n= 0
        while len(self.mdilist) > 0 :
#             print('len of mdilist: %d' % len(self.mdilist))
            sleep(0.001)
            event = self.mdilist.pop(0)
            evt = SeqEvent(SEQ_EVENT_NOTE)
            evt.source = (self.seq.client_id, self.seq.outportId)
            evt.dest = (self.seq.outClientId, self.seq.outClientPort)
            evt.timestamp = SEQ_TIME_STAMP_REAL
            evt.time = float(event[2])/1000.000
#                 print(event[3])
#                 evt.set_data({'note.note' : event[0], 'note.velocity' : event[1], 'note.duration' : event[3]*t , 'note.off_velocity' : event[4]})
            evt.set_data({'note.note' : event[0], 'note.velocity' : event[1], 'note.duration' : int(event[3]) , 'note.off_velocity' : event[4]})
            evt.queue = self.seq.queue
#             print('play event: %s %s' % (evt, evt.get_data()), file=sys.stderr)
            self.seq.output_event(evt)
            self.seq.drain_output()
            i += 1
            if i > 20:
                n += 1
#                 print('boucle %d' % n)
#                 print('go')
                self.seq.sync_output_queue()
                if e_stop.is_set():
                    self.seq.stop_queue(self.seq.queue)
#                     print("exit")
                    self.out = True
                    break
                i = 0
#         print("end of thread")
        if self.out == False:
            self.seq.sync_output_queue()
            self.seq.stop_queue(self.seq.queue)
#         self.seq.delete_queue(q)
        self.running = False
        self.seq.playing = False
        print('0 Ready')
        e_stop.clear()