From ad756bc1b29076215ff47e6c08d91773c2e92f8a Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sun, 27 Apr 2008 07:04:37 -0500 Subject: [PATCH] Don't fake sample rate. --- Timeline/Engine.C | 2 ++ Timeline/Engine.H | 3 +++ Timeline/Timeline.C | 14 ++++++++------ Timeline/Timeline.H | 7 ++++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Timeline/Engine.C b/Timeline/Engine.C index f5f378f..4d2ebf5 100644 --- a/Timeline/Engine.C +++ b/Timeline/Engine.C @@ -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; } diff --git a/Timeline/Engine.H b/Timeline/Engine.H index 1857868..f0fadbe 100644 --- a/Timeline/Engine.H +++ b/Timeline/Engine.H @@ -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 ); } }; diff --git a/Timeline/Timeline.C b/Timeline/Timeline.C index ac1583f..588b5c9 100644 --- a/Timeline/Timeline.C +++ b/Timeline/Timeline.C @@ -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(); } diff --git a/Timeline/Timeline.H b/Timeline/Timeline.H index 05b2a6e..6b1d5a0 100644 --- a/Timeline/Timeline.H +++ b/Timeline/Timeline.H @@ -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; }