Fixup tempo/time points, which were broken by recent renaming.

This commit is contained in:
Jonathan Moore Liles 2008-05-07 17:55:01 -05:00
parent e050332e36
commit 9df497a50a
7 changed files with 72 additions and 72 deletions

View File

@ -173,5 +173,14 @@ Project::create ( const char *name, const char *template_name )
/* TODO: copy template */
return open( name );
if ( open( name ) )
{
/* add the bare essentials */
timeline->beats_per_minute( 0, 120 );
timeline->time( 0, 4, 4 );
return true;
}
else
return false;
}

View File

@ -25,26 +25,29 @@
void
Tempo_Point::get ( Log_Entry &e ) const
{
e.add( ":start", _r->offset );
Sequence_Point::get( e );
e.add( ":tempo", _tempo );
}
void
Tempo_Point::set ( Log_Entry &e )
{
Sequence_Point::set( e );
for ( int i = 0; i < e.size(); ++i )
{
const char *s, *v;
e.get( i, &s, &v );
if ( ! strcmp( s, ":start" ) )
_r->offset = atol( v );
else if ( ! strcmp( s, ":tempo" ) )
if ( ! strcmp( s, ":tempo" ) )
_tempo = atof( v );
/* FIXME: we need to add this to the time track on creation!!! */
timeline->tempo_track->add( this );
/* /\* FIXME: we need to add this to the time track on creation!!! *\/ */
/* timeline->tempo_track->add( this ); */
}
timeline->redraw();
@ -53,13 +56,20 @@ Tempo_Point::set ( Log_Entry &e )
}
Tempo_Point::Tempo_Point ( )
{
timeline->tempo_track->add( this );
}
Tempo_Point::Tempo_Point ( nframes_t when, float bpm )
{
_tempo = bpm;
_r->offset = when;
_r->start = when;
_make_label();
timeline->tempo_track->add( this );
log_create();
}

View File

@ -42,9 +42,7 @@ protected:
virtual void get ( Log_Entry &e ) const;
void set ( Log_Entry &e );
Tempo_Point ( )
{
}
Tempo_Point ( );
public:

View File

@ -24,7 +24,9 @@
void
Time_Point::get ( Log_Entry &e ) const
{
e.add( ":start", _r->offset );
Sequence_Point::get( e );
e.add( ":beats_per_bar", _time.beats_per_bar );
e.add( ":beat_type", _time.beat_type );
}
@ -32,24 +34,48 @@ Time_Point::get ( Log_Entry &e ) const
void
Time_Point::set ( Log_Entry &e )
{
Sequence_Point::set( e );
for ( int i = 0; i < e.size(); ++i )
{
const char *s, *v;
e.get( i, &s, &v );
if ( ! strcmp( s, ":start" ) )
_r->offset = atol( v );
else if ( ! strcmp( s, ":beats_per_bar" ) )
if ( ! strcmp( s, ":beats_per_bar" ) )
_time.beats_per_bar = atoi( v );
else if ( ! strcmp( s, ":beat_type" ) )
_time.beat_type = atoi( v );
/* FIXME: we need to add this to the time track on creation!!! */
timeline->time_track->add( this );
/* /\* FIXME: we need to add this to the time track on creation!!! *\/ */
/* timeline->time_track->add( this ); */
}
timeline->redraw();
_make_label();
}
Time_Point::Time_Point ( ) : _time( 4, 4 )
{
timeline->time_track->add( this );
}
Time_Point::Time_Point ( nframes_t when, int bpb, int note ) : _time( bpb, note )
{
_r->offset = when;
_make_label();
timeline->time_track->add( this );
log_create();
}
Time_Point::Time_Point ( const Time_Point &rhs )
{
_r->offset = rhs._r->offset;
_time = rhs._time;
}

View File

@ -56,10 +56,6 @@ class Time_Point : public Sequence_Point
snprintf( _label, 40, "%d/%d", _time.beats_per_bar, _time.beat_type );
}
Time_Point ( ) : _time( 4, 4 )
{
}
protected:
@ -68,23 +64,18 @@ protected:
virtual void get ( Log_Entry &e ) const;
void set ( Log_Entry &e );
Time_Point ( );
public:
LOG_CREATE_FUNC( Time_Point );
Time_Point ( nframes_t when, int bpb, int note ) : _time( bpb, note )
{
_r->offset = when;
_make_label();
Time_Point ( nframes_t when, int bpb, int note );
Time_Point ( const Time_Point &rhs );
log_create();
}
Time_Point ( const Time_Point &rhs )
~Time_Point ( )
{
_r->offset = rhs._r->offset;
_time = rhs._time;
log_destroy();
}
Sequence_Widget *clone ( const Sequence_Widget *r )
@ -92,41 +83,9 @@ public:
return new Time_Point( *(Time_Point*)r );
}
~Time_Point ( )
{
log_destroy();
}
/* beats_per_bar ( void ) const { return _time.beats_per_bar; } */
/* beat_type ( void ) const { return _beat_type; } */
void time ( int bpb, int note ) { _time.beats_per_bar = bpb; _time.beat_type = note; }
time_sig time ( void ) const { return _time; }
/* Time_Point * */
/* at ( nframes_t when ) */
/* { */
/* for ( std::list <Sequence_Widget *>::const_reverse_iterator i = _widgets.rbegin(); */
/* i != _widgets.rend(); i++ ) */
/* if ( (*i)->offset() < when ) */
/* return ((Time_Point*)(*i)); */
/* return NULL; */
/* } */
/* int */
/* handle ( int m ) */
/* { */
/* int r = Sequence_Widget::handle( m ); */
/* if ( m == FL_RELEASE ) */
/* { */
/* _track->sort(); */
/* timeline->redraw(); */
/* } */
/* return r; */
/* } */
};
#undef __CLASS__

View File

@ -157,13 +157,6 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Wi
o->align( FL_ALIGN_LEFT );
tempo_track = o;
o->beats_per_minute( 0, 120 );
/* o->beats_per_minute( 48000 * 50, 250 ); */
/* o->beats_per_minute( 48000 * 120, 60 ); */
}
{
@ -175,8 +168,6 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Wi
o->align( FL_ALIGN_LEFT );
time_track = o;
o->time( 0, 4, 4 );
}
@ -253,6 +244,12 @@ Timeline::beats_per_minute ( nframes_t when, float bpm )
tempo_track->add( new Tempo_Point( when, bpm ) );
}
void
Timeline::time ( nframes_t when, int bpb, int note_type )
{
time_track->add( new Time_Point( when, bpb, note_type ) );
}
#if 0
struct BBT
{

View File

@ -141,6 +141,7 @@ public:
float beats_per_minute ( nframes_t when ) const;
int beats_per_bar ( nframes_t when ) const;
void beats_per_minute ( nframes_t when, float bpm );
void time ( nframes_t when, int bpb, int beat_type );
bool nearest_line ( nframes_t when, nframes_t *f ) const;
typedef void (measure_line_callback)( nframes_t frame, int X, int Y, int H, void *arg );