Example #1
0
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'
Example #2
0
	def get_jack_ports(self):
		self.jainplist.delete(0,tkinter.END)
		self.jaoutlist.delete(0,tkinter.END)
		#jack.attach('measure')
		for port in jack.get_ports():
			if (jack.get_port_flags(port) & jack.IsOutput) > 0:
				self.jainplist.insert(tkinter.END, port)
			if (jack.get_port_flags(port) & jack.IsInput) > 0:
				self.jaoutlist.insert(tkinter.END, port)
Example #3
0
 def __GetNumberOfPeriods(self):
     """
     Querys the number of buffer periods of the jack server.
     Since neither the Jack latency functions nor the querying of the number
     of buffer periods are available in PyJack, this method is a dirty workaround
     to obtain this number.
     @retval : The number of buffer periods of the Jack server
     """
     for p in self.GetCapturePorts():
         if jack.get_port_flags(p) & jack.IsPhysical:
             return int(subprocess.check_output(["jack_lsp", "-l", p]).split("\n")[1].strip().split(" ")[-2]) / jack.get_buffer_size()
     return 2
Example #4
0
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'
Example #5
0
 def GetPlaybackPorts(self):
     """
     Returns a list of playback ports of other programs.
     Use GetOutputs to get a list of this instance's playback ports.
     @retval : a list of playback port names as strings
     """
     ports = jack.get_ports()
     result = []
     prefix = self.__prefix + ":"
     for p in ports:
         if jack.get_port_flags(p) & jack.IsOutput:
             if not p.startswith(prefix):
                 result.append(p)
     return result
Example #6
0
def conecta (a, b, mode="connect"):
    """ conecta puertos de captura con puertos de playback
    """
    # Lista de puertos A
    Aports = [x for x in jack.get_ports() if a in x]
    # y filtramos los de captura
    Aports = [x for x in Aports if jack.get_port_flags(x) % 2 == 0 ]
    # Lista de puertos B
    Bports = [x for x in jack.get_ports() if b in x]
    # y filtramos los de playback
    Bports = [x for x in Bports if jack.get_port_flags(x) % 2 == 1 ]

    # Recorremos A y lo vamos (des)conectando con B
    while Aports:
        try:
            p1 = Aports.pop(0)
            p2 = Bports.pop(0)
            #print p1, p2
            if mode == 'disconnect':
                jack.disconnect(p1, p2)
            else:
                jack.connect(p1, p2)
        except:
            pass
Example #7
0
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
Example #8
0

for i in range(output_n):
    if channels == 2:
        jack.register_port('output {} L'.format(i+1), jack.IsOutput)
        jack.register_port('output {} R'.format(i+1), jack.IsOutput)
    else:
        jack.register_port('output {}'.format(i+1), jack.IsOutput)

jack.activate()

if args.input:
    if ',' in args.input:
        capture_ports = args.input.split(',')
    else:
        jack_capture_ports = [p for p in jack.get_ports() if jack.get_port_flags(p) & jack.IsOutput]
        try:
            request = re.compile(args.input)
            capture_ports = [s.string for i in jack_capture_ports for s in [re.match(request, i)] if s]
        except:
            print 'input ports not valid'
    i = 0
    for p in capture_ports:
        try:
            print 'connect {} to {}'.format(p, input_ports[i])
            jack.connect(p, input_ports[i])
            i += 1
            if i >= len(input_ports):
                i = 0
        except Exception as err:
            print err