2 This program is free software; you can redistribute it and/or modify
3 it under the terms of the GNU General Public License as published by
4 the Free Software Foundation; either version 2 of the License, or
5 (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <jack/jack.h>
24 #include <jack/transport.h>
26 jack_client_t
*client
;
31 jack_position_t current
;
32 jack_transport_state_t transport_state
;
33 jack_nframes_t frame_time
;
35 transport_state
= jack_transport_query (client
, ¤t
);
36 frame_time
= jack_frame_time (client
);
38 printf ("frame = %u frame_time = %u usecs = %lld \t", current
.frame
, frame_time
, current
.usecs
);
40 switch (transport_state
) {
41 case JackTransportStopped
:
42 printf ("state: Stopped");
44 case JackTransportRolling
:
45 printf ("state: Rolling");
47 case JackTransportStarting
:
48 printf ("state: Starting");
51 printf ("state: [unknown]");
54 if (current
.valid
& JackPositionBBT
)
55 printf ("\tBBT: %3" PRIi32
"|%" PRIi32
"|%04"
56 PRIi32
, current
.bar
, current
.beat
, current
.tick
);
58 if (current
.valid
& JackPositionTimecode
)
59 printf ("\tTC: (%.6f, %.6f)",
60 current
.frame_time
, current
.next_time
);
65 jack_shutdown (void *arg
)
71 signal_handler (int sig
)
73 jack_client_close (client
);
74 fprintf (stderr
, "signal received, exiting ...\n");
79 main (int argc
, char *argv
[])
81 /* try to become a client of the JACK server */
83 if ((client
= jack_client_open ("showtime", JackNullOption
, NULL
)) == 0) {
84 fprintf (stderr
, "jack server not running?\n");
88 signal (SIGQUIT
, signal_handler
);
89 signal (SIGTERM
, signal_handler
);
90 signal (SIGHUP
, signal_handler
);
91 signal (SIGINT
, signal_handler
);
93 /* tell the JACK server to call `jack_shutdown()' if
94 it ever shuts down, either entirely, or if it
95 just decides to stop calling us.
98 jack_on_shutdown (client
, jack_shutdown
, 0);
100 /* tell the JACK server that we are ready to roll */
102 if (jack_activate (client
)) {
103 fprintf (stderr
, "cannot activate client");
112 jack_client_close (client
);