diff options
author | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2015-04-30 21:38:10 +0000 |
---|---|---|
committer | IOhannes m zmölnig <zmoelnig@iem.at> | 2015-10-14 15:12:02 +0200 |
commit | 622422f9fe647dc63fe9c80b1b7205a17e621586 (patch) | |
tree | 94010b19fbb0ec835aa827e602baff74b399f524 | |
parent | a95e3458aaa5f11f78006632be7b3f87d83febcd (diff) |
collate extra outlets into a single one that emits routable messages
svn path=/trunk/externals/tb/; revision=17461
-rw-r--r-- | jack_transport/jack_transport.c | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/jack_transport/jack_transport.c b/jack_transport/jack_transport.c index e9efd11..f781346 100644 --- a/jack_transport/jack_transport.c +++ b/jack_transport/jack_transport.c @@ -25,20 +25,11 @@ 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; + t_outlet * x_outlet_info; jack_client_t* x_jack_client; jack_position_t* x_pos; } jack_transport_t; @@ -78,11 +69,7 @@ static jack_transport_t * jack_transport_new(void) 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_outlet_info = outlet_new(&x->x_obj, NULL); x->x_pos = (jack_position_t*) getbytes(sizeof(jack_position_t)); status = jack_transport_connect(x); @@ -105,12 +92,22 @@ static void jack_transport_stoper(jack_transport_t * x) static void jack_transport_timebase(jack_transport_t * x) { jack_position_t pos; + t_atom ap[8]; 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); + SETFLOAT(ap+0, pos.bar); + SETFLOAT(ap+1, pos.beat); + SETSYMBOL(ap+2, gensym("type")); + SETFLOAT(ap+3, pos.beat_type); + SETSYMBOL(ap+4, gensym("beats/bar")); + SETFLOAT(ap+5, pos.beats_per_bar); + SETSYMBOL(ap+6, gensym("bpm")); + SETFLOAT(ap+7, pos.beats_per_minute); + + outlet_anything(x->x_outlet_info, gensym("beat"), 2, ap+2); + outlet_anything(x->x_outlet_info, gensym("beat"), 2, ap+4); + outlet_anything(x->x_outlet_info, gensym("beat"), 2, ap+6); + outlet_anything(x->x_outlet_info, gensym("beat"), 1, ap+1); + outlet_anything(x->x_outlet_info, gensym("bar"), 1, ap+0); } static void jack_transport_bang(jack_transport_t * x) @@ -139,7 +136,7 @@ void jack_transport_setup(void) (t_newmethod)jack_transport_new, NULL, sizeof(jack_transport_t), CLASS_DEFAULT, 0); - class_addmethod(jack_transport_class, (t_method)jack_transport_starter, + class_addmethod(jack_transport_class, (t_method)jack_transport_starter, gensym("start"),0,0); class_addmethod(jack_transport_class, (t_method)jack_transport_stoper, gensym("stop"),0,0); |