@@ -94,7 +94,7 @@ public: | |||||
static void | static void | ||||
frame_to_BBT ( char *dst, int n, nframes_t frame ) | frame_to_BBT ( char *dst, int n, nframes_t frame ) | ||||
{ | { | ||||
struct BBT bbt = timeline->solve_tempomap( frame ); | |||||
struct BBT bbt = timeline->solve_tempomap( frame ).bbt; | |||||
snprintf( dst, n, "%03d|%1d|%04d", bbt.bar + 1, bbt.beat + 1, bbt.tick ); | snprintf( dst, n, "%03d|%1d|%04d", bbt.bar + 1, bbt.beat + 1, bbt.tick ); | ||||
} | } | ||||
@@ -21,6 +21,7 @@ | |||||
#include "Transport.H" | #include "Transport.H" | ||||
#include "Timeline.H" // for process() | #include "Timeline.H" // for process() | ||||
#include "Sequence_Widget.H" // for BBT and position info. | |||||
#define APP_NAME "Non-DAW" // FIXME: wrong place for this! | #define APP_NAME "Non-DAW" // FIXME: wrong place for this! | ||||
@@ -56,6 +57,12 @@ Engine::xrun ( void *arg ) | |||||
return ((Engine*)arg)->xrun(); | return ((Engine*)arg)->xrun(); | ||||
} | } | ||||
void | |||||
Engine::timebase ( jack_transport_state_t state, jack_nframes_t nframes, jack_position_t *pos, int new_pos, void *arg ) | |||||
{ | |||||
((Engine*)arg)->timebase( state, nframes, pos, new_pos ); | |||||
} | |||||
void | void | ||||
@@ -121,6 +128,29 @@ Engine::sync ( jack_transport_state_t state, jack_position_t *pos ) | |||||
return 0; | return 0; | ||||
} | } | ||||
/* THREAD: RT */ | |||||
void | |||||
Engine::timebase ( jack_transport_state_t state, jack_nframes_t nframes, jack_position_t *pos, int new_pos ) | |||||
{ | |||||
position_info pi = timeline->solve_tempomap( pos->frame ); | |||||
pos->valid = JackPositionBBT; | |||||
pos->beats_per_bar = pi.beats_per_bar; | |||||
pos->beat_type = pi.beat_type; | |||||
pos->beats_per_minute = pi.tempo; | |||||
pos->bar = pi.bbt.bar + 1; | |||||
pos->beat = pi.bbt.beat + 1; | |||||
pos->tick = pi.bbt.tick; | |||||
pos->ticks_per_beat = 1920.0; /* FIXME: wrong place for this */ | |||||
/* FIXME: fill this in */ | |||||
pos->bar_start_tick = 0; | |||||
} | |||||
/* THREAD: RT */ | /* THREAD: RT */ | ||||
int | int | ||||
Engine::process ( nframes_t nframes ) | Engine::process ( nframes_t nframes ) | ||||
@@ -165,10 +195,13 @@ Engine::init ( void ) | |||||
set_callback( process ); | set_callback( process ); | ||||
set_callback( xrun ); | set_callback( xrun ); | ||||
/* FIXME: should we wait to register this until after the project | /* FIXME: should we wait to register this until after the project | ||||
has been loaded (and we have disk threads running)? */ | has been loaded (and we have disk threads running)? */ | ||||
set_callback( sync ); | set_callback( sync ); | ||||
jack_set_timebase_callback( _client, 0, &Engine::timebase, this ); | |||||
jack_activate( _client ); | jack_activate( _client ); | ||||
_sample_rate = frame_rate(); | _sample_rate = frame_rate(); | ||||
@@ -50,6 +50,8 @@ class Engine : public Mutex | |||||
int sync ( jack_transport_state_t state, jack_position_t *pos ); | int sync ( jack_transport_state_t state, jack_position_t *pos ); | ||||
static int xrun ( void *arg ); | static int xrun ( void *arg ); | ||||
int xrun ( void ); | int xrun ( void ); | ||||
static void timebase ( jack_transport_state_t state, jack_nframes_t nframes, jack_position_t *pos, int new_pos, void *arg ); | |||||
void timebase ( jack_transport_state_t state, jack_nframes_t nframes, jack_position_t *pos, int new_pos ); | |||||
Engine ( const Engine &rhs ); | Engine ( const Engine &rhs ); | ||||
Engine & operator = ( const Engine &rhs ); | Engine & operator = ( const Engine &rhs ); | ||||
@@ -363,13 +363,10 @@ draw_measure_cb ( nframes_t frame, const BBT &bbt, void *arg ) | |||||
/* FIXME: wrong place for this */ | /* FIXME: wrong place for this */ | ||||
const float ticks_per_beat = 1920.0; | const float ticks_per_beat = 1920.0; | ||||
/** return the BBT values for point in time /frame/ */ | |||||
BBT | |||||
position_info | |||||
Timeline::solve_tempomap ( nframes_t frame ) const | Timeline::solve_tempomap ( nframes_t frame ) const | ||||
{ | { | ||||
position_info pos = render_tempomap( frame, 1, 0, 0 ); | |||||
return pos.bbt; | |||||
return render_tempomap( frame, 1, 0, 0 ); | |||||
} | } | ||||
/** draw appropriate measure lines inside the given bounding box */ | /** draw appropriate measure lines inside the given bounding box */ | ||||
@@ -152,7 +152,7 @@ public: | |||||
typedef void (measure_line_callback)( nframes_t frame, const BBT & bbt, void *arg ); | typedef void (measure_line_callback)( nframes_t frame, const BBT & bbt, void *arg ); | ||||
BBT solve_tempomap ( nframes_t when ) const; | |||||
position_info solve_tempomap ( nframes_t when ) const; | |||||
void draw_measure_lines ( int X, int Y, int W, int H, Fl_Color color ); | void draw_measure_lines ( int X, int Y, int W, int H, Fl_Color color ); | ||||
void draw_measure_BBT ( int X, int Y, int W, int H, Fl_Color color ); | void draw_measure_BBT ( int X, int Y, int W, int H, Fl_Color color ); | ||||
position_info render_tempomap ( nframes_t start, nframes_t length, measure_line_callback *cb, void *arg ) const; | position_info render_tempomap ( nframes_t start, nframes_t length, measure_line_callback *cb, void *arg ) const; | ||||