Don't fake sample rate.

This commit is contained in:
Jonathan Moore Liles 2008-04-27 07:04:37 -05:00
parent 46e7378cb4
commit ad756bc1b2
4 changed files with 17 additions and 9 deletions

View File

@ -148,6 +148,8 @@ Engine::init ( void )
jack_activate( _client );
_sample_rate = frame_rate();
/* we don't need to create any ports until tracks are created */
return 1;
}

View File

@ -53,6 +53,8 @@ private:
friend class Transport;
jack_client_t * client ( void ) { return _client; }
nframes_t _sample_rate;
public:
Engine ( );
@ -63,6 +65,7 @@ public:
nframes_t nframes ( void ) const { return jack_get_buffer_size( _client ); }
float frame_rate ( void ) const { return jack_get_sample_rate( _client ); }
nframes_t sample_rate ( void ) const { return _sample_rate; }
float cpu_load ( void ) const { return jack_cpu_load( _client ); }
};

View File

@ -154,9 +154,11 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Wi
{
_sample_rate = 44100;
// sample_rate() = engine->sample_rate();
_fpp = 256;
_length = _sample_rate * 60 * 2;
// _length = sample_rate() * 60 * 2;
/* FIXME: hack */
_length = -1;
{
Fl_Pack *o = new Fl_Pack( X, rulers->y() + rulers->h(), W - vscroll->w(), 5000 );
@ -246,7 +248,7 @@ Timeline::nearest_line ( int ix )
for ( int x = ix - 10; x < ix + 10; ++x )
{
const int measure = ts_to_x( (double)(_sample_rate * 60) / beats_per_minute( x_to_ts( x - Track::width() ) + xoffset ));
const int measure = ts_to_x( (double)(sample_rate() * 60) / beats_per_minute( x_to_ts( x - Track::width() ) + xoffset ));
// const int abs_x = ts_to_x( xoffset ) + x - Track::width();
@ -292,7 +294,7 @@ Timeline::draw_measure ( int X, int Y, int W, int H, Fl_Color color, bool BBT )
for ( int x = X; x < X + W; ++x )
{
measure = ts_to_x( (double)(_sample_rate * 60) / beats_per_minute( x_to_ts( x - Track::width() ) + xoffset ) );
measure = ts_to_x( (double)(sample_rate() * 60) / beats_per_minute( x_to_ts( x - Track::width() ) + xoffset ) );
const int abs_x = ts_to_x( xoffset ) + x - Track::width();
@ -318,7 +320,7 @@ Timeline::draw_measure ( int X, int Y, int W, int H, Fl_Color color, bool BBT )
// if ( draw_hms )
{
const double seconds = (double)ts / _sample_rate;
const double seconds = (double)ts / sample_rate();
int S = (int)seconds;
int M = S / 60; S -= M * 60;
@ -901,7 +903,7 @@ Timeline::zoom ( float secs )
const int sw = w() - vscroll->w() - Track::width();
/* FIXME: we actually need to set this in the scalebar */
_fpp = (int)((secs * _sample_rate) / sw);
_fpp = (int)((secs * sample_rate()) / sw);
redraw();
}

View File

@ -73,7 +73,9 @@ struct Rectangle
};
class Engine;
#include "Engine.H" // for sample_rate()
// class Engine;
#include "RWLock.H"
@ -97,7 +99,6 @@ class Timeline : public Fl_Overlay_Window, public RWLock
void cb_scroll ( Fl_Widget *w );
float _fpp; /* frames per pixel */
nframes_t _sample_rate;
nframes_t _length;
@ -128,7 +129,7 @@ public:
float fpp ( void ) const { return _fpp; }
nframes_t length ( void ) const { return _length; }
nframes_t sample_rate ( void ) const { return _sample_rate; }
nframes_t sample_rate ( void ) const { return engine->sample_rate(); }
int ts_to_x( nframes_t ts ) const { return ts / _fpp; }
nframes_t x_to_ts ( int x ) const { return x * _fpp; }