/[cabestan]/callbacks.c
ViewVC logotype

Annotation of /callbacks.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (hide annotations)
Mon Oct 5 01:58:05 2009 UTC (10 years ago) by ben
File MIME type: text/plain
File size: 2131 byte(s)
version 0.1
1 ben 1 #include <gtk/gtk.h>
2     #include <jack/jack.h>
3     #include <jack/transport.h>
4 ben 3 #include "cabestan.h"
5 ben 1
6     void on_play (GtkButton* button, gpointer app_data) {
7     jack_client_t* client = (jack_client_t*)app_data;
8     GtkWidget* pauseimage = NULL;
9     GtkWidget* playimage = NULL;
10 ben 2 jack_position_t tpos;
11     jack_transport_state_t tstate;
12     gboolean playing;
13 ben 1
14 ben 2 tstate = jack_transport_query(client, &tpos);
15     playing = (tstate == JackTransportRolling || tstate == JackTransportLooping);
16 ben 1 if (!playing) {
17     jack_transport_start(client);
18     pauseimage = gtk_image_new_from_stock(GTK_STOCK_MEDIA_PAUSE, GTK_ICON_SIZE_BUTTON);
19     gtk_button_set_image(GTK_BUTTON(button), pauseimage);
20     playing = TRUE;
21     } else {
22     jack_transport_stop(client);
23     playimage = gtk_image_new_from_stock(GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_BUTTON);
24     gtk_button_set_image(GTK_BUTTON(button), playimage);
25     playing = FALSE;
26     }
27     }
28    
29     void on_rewind (GtkButton* button, gpointer app_data) {
30     jack_client_t* client = (jack_client_t*)app_data;
31    
32     jack_transport_locate(client, 0); /* go to frame 0 */
33     button = NULL;
34     }
35    
36     void on_stepf (GtkButton* button, gpointer app_data) {
37     jack_client_t* client = (jack_client_t*)app_data;
38 ben 3 jack_position_t pos;
39     float rate, loc;
40 ben 1
41 ben 3 jack_transport_query(client, &pos);
42     rate = (float)pos.frame_rate;
43     loc = (((float)pos.frame / rate) + 0.001) * rate; /* one ms step */
44     if (loc < 0.0f) loc = 0.0f;
45     jack_transport_locate(client, (jack_nframes_t) loc);
46 ben 1 button = NULL;
47     }
48    
49     void on_stepr (GtkButton* button, gpointer app_data) {
50     jack_client_t* client = (jack_client_t*)app_data;
51 ben 3 jack_position_t pos;
52     float rate, loc;
53 ben 1
54 ben 3 jack_transport_query(client, &pos);
55     rate = (float)pos.frame_rate;
56     loc = (((float)pos.frame / rate) - 0.001) * rate; /* one ms step */
57     if (loc < 0.0f) loc = 0.0f;
58     jack_transport_locate(client, (jack_nframes_t) loc);
59 ben 1 button = NULL;
60     }
61 ben 3
62     gboolean refresh_timeline (gpointer app_data) {
63     AppData* d = (AppData*) app_data;
64     jack_position_t pos;
65     gchar* time;
66    
67     jack_transport_query(d->jackd_client, &pos);
68     time = format_time((float)pos.frame / (float)pos.frame_rate);
69     gtk_label_set_markup(GTK_LABEL(d->timeline), time);
70    
71     return TRUE;
72     }
73    

  ViewVC Help
Powered by ViewVC 1.1.26