Exemplo n.º 1
0
    def get_midi_ports(self, client_name):
        if self.jack_client is None:
            return []

        # get input and outputs separately
        in_ports = charPtrPtrToStringList(jacklib.get_ports(self.jack_client, client_name+":", jacklib.JACK_DEFAULT_MIDI_TYPE,
                                                            jacklib.JackPortIsPhysical|jacklib.JackPortIsOutput
                                                            if client_name == "alsa_midi" else
                                                            jacklib.JackPortIsInput
                                                            ))
        out_ports = charPtrPtrToStringList(jacklib.get_ports(self.jack_client, client_name+":", jacklib.JACK_DEFAULT_MIDI_TYPE,
                                                             jacklib.JackPortIsPhysical|jacklib.JackPortIsInput
                                                             if client_name == "alsa_midi" else
                                                             jacklib.JackPortIsOutput
                                                             ))

        if client_name != "alsa_midi":
            if "ingen:control_in" in in_ports:
                in_ports.remove("ingen:control_in")
            if "ingen:control_out" in out_ports:
                out_ports.remove("ingen:control_out")

            for i in range(len(in_ports)):
                uuid = jacklib.port_uuid(jacklib.port_by_name(self.jack_client, in_ports[i]))
                ret, value, type_ = jacklib.get_property(uuid, jacklib.JACK_METADATA_PRETTY_NAME)
                if ret == 0 and type_ == b"text/plain":
                    in_ports[i] = charPtrToString(value)

            for i in range(len(out_ports)):
                uuid = jacklib.port_uuid(jacklib.port_by_name(self.jack_client, out_ports[i]))
                ret, value, type_ = jacklib.get_property(uuid, jacklib.JACK_METADATA_PRETTY_NAME)
                if ret == 0 and type_ == b"text/plain":
                    out_ports[i] = charPtrToString(value)

        # remove suffixes from ports
        in_ports  = [port.replace(client_name+":","",1).rsplit(" in" ,1)[0] for port in in_ports ]
        out_ports = [port.replace(client_name+":","",1).rsplit(" out",1)[0] for port in out_ports]

        # add our own suffix now
        ports = []
        for port in in_ports:
            #if "Midi Through" in port:
                #continue
            if port in ("jackmidi", "OSS sequencer"):
                continue
            ports.append(port + (" (in+out)" if port in out_ports else " (in)"))

        return ports
Exemplo n.º 2
0
    def jack_midi_devs_callback(self):
        while len(self.mididevuuids) != 0:
            subject = self.mididevuuids.pop()

            ret, value, type_ = jacklib.get_property(
                subject, jacklib.JACK_METADATA_PRETTY_NAME)
            if ret != 0:
                continue
            if type_ != b"text/plain":
                continue

            value = charPtrToString(value)
            if not (value.endswith(" in") or value.endswith(" out")):
                continue

            mod_name = "%s:%s" % (self.backend_client_name,
                                  value.replace(" ", "_").replace("-",
                                                                  "_").lower())
            midi_name = "alsa_midi:%s" % value

            # All good, make connection now
            if value.endswith(" in"):
                jacklib.connect(self.jack_client, midi_name, mod_name)
                jacklib.connect(self.jack_client, midi_name,
                                self.backend_client_name + ":control_in")
            else:
                jacklib.connect(self.jack_client, mod_name, midi_name)
Exemplo n.º 3
0
    def jack_midi_devs_callback(self):
        while len(self.mididevuuids) != 0:
            subject = self.mididevuuids.pop()

            ret, value, type_ = jacklib.get_property(subject, jacklib.JACK_METADATA_PRETTY_NAME)
            if ret != 0:
                continue
            if type_ != b"text/plain":
                continue

            value = charPtrToString(value)
            if not (value.endswith(" in") or value.endswith(" out")):
                continue

            mod_name  = "%s:%s" % (self.backend_client_name, value.replace(" ", "_").replace("-","_").lower())
            midi_name = "alsa_midi:%s" % value

            # All good, make connection now
            if value.endswith(" in"):
                jacklib.connect(self.jack_client, midi_name, mod_name)
                jacklib.connect(self.jack_client, midi_name, self.backend_client_name+":control_in")
            else:
                jacklib.connect(self.jack_client, mod_name, midi_name)
Exemplo n.º 4
0
    def get_midi_ports(self, client_name):
        if self.jack_client is None:
            return []

        # get input and outputs separately
        in_ports = charPtrPtrToStringList(
            jacklib.get_ports(
                self.jack_client, client_name + ":",
                jacklib.JACK_DEFAULT_MIDI_TYPE,
                jacklib.JackPortIsPhysical | jacklib.JackPortIsOutput
                if client_name == "alsa_midi" else jacklib.JackPortIsInput))
        out_ports = charPtrPtrToStringList(
            jacklib.get_ports(
                self.jack_client, client_name + ":",
                jacklib.JACK_DEFAULT_MIDI_TYPE,
                jacklib.JackPortIsPhysical | jacklib.JackPortIsInput
                if client_name == "alsa_midi" else jacklib.JackPortIsOutput))

        if client_name != "alsa_midi":
            if "ingen:control_in" in in_ports:
                in_ports.remove("ingen:control_in")
            if "ingen:control_out" in out_ports:
                out_ports.remove("ingen:control_out")

            for i in range(len(in_ports)):
                uuid = jacklib.port_uuid(
                    jacklib.port_by_name(self.jack_client, in_ports[i]))
                ret, value, type_ = jacklib.get_property(
                    uuid, jacklib.JACK_METADATA_PRETTY_NAME)
                if ret == 0 and type_ == b"text/plain":
                    in_ports[i] = charPtrToString(value)

            for i in range(len(out_ports)):
                uuid = jacklib.port_uuid(
                    jacklib.port_by_name(self.jack_client, out_ports[i]))
                ret, value, type_ = jacklib.get_property(
                    uuid, jacklib.JACK_METADATA_PRETTY_NAME)
                if ret == 0 and type_ == b"text/plain":
                    out_ports[i] = charPtrToString(value)

        # remove suffixes from ports
        in_ports = [
            port.replace(client_name + ":", "", 1).rsplit(" in", 1)[0]
            for port in in_ports
        ]
        out_ports = [
            port.replace(client_name + ":", "", 1).rsplit(" out", 1)[0]
            for port in out_ports
        ]

        # add our own suffix now
        ports = []
        for port in in_ports:
            #if "Midi Through" in port:
            #continue
            if port in ("jackmidi", "OSS sequencer"):
                continue
            ports.append(port +
                         (" (in+out)" if port in out_ports else " (in)"))

        return ports