Re: Toggle Jack Transport CLI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi lista :)

Using an i3 shortcut, I can control my jack transport from everywhere, even when no jack application has focus :

bindsym $mod+p exec echo play | jack_transport
bindsym $mod+Shift+p exec echo stop | jack_transport

Thanks to FalkTX for the pipe trick BTW, I saw that on linuxmusicians ; This is very cool if you have some sort of wireless keyboard, but as you can see it's two different keystrokes, how do I make it so <command> toggles play/pause? Alternatively, how do I know when jack transport is rolling, so I can hack my way into making my own toggle script? I did my homework and read the inline --help of all the available jack commands on my machine :



With this patch, jack_transport should be able to toggle. I will suggest it to the jack-develop list but would be happy if some else can test it.


Holger

-----------------

diff --git a/example-clients/transport.c b/example-clients/transport.c
index c543b41..0b1130f 100644
--- a/example-clients/transport.c
+++ b/example-clients/transport.c
@@ -211,6 +211,29 @@ static void com_timeout(char *arg)
       jack_set_sync_timeout(client, (jack_time_t) (timeout*1000000));
}
 
+/* Set sync timeout in seconds. */
+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:
+               printf ("state: Starting - no transport toggling");
+               break;
+        default:
+               printf ("state: Unknown - no transport toggling");
+       }  
+}
+
 
/* Command parsing based on GNU readline info examples. */
 
@@ -238,6 +261,7 @@ command_t commands[] = {
       {"stop",        com_stop,       "Stop transport"},
       {"tempo",       com_tempo,      "Set beat tempo <beats_per_min>"},
       {"timeout",     com_timeout,    "Set sync timeout in <seconds>"},
+       {"toggle",      com_toggle,     "Toggle transport rolling"},
       {"?",           com_help,       "Synonym for `help'" },
       {(char *)NULL, (cmd_function_t *)NULL, (char *)NULL }
};
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@xxxxxxxxxxxxxxxxxxxx
http://lists.linuxaudio.org/listinfo/linux-audio-user

[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux