def JackPortRenameCallback(portId, oldName, newName, arg=None): portPtr = jacklib.port_by_id(jack_client, portId) portFlags = jacklib.port_flags(portPtr) port_mode = PORT_MODE_NULL if portFlags & jacklib.JackPortIsInput: port_mode = PORT_MODE_INPUT elif portFlags & jacklib.JackPortIsOutput: port_mode = PORT_MODE_OUTPUT port_type = PORT_TYPE_NULL portTypeStr = str(jacklib.port_type(portPtr), encoding="utf-8") if portTypeStr == jacklib.JACK_DEFAULT_AUDIO_TYPE: port_type = PORT_TYPE_AUDIO elif portTypeStr == jacklib.JACK_DEFAULT_MIDI_TYPE: port_type = PORT_TYPE_MIDI signaler.port_renamed.emit(str(oldName, encoding='utf-8'), str(newName, encoding='utf-8'), port_mode, port_type) return 0
def JackPortRegistrationCallback(portId, registerYesNo, arg=None): portPtr = jacklib.port_by_id(jack_client, portId) portFlags = jacklib.port_flags(portPtr) port_name = str(jacklib.port_name(portPtr), encoding="utf-8") port_mode = PORT_MODE_NULL if portFlags & jacklib.JackPortIsInput: port_mode = PORT_MODE_INPUT elif portFlags & jacklib.JackPortIsOutput: port_mode = PORT_MODE_OUTPUT port_type = PORT_TYPE_NULL portTypeStr = str(jacklib.port_type(portPtr), encoding="utf-8") if portTypeStr == jacklib.JACK_DEFAULT_AUDIO_TYPE: port_type = PORT_TYPE_AUDIO elif portTypeStr == jacklib.JACK_DEFAULT_MIDI_TYPE: port_type = PORT_TYPE_MIDI if registerYesNo: signaler.port_added.emit(port_name, port_mode, port_type) else: signaler.port_removed.emit(port_name, port_mode, port_type) return 0
def __init__(self, port_name: str, jack_client, port_ptr=None): # In some cases, port could has just been renamed # then, jacklib.port_by_name fail. # that is why, port_ptr can be sent as argument here self.name = port_name if port_ptr is None: port_ptr = jacklib.port_by_name(jack_client, port_name) self.flags = jacklib.port_flags(port_ptr) self.uuid = jacklib.port_uuid(port_ptr) port_type_str = jacklib.port_type(port_ptr) if port_type_str == jacklib.JACK_DEFAULT_AUDIO_TYPE: self.type = PORT_TYPE_AUDIO elif port_type_str == jacklib.JACK_DEFAULT_MIDI_TYPE: self.type = PORT_TYPE_MIDI order_prop = jacklib.get_property(self.uuid, jacklib.JACK_METADATA_ORDER) ret, alias_1, alias_2 = jacklib.port_get_aliases(port_ptr) if ret: self.alias_1 = alias_1 self.alias_2 = alias_2
NSMServer.announce('JACK Connections', ':dirty:switch:', 'ray-jackpatch') #connect signals signal.signal(signal.SIGINT, signalHandler) signal.signal(signal.SIGTERM, signalHandler) #get all currents Jack ports and connections portNameList = c_char_p_p_to_list(jacklib.get_ports(jack_client, "", "", 0)) for portName in portNameList: jack_port = JackPort() jack_port.name = portName portPtr = jacklib.port_by_name(jack_client, portName) portFlags = jacklib.port_flags(portPtr) if portFlags & jacklib.JackPortIsInput: jack_port.mode = PORT_MODE_INPUT elif portFlags & jacklib.JackPortIsOutput: jack_port.mode = PORT_MODE_OUTPUT else: jack_port.mode = PORT_MODE_NULL portTypeStr = str(jacklib.port_type(portPtr), encoding="utf-8") if portTypeStr == jacklib.JACK_DEFAULT_AUDIO_TYPE: jack_port.type = PORT_TYPE_AUDIO elif portTypeStr == jacklib.JACK_DEFAULT_MIDI_TYPE: jack_port.type = PORT_TYPE_MIDI else: jack_port.type = PORT_TYPE_NULL