def establish_connection(pcm, channel): myname = jack.get_client_name() capture_name = pcm + ":capture_" + channel port_name = "in_" + channel connection_name = myname + ":" + port_name print capture_name, port_name, connection_name print "Jack ports (before):", jack.get_ports() jack.register_port(port_name, jack.IsInput) jack.activate() print "Jack ports (after):", jack.get_ports() jack.connect(capture_name, connection_name) print jack.get_connections(connection_name)
def index(): ports = None try: ports = jack.get_ports() except (jack.NotConnectedError, jack.Error): try: jack.detach('studio-webapp') jack.attach('studio-webapp') ports = jack.get_ports() except (jack.NotConnectedError, jack.Error): return render_template('jack_device_error.html') inports = [] outports = [] connects = {} for port in ports: if (jack.get_port_flags(port) & jack.IsInput) > 0: inports.append(port) connects[port] = jack.get_connections(port) if (jack.get_port_flags(port) & jack.IsOutput) > 0: outports.append(port) try: otg_systemd_status = subprocess.check_output(['sudo', 'systemctl', 'is-active', 'studio-gaudio_in']) except subprocess.CalledProcessError, e: otg_systemd_status = 'failed'
def conectaDISPLAYS(): info =[] # Primero desconectamos lo que hubiera en los displays, por higiene ;-) desconectaDISPLAYS() # Tomamos nota de la source: source_ports = [] for p in firtro_ports: source_ports += jack.get_connections(p) # Conectamos los impares: for o in source_ports[0::2]: for d in getDisplaysPorts()[0::2]: info.append("(i) conectando "+ o + " " + d) jack.connect(o,d) # Conectamos los pares: for o in source_ports[1::2]: for d in getDisplaysPorts()[1::2]: info.append("(i) conectando "+ o + " " + d) jack.connect(o,d) if info: for cosa in info: print cosa else: print "(?) nada que conectar"
def desconectaDISPLAYS(): for portDisplay in getDisplaysPorts(): clientes = jack.get_connections(portDisplay) for cliente in clientes: print "(i) desconectando " + cliente + " " + portDisplay jack.disconnect(cliente, portDisplay) if not getDisplaysPorts(): print "(?) nada que desconectar"
def desconecta_fuentes_de(out_ports): """ Desconectamos todos los clientes de la entrada del FIRtro y de los monitores """ sources_L_firtro = jack.get_connections(out_ports[0]) sources_R_firtro = jack.get_connections(out_ports[1]) for source in sources_L_firtro: jack_disconnect(source, out_ports[0]) for source in sources_R_firtro: jack_disconnect(source, out_ports[1]) # Los monitores son opcionales try: if ext_monitor_ports: sources_L_extMon = jack.get_connections(ext_monitor_ports[0]) sources_R_extMon = jack.get_connections(ext_monitor_ports[1]) for source in sources_L_extMon: jack_disconnect(source, ext_monitor_ports[0]) for source in sources_R_extMon: jack_disconnect(source, ext_monitor_ports[1]) sources_L_intMon = jack.get_connections(int_monitor_ports[0]) sources_R_intMon = jack.get_connections(int_monitor_ports[1]) for source in sources_L_intMon: jack_disconnect(source, int_monitor_ports[0]) for source in sources_R_intMon: jack_disconnect(source, int_monitor_ports[1]) except: logging.exception("error en desconexion de monitores")
def connect_source2jacktrip(): jack.attach("tmp") # Desconectamos lo que hubiera en JackTrip c1_ports = jack.get_connections("JackTrip:send_1") c2_ports = jack.get_connections("JackTrip:send_2") for p1 in c1_ports: jack.disconnect(p1, "JackTrip:send_1") for p2 in c2_ports: jack.disconnect(p2, "JackTrip:send_2") try: # conectamos las fuente del FIRtro a jacktrip s1_ports = jack.get_connections(firtro_ports[0]) s2_ports = jack.get_connections(firtro_ports[1]) for s1 in s1_ports: jack.connect(s1, "JackTrip:send_1") for s2 in s2_ports: jack.connect(s2, "JackTrip:send_2") except: # el motivo del fallo es que los puertos de JackTrip no están activos: # "Cannot connect ports owned by inactive clients: "JackTrip" is not active" # porque no ha sincronizado todavía con un cliente. print "(jacktrip.py) (i) para conectar puertos se necesita que estén" print " activos (con una conexion cliente jacktrip en red)" jack.detach()
def index(): try: ports = jack.get_ports() except jack.NotConnectedError: jack.attach('studio-webapp') ports = jack.get_ports() inports = [] outports = [] connects = {} for port in ports: if (jack.get_port_flags(port) & jack.IsInput) > 0: inports.append(port) connects[port] = jack.get_connections(port) if (jack.get_port_flags(port) & jack.IsOutput) > 0: outports.append(port) try: otg_systemd_status = subprocess.check_output( ['sudo', 'systemctl', 'is-active', 'studio-gaudio_in']) except subprocess.CalledProcessError, e: otg_systemd_status = 'failed'
def jackConexiones(nombrePuerto="", direccion="*"): """ direccion: > | < | * Devuelve una lista de tripletas: (puerto, conexion, puerto) """ ports = [] jack.attach("tmp") for puerto in [x for x in jack.get_ports() if nombrePuerto in x]: conexiones = jack.get_connections(puerto) for conexion in conexiones: flags = jack.get_port_flags(conexion) # Returns an integer which is the bitwise-or of all flags for a given port. # haciendo pruebas veamos algunos flags de puertos: # puertos escribibles (playback): 1 21 impares, ultimo bit a 1 # puertos leibles (capture) : 2 18 22 pares, ultimo bit a 0 if flags % 2: direc = ">" else: direc = "<" if direc == direccion or direccion == "*": ports.append((puerto, " --" + direc + "-- ", conexion)) jack.detach() return ports
myname = jack.get_client_name() print "Client:", myname print jack.get_ports() jack.register_port("in_1", jack.IsInput) jack.register_port("in_2", jack.IsInput) jack.activate() print jack.get_ports() jack.connect("system:capture_1", myname+":in_1") jack.connect("system:capture_2", myname+":in_2") print jack.get_connections(myname+":in_1") N = jack.get_buffer_size() Sr = float(jack.get_sample_rate()) print "Buffer Size:", N, "Sample Rate:", Sr sec = 3.0 capture = numpy.zeros((2,int(Sr*sec)), 'f') dummy = numpy.zeros((2,0), 'f') #time.sleep(1) print "Capturing audio..." i = 0 while i < capture.shape[1] - N:
jack.register_port("in_1", jack.IsInput) jack.register_port("in_2", jack.IsInput) jack.register_port("out_1", jack.IsOutput) jack.register_port("out_2", jack.IsOutput) jack.activate() print jack.get_ports() jack.connect("system:capture_1", "captest:in_1") jack.connect("system:capture_2", "captest:in_2") jack.connect("captest:out_1", "system:playback_1") jack.connect("captest:out_2", "system:playback_2") print jack.get_connections("captest:in_1") N = jack.get_buffer_size() Sr = float(jack.get_sample_rate()) print "Buffer Size:", N, "Sample Rate:", Sr sec = 3.0 capture = numpy.zeros((2, int(Sr * sec)), 'f') input = numpy.zeros((2, N), 'f') output = numpy.zeros((2, N), 'f') #time.sleep(1) print "Capturing audio..." i = 0
jack.register_port("in_1", jack.IsInput) jack.register_port("in_2", jack.IsInput) jack.register_port("out_1", jack.IsOutput) jack.register_port("out_2", jack.IsOutput) jack.activate() print jack.get_ports() jack.connect("system:capture_1", "captest:in_1") jack.connect("system:capture_2", "captest:in_2") jack.connect("captest:out_1", "system:playback_1") jack.connect("captest:out_2", "system:playback_2") print jack.get_connections("captest:in_1") N = jack.get_buffer_size() Sr = float(jack.get_sample_rate()) print "Buffer Size:", N, "Sample Rate:", Sr sec = 3.0 capture = numpy.zeros((2,int(Sr*sec)), 'f') input = numpy.zeros((2,N), 'f') output = numpy.zeros((2,N), 'f') #time.sleep(1) print "Capturing audio..." i = 0
jack.attach("fftknn") print jack.get_ports() jack.register_port("in_1", jack.IsInput) jack.register_port("out_1", jack.IsOutput) jack.activate() # jack.connect("alsa_pcm:capture_1", "fftknn:in_1") # jack.connect("Hydrogen-1:out_L", "fftknn:in_1") # jack.connect("pure_data_0:output0", "fftknn:in_1") # jack.connect("sooperlooper:common_out_1", "fftknn:in_1") print jack.get_connections("fftknn:in_1") N = jack.get_buffer_size() Sr = float(jack.get_sample_rate()) print "Buffer Size:", N, "Sample Rate:", Sr # sec = 0.1 import rtmidi midiin = rtmidi.RtMidiIn() midiin.openVirtualPort('fftknn') midiout = rtmidi.RtMidiOut() midiout.openVirtualPort('fftknn') time.sleep(1) print "Capturing audio..."
myname = jack.get_client_name() print "Client:", myname print jack.get_ports() jack.register_port("in_1", jack.IsInput) jack.register_port("in_2", jack.IsInput) jack.activate() print jack.get_ports() jack.connect("system:capture_1", myname + ":in_1") jack.connect("system:capture_2", myname + ":in_2") print jack.get_connections(myname + ":in_1") N = jack.get_buffer_size() Sr = float(jack.get_sample_rate()) print "Buffer Size:", N, "Sample Rate:", Sr sec = 3.0 capture = numpy.zeros((2, int(Sr * sec)), 'f') dummy = numpy.zeros((2, 0), 'f') #time.sleep(1) print "Capturing audio..." i = 0 while i < capture.shape[1] - N:
jack.attach("fftknn") print jack.get_ports() jack.register_port("in_1", jack.IsInput) jack.register_port("out_1", jack.IsOutput) jack.activate() # jack.connect("alsa_pcm:capture_1", "fftknn:in_1") # jack.connect("Hydrogen-1:out_L", "fftknn:in_1") # jack.connect("pure_data_0:output0", "fftknn:in_1") # jack.connect("sooperlooper:common_out_1", "fftknn:in_1") print jack.get_connections("fftknn:in_1") N = jack.get_buffer_size() Sr = float(jack.get_sample_rate()) print "Buffer Size:", N, "Sample Rate:", Sr # sec = 0.1 import rtmidi midiin = rtmidi.RtMidiIn() midiin.openVirtualPort('fftknn') midiout = rtmidi.RtMidiOut() midiout.openVirtualPort('fftknn') time.sleep(1)
def BrutefirPorts(): L = jack.get_connections('brutefir:input-0') R = jack.get_connections('brutefir:input-1') return (L,R)
def connected(self, output): return output.port in jack.get_connections(self.port)