Un-unify tempo and time sequences...

Add an update_tempomap() method to Timeline instead, which must be
called every time the time or tempo tracks are edited. This is perhaps as
ugly as the unified map was, but is at least a bit more compatible with
the possibility of moving all the meat of tempomapping into a library.
This commit is contained in:
Jonathan Moore Liles 2008-05-14 16:50:31 -05:00
parent bde6f2c557
commit b3d2cf94a1
8 changed files with 81 additions and 26 deletions

View File

@ -20,7 +20,7 @@
#include "Tempo_Point.H"
#include "Tempo_Map_Sequence.H"
#include "Tempo_Sequence.H"
#include "Timeline.H" // for timeline->tempo_track
void
@ -52,6 +52,7 @@ Tempo_Point::set ( Log_Entry &e )
}
timeline->update_tempomap();
timeline->redraw();
_make_label();
@ -61,6 +62,7 @@ Tempo_Point::set ( Log_Entry &e )
Tempo_Point::Tempo_Point ( )
{
timeline->tempo_track->add( this );
timeline->update_tempomap();
}
Tempo_Point::Tempo_Point ( nframes_t when, float bpm )
@ -71,6 +73,7 @@ Tempo_Point::Tempo_Point ( nframes_t when, float bpm )
_make_label();
timeline->tempo_track->add( this );
timeline->update_tempomap();
log_create();
}
@ -79,6 +82,8 @@ Tempo_Point::Tempo_Point ( nframes_t when, float bpm )
Tempo_Point::~Tempo_Point ( )
{
timeline->tempo_track->remove( this );
timeline->update_tempomap();
log_destroy();
}
@ -100,6 +105,7 @@ Tempo_Point::handle ( int m )
if ( m == FL_RELEASE )
{
sequence()->sort();
timeline->update_tempomap();
timeline->redraw();
}
return r;

View File

@ -17,11 +17,11 @@
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/
#include "Tempo_Map_Sequence.H"
#include "Tempo_Sequence.H"
void
Tempo_Map_Sequence::draw ( void )
Tempo_Sequence::draw ( void )
{
if ( ! fl_not_clipped( x(), y(), w(), h() ) )
return;
@ -59,7 +59,7 @@ Tempo_Map_Sequence::draw ( void )
}
int
Tempo_Map_Sequence::handle ( int m )
Tempo_Sequence::handle ( int m )
{
int r = Sequence::handle( m );

View File

@ -22,8 +22,6 @@
#include "Sequence.H"
#include "Tempo_Point.H"
#include <list>
class Tempo_Sequence : public Sequence
{

View File

@ -53,6 +53,7 @@ Time_Point::set ( Log_Entry &e )
}
timeline->update_tempomap();
timeline->redraw();
_make_label();
@ -62,6 +63,7 @@ Time_Point::set ( Log_Entry &e )
Time_Point::Time_Point ( ) : _time( 4, 4 )
{
timeline->time_track->add( this );
timeline->update_tempomap();
}
Time_Point::Time_Point ( nframes_t when, int bpb, int note ) : _time( bpb, note )
@ -70,6 +72,7 @@ Time_Point::Time_Point ( nframes_t when, int bpb, int note ) : _time( bpb, note
_make_label();
timeline->time_track->add( this );
timeline->update_tempomap();
log_create();
}
@ -78,5 +81,43 @@ Time_Point::Time_Point ( const Time_Point &rhs ) : Sequence_Point( rhs )
{
_time = rhs._time;
timeline->update_tempomap();
log_create();
}
Time_Point::~Time_Point ( )
{
timeline->time_track->remove( this );
timeline->update_tempomap();
log_destroy();
}
int
Time_Point::handle ( int m )
{
if ( m == FL_PUSH && Fl::event_button3() && ! ( Fl::event_state() & ( FL_ALT | FL_CTRL | FL_SHIFT ) ) )
{
/* float t = _tempo; */
/* edit( &t ); */
/* tempo( t ); */
return 0;
}
int r = Sequence_Widget::handle( m );
if ( m == FL_RELEASE )
{
sequence()->sort();
timeline->update_tempomap();
timeline->redraw();
}
return r;
}

View File

@ -36,9 +36,6 @@ struct time_sig
}
};
#define __CLASS__ "Time_Point"
class Time_Point : public Sequence_Point
{
time_sig _time;
@ -70,15 +67,11 @@ public:
Time_Point ( nframes_t when, int bpb, int note );
Time_Point ( const Time_Point &rhs );
~Time_Point ( )
{
log_destroy();
}
~Time_Point ( );
void time ( int bpb, int note ) { _time.beats_per_bar = bpb; _time.beat_type = note; }
time_sig time ( void ) const { return _time; }
};
int handle ( int m );
#undef __CLASS__
};

View File

@ -363,6 +363,24 @@ draw_measure_cb ( nframes_t frame, const BBT &bbt, void *arg )
/* FIXME: wrong place for this */
const float ticks_per_beat = 1920.0;
void
Timeline::update_tempomap ( void )
{
_tempomap.clear();
for ( list <Sequence_Widget *>::const_iterator i = time_track->_widgets.begin();
i != time_track->_widgets.end(); ++i )
_tempomap.push_back( *i );
for ( list <Sequence_Widget *>::const_iterator i = tempo_track->_widgets.begin();
i != tempo_track->_widgets.end(); ++i )
_tempomap.push_back( *i );
/* FIXME: shouldn't we ensure that time points always precede
tempo points at the same position? */
_tempomap.sort();
}
position_info
Timeline::solve_tempomap ( nframes_t frame ) const
{
@ -374,7 +392,6 @@ position_info
Timeline::render_tempomap( nframes_t start, nframes_t length, measure_line_callback * cb, void *arg ) const
{
const nframes_t end = start + length;
position_info pos;
@ -384,10 +401,6 @@ Timeline::render_tempomap( nframes_t start, nframes_t length, measure_line_callb
const nframes_t samples_per_minute = sample_rate() * 60;
list <Sequence_Widget*> & tempo_map = tempo_track->_widgets;
/* tempo_map.sort( Sequence_Widget::sort_func ); */
float bpm = 120.0f;
time_sig sig;
@ -402,8 +415,8 @@ Timeline::render_tempomap( nframes_t start, nframes_t length, measure_line_callb
/* FIXME: don't we need to sort so that Time_Points always preceed Tempo_Points? */
for ( list <Sequence_Widget *>::iterator i = tempo_map.begin();
i != tempo_map.end(); ++i )
for ( list <const Sequence_Widget *>::const_iterator i = _tempomap.begin();
i != _tempomap.end(); ++i )
{
if ( ! strcmp( (*i)->class_name(), "Tempo_Point" ) )
@ -421,9 +434,9 @@ Timeline::render_tempomap( nframes_t start, nframes_t length, measure_line_callb
}
{
list <Sequence_Widget *>::iterator n = i;
list <const Sequence_Widget *>::const_iterator n = i;
++n;
if ( n == tempo_map.end() )
if ( n == _tempomap.end() )
next = end;
else
// next = min( (*n)->start(), end );

View File

@ -112,6 +112,8 @@ class Timeline : public Fl_Overlay_Window, public RWLock
Timeline ( const Timeline &rhs );
Timeline & operator = ( const Timeline &rhs );
std::list <const Sequence_Widget*> _tempomap;
public:
enum snap_e {
@ -137,6 +139,8 @@ public:
Timeline ( int X, int Y, int W, int H, const char *L=0 );
void update_tempomap ( void );
nframes_t fpp ( void ) const { return 1 << _fpp; }
nframes_t length ( void ) const { return _length; }
nframes_t sample_rate ( void ) const { return engine->sample_rate(); }

View File

@ -24,8 +24,8 @@ Timeline/Sequence_Point.C \
Timeline/Sequence_Region.C \
Timeline/Sequence_Widget.C \
Timeline/TLE.C \
Timeline/Tempo_Map_Sequence.C \
Timeline/Tempo_Point.C \
Timeline/Tempo_Sequence.C \
Timeline/Time_Point.C \
Timeline/Timeline.C \
Timeline/Track.C \