/[cabestan]/callbacks.c
ViewVC logotype

Contents of /callbacks.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations)
Sun Oct 4 20:55:30 2009 UTC (9 years, 9 months ago) by ben
File MIME type: text/plain
File size: 1782 byte(s)
better stepr/stepf, and play
1 #include <gtk/gtk.h>
2 #include <jack/jack.h>
3 #include <jack/transport.h>
4
5 void on_play (GtkButton* button, gpointer app_data) {
6 jack_client_t* client = (jack_client_t*)app_data;
7 GtkWidget* pauseimage = NULL;
8 GtkWidget* playimage = NULL;
9 jack_position_t tpos;
10 jack_transport_state_t tstate;
11 gboolean playing;
12
13 tstate = jack_transport_query(client, &tpos);
14 playing = (tstate == JackTransportRolling || tstate == JackTransportLooping);
15 if (!playing) {
16 jack_transport_start(client);
17 pauseimage = gtk_image_new_from_stock(GTK_STOCK_MEDIA_PAUSE, GTK_ICON_SIZE_BUTTON);
18 gtk_button_set_image(GTK_BUTTON(button), pauseimage);
19 playing = TRUE;
20 } else {
21 jack_transport_stop(client);
22 playimage = gtk_image_new_from_stock(GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_BUTTON);
23 gtk_button_set_image(GTK_BUTTON(button), playimage);
24 playing = FALSE;
25 }
26 }
27
28 void on_rewind (GtkButton* button, gpointer app_data) {
29 jack_client_t* client = (jack_client_t*)app_data;
30
31 jack_transport_locate(client, 0); /* go to frame 0 */
32 button = NULL;
33 }
34
35 void on_stepf (GtkButton* button, gpointer app_data) {
36 jack_client_t* client = (jack_client_t*)app_data;
37 jack_position_t tpos;
38 float rate, tloc;
39
40 jack_transport_query(client, &tpos);
41 rate = (float)tpos.frame_rate;
42 tloc = (((float)tpos.frame / rate) + 1) * rate;
43 if (tloc < 0.0f) tloc = 0.0f;
44 jack_transport_locate(client, (jack_nframes_t) tloc);
45 button = NULL;
46 }
47
48 void on_stepr (GtkButton* button, gpointer app_data) {
49 jack_client_t* client = (jack_client_t*)app_data;
50 jack_position_t tpos;
51 float rate, tloc;
52
53 jack_transport_query(client, &tpos);
54 rate = (float)tpos.frame_rate;
55 tloc = (((float)tpos.frame / rate) - 1) * rate;
56 if (tloc < 0.0f) tloc = 0.0f;
57 jack_transport_locate(client, (jack_nframes_t) tloc);
58 button = NULL;
59 }

  ViewVC Help
Powered by ViewVC 1.1.26