Browse Source

Add (possibly bogus) timebase callback.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
682645f2e1
5 changed files with 39 additions and 7 deletions
  1. +1
    -1
      Timeline/Clock.H
  2. +33
    -0
      Timeline/Engine.C
  3. +2
    -0
      Timeline/Engine.H
  4. +2
    -5
      Timeline/Timeline.C
  5. +1
    -1
      Timeline/Timeline.H

+ 1
- 1
Timeline/Clock.H View File

@@ -94,7 +94,7 @@ public:
static void
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 );
}


+ 33
- 0
Timeline/Engine.C View File

@@ -21,6 +21,7 @@
#include "Transport.H"

#include "Timeline.H" // for process()
#include "Sequence_Widget.H" // for BBT and position info.

#define APP_NAME "Non-DAW" // FIXME: wrong place for this!

@@ -56,6 +57,12 @@ Engine::xrun ( void *arg )
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
@@ -121,6 +128,29 @@ Engine::sync ( jack_transport_state_t state, jack_position_t *pos )
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 */
int
Engine::process ( nframes_t nframes )
@@ -165,10 +195,13 @@ Engine::init ( void )

set_callback( process );
set_callback( xrun );

/* FIXME: should we wait to register this until after the project
has been loaded (and we have disk threads running)? */
set_callback( sync );

jack_set_timebase_callback( _client, 0, &Engine::timebase, this );

jack_activate( _client );

_sample_rate = frame_rate();


+ 2
- 0
Timeline/Engine.H View File

@@ -50,6 +50,8 @@ class Engine : public Mutex
int sync ( jack_transport_state_t state, jack_position_t *pos );
static int xrun ( void *arg );
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 & operator = ( const Engine &rhs );


+ 2
- 5
Timeline/Timeline.C View File

@@ -363,13 +363,10 @@ draw_measure_cb ( nframes_t frame, const BBT &bbt, void *arg )
/* FIXME: wrong place for this */
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
{
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 */


+ 1
- 1
Timeline/Timeline.H View File

@@ -152,7 +152,7 @@ public:

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_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;


Loading…
Cancel
Save