diff --git a/transport.c b/transport.c index b96179d..57a4452 100644 --- a/transport.c +++ b/transport.c @@ -214,6 +214,28 @@ void com_timeout(char *arg) jack_set_sync_timeout(client, (jack_time_t) (timeout*1000000)); } +/* Toggle between play and stop state */ +static void com_toggle(char *arg) +{ + jack_position_t current; + jack_transport_state_t transport_state; + + transport_state = jack_transport_query (client, ¤t); + + switch (transport_state) { + case JackTransportStopped: + com_play( arg ); + break; + case JackTransportRolling: + com_stop( arg ); + break; + case JackTransportStarting: + fprintf(stderr, "state: Starting - no transport toggling"); + break; + default: + fprintf(stderr, "unexpected state: no transport toggling"); + } +} /* Change the tempo for the entire timeline, not just from the current * location. */ @@ -255,6 +277,7 @@ command_t commands[] = { {"stop", com_stop, "Stop transport"}, {"tempo", com_tempo, "Set beat tempo "}, {"timeout", com_timeout, "Set sync timeout in "}, + {"toggle", com_toggle, "Toggle transport rolling"}, {"?", com_help, "Synonym for `help'" }, {(char *)NULL, (cmd_function_t *)NULL, (char *)NULL } };