Exemplo n.º 1
0
    def checkTransport(self):
        pos = jacklib.jack_position_t()
        pos.valid = 0

        state = jacklib.transport_query(jack_client, jacklib.pointer(pos))

        if self.will_trig:
            if pos.beat == pos.beats_per_bar:
                if (pos.ticks_per_beat - pos.tick) <= 4:
                    # we are at 4 ticks or less from next bar (arbitrary)
                    # so we send a trig message to sooperlooper.
                    server.send(self.sl_url, '/sl/-1/hit', 'trigger')
                    self.will_trig = False
                    return

        if (self.transport_playing and state == jacklib.JackTransportStopped):
            if self.will_trig:
                self.will_trig = False
            else:
                server.send(self.sl_url, '/sl/-1/hit', 'pause_on')

            self.transport_playing = False

        elif (not self.transport_playing
              and state == jacklib.JackTransportRolling):
            if pos.beat == 1 and pos.tick == 0:
                server.send(self.sl_url, '/sl/-1/hit', 'trigger')

            else:
                self.will_trig = True

            self.transport_playing = True
Exemplo n.º 2
0
status = jacklib.jack_status_t()
client = jacklib.client_open("transport-query", jacklib.JackNoStartServer,
                             status)
err = get_jack_status_error_string(status)

if status.value:
    if status.value & jacklib.JackNameNotUnique:
        print("Non-fatal JACK status: %s" % err, file=sys.stderr)
    elif status.value & jacklib.JackServerStarted:
        # Should not happen, since we use the JackNoStartServer option
        print("Unexpected JACK status: %s" % err, file=sys.stderr)
    else:
        sys.exit("Error connecting to JACK server: %s" % err)

position = jacklib.jack_position_t()
transport_state = jacklib.transport_query(client, pointer(position))

for name, type_ in sorted(position._fields_):
    value = getattr(position, name)
    if name == 'padding':
        value = list(value)
    print("{}: {}".format(name, value), file=sys.stderr)

if transport_state == jacklib.JackTransportStopped:
    print("JACK transport stopped, starting it now.")
    jacklib.transport_start(client)
elif transport_state == jacklib.JackTransportRolling:
    print("JACK transport rolling, stopping it now.")
    jacklib.transport_stop(client)
elif transport_state == jacklib.JackTransportStarting:
    print("JACK transport starting, nothing to do.")
Exemplo n.º 3
0
 def transport_query(self, position=None):
     return jacklib.transport_query(self.client, position)