diff options
author | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2015-04-30 21:16:01 +0000 |
---|---|---|
committer | IOhannes m zmölnig <zmoelnig@iem.at> | 2015-10-14 15:12:02 +0200 |
commit | a95e3458aaa5f11f78006632be7b3f87d83febcd (patch) | |
tree | ff648df535cf6618f7ac8e00b094aece140c40ec /jack_transport | |
parent | ca3f35ee0b459fce8554f339910484cd32f35b9f (diff) |
imported patch from Patrice Colet
svn path=/trunk/externals/tb/; revision=17460
Diffstat (limited to 'jack_transport')
-rw-r--r-- | jack_transport/jack_transport.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/jack_transport/jack_transport.c b/jack_transport/jack_transport.c index 84b269e..e9efd11 100644 --- a/jack_transport/jack_transport.c +++ b/jack_transport/jack_transport.c @@ -24,27 +24,36 @@ static t_class *jack_transport_class; + +float time_beats_per_bar = 4.0; +float time_beat_type = 1.0 / 4.0; +double time_ticks_per_beat = 1920.0; +double time_beats_per_minute = 120.0; + typedef struct _jack_transport { t_object x_obj; t_outlet * x_outlet; + t_outlet * x_outlet_bar; + t_outlet * x_outlet_beat; + t_outlet * x_outlet_beat_type; + t_outlet * x_outlet_beats_per_bar; + t_outlet * x_outlet_beats_per_minute; jack_client_t* x_jack_client; jack_position_t* x_pos; } jack_transport_t; - /* connect to jack server */ static int jack_transport_connect(jack_transport_t * x) { char port_name[80] = ""; - static int client = 0; do { sprintf(port_name,"pure_data_jack_transport_%d",client); client++; } - while (((x->x_jack_client = jack_client_new (port_name)) == 0) && + while (((x->x_jack_client = jack_client_open (port_name, (jack_options_t)0, NULL)) == 0) && client < 100); client = 0; @@ -67,7 +76,13 @@ static jack_transport_t * jack_transport_new(void) int status = 0; jack_transport_t *x = (jack_transport_t*) pd_new(jack_transport_class); + x->x_outlet = outlet_new(&x->x_obj, NULL); + x->x_outlet_bar = outlet_new(&x->x_obj, NULL); + x->x_outlet_beat = outlet_new(&x->x_obj, NULL); + x->x_outlet_beat_type = outlet_new(&x->x_obj, NULL); + x->x_outlet_beats_per_bar = outlet_new(&x->x_obj, NULL); + x->x_outlet_beats_per_minute = outlet_new(&x->x_obj, NULL); x->x_pos = (jack_position_t*) getbytes(sizeof(jack_position_t)); status = jack_transport_connect(x); @@ -87,6 +102,17 @@ static void jack_transport_stoper(jack_transport_t * x) return; } +static void jack_transport_timebase(jack_transport_t * x) +{ + jack_position_t pos; + const int rolling = (jack_transport_query(x->x_jack_client, &pos) == JackTransportRolling); + outlet_float(x->x_outlet_bar, pos.bar); + outlet_float(x->x_outlet_beat, pos.beat); + outlet_float(x->x_outlet_beat_type, pos.beat_type); + outlet_float(x->x_outlet_beats_per_bar, pos.beats_per_bar); + outlet_float(x->x_outlet_beats_per_minute, pos.beats_per_minute); +} + static void jack_transport_bang(jack_transport_t * x) { float f; @@ -94,7 +120,7 @@ static void jack_transport_bang(jack_transport_t * x) return; f = (float)jack_get_current_transport_frame(x->x_jack_client); - + jack_transport_timebase(x); outlet_float(x->x_outlet, f); } |