Browse Source

added a toggle command

This command allows toggling between play and stop state
pull/9/head
Holger Dehnhardt GitHub 8 years ago
parent
commit
ef8029546c
1 changed files with 23 additions and 0 deletions
  1. +23
    -0
      transport.c

+ 23
- 0
transport.c View File

@@ -214,6 +214,28 @@ void com_timeout(char *arg)
jack_set_sync_timeout(client, (jack_time_t) (timeout*1000000)); 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, &current);

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 /* Change the tempo for the entire timeline, not just from the current
* location. */ * location. */
@@ -255,6 +277,7 @@ command_t commands[] = {
{"stop", com_stop, "Stop transport"}, {"stop", com_stop, "Stop transport"},
{"tempo", com_tempo, "Set beat tempo <beats_per_min>"}, {"tempo", com_tempo, "Set beat tempo <beats_per_min>"},
{"timeout", com_timeout, "Set sync timeout in <seconds>"}, {"timeout", com_timeout, "Set sync timeout in <seconds>"},
{"toggle", com_toggle, "Toggle transport rolling"},
{"?", com_help, "Synonym for `help'" }, {"?", com_help, "Synonym for `help'" },
{(char *)NULL, (cmd_function_t *)NULL, (char *)NULL } {(char *)NULL, (cmd_function_t *)NULL, (char *)NULL }
}; };


Loading…
Cancel
Save