def jack_process_callback(nframes, arg): try: global jack_midi_in_port, jack_midi_in_data # MIDI In midi_in_buffer = jacklib.port_get_buffer(jack_midi_in_port, nframes) event_count = jacklib.midi_get_event_count(midi_in_buffer) if event_count > 0: event = jacklib.jack_midi_event_t() for i in range(event_count): if jacklib.midi_event_get(jacklib.pointer(event), midi_in_buffer, i) == 0: data = jacklib.translate_midi_event_buffer(event.buffer) if len(data) == 1: jack_midi_in_data.put_nowait((data[0], 0, 0)) elif len(data) == 2: jack_midi_in_data.put_nowait((data[0], data[1], 0)) elif len(data) == 3: jack_midi_in_data.put_nowait((data[0], data[1], data[2])) if jack_midi_in_data.full(): break del event except Exception as e: print e return 0
def JackProcess(self,nframes,arg): """Main Jack Process Method""" if not self.docapture.is_set(): ## Copy input data endframe = self.startframe + nframes if endframe > self.iIa.size: endframe = self.iIa.size tsz = (endframe-self.startframe) * ctypes.sizeof(jacklib.jack_default_audio_sample_t) basei = self.startframe * ctypes.sizeof(jacklib.jack_default_audio_sample_t) ctypes.memmove(self.iIa.ctypes.data+basei,jacklib.port_get_buffer(self.iI,nframes),tsz) ctypes.memmove(self.iQa.ctypes.data+basei,jacklib.port_get_buffer(self.iQ,nframes),tsz) ctypes.memmove(jacklib.port_get_buffer(self.oI,nframes),self.oIa.ctypes.data+basei,tsz) ctypes.memmove(jacklib.port_get_buffer(self.oQ,nframes),self.oQa.ctypes.data+basei,tsz) #print self.startframe,endframe,basei,tsz self.startframe = endframe if self.startframe >= self.iIa.size: self.docapture.set() return 0