Browse Source

Big fix for loggability which was broken by the previous attempt at making Time and Tempo sequences unlogged.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
c3a20870f7
17 changed files with 170 additions and 120 deletions
  1. +8
    -17
      Timeline/Annotation_Sequence.H
  2. +1
    -0
      Timeline/Audio_Region.C
  3. +62
    -0
      Timeline/Audio_Sequence.C
  4. +7
    -51
      Timeline/Audio_Sequence.H
  5. +1
    -1
      Timeline/Control_Sequence.C
  6. +2
    -2
      Timeline/Control_Sequence.H
  7. +1
    -8
      Timeline/Loggable.C
  8. +32
    -18
      Timeline/Loggable.H
  9. +17
    -7
      Timeline/Sequence.C
  10. +5
    -2
      Timeline/Sequence.H
  11. +1
    -1
      Timeline/Sequence_Region.H
  12. +6
    -0
      Timeline/Tempo_Sequence.H
  13. +6
    -0
      Timeline/Time_Sequence.H
  14. +1
    -1
      Timeline/Timeline.C
  15. +8
    -6
      Timeline/Track.C
  16. +11
    -6
      Timeline/Track.H
  17. +1
    -0
      Timeline/main.C

+ 8
- 17
Timeline/Annotation_Sequence.H View File

@@ -24,7 +24,9 @@
#include "Annotation_Region.H" #include "Annotation_Region.H"
#include "Timeline.H" #include "Timeline.H"


class Annotation_Sequence : public Sequence, public Loggable
#include "Track.H"

class Annotation_Sequence : public Sequence
{ {


protected: protected:
@@ -51,13 +53,14 @@ protected:


assert( t ); assert( t );


t->track( this );
t->add( this );
} }
} }
} }


Annotation_Sequence ( ) : Sequence ( 0, 0, 0, 0 )
Annotation_Sequence ( ) : Sequence ( 0 )
{ {
color( fl_darker( FL_GREEN ) );
} }


public: public:
@@ -67,20 +70,15 @@ public:


Fl_Cursor cursor ( void ) const { return FL_CURSOR_INSERT; } Fl_Cursor cursor ( void ) const { return FL_CURSOR_INSERT; }


Annotation_Sequence ( Track *track ) : Sequence( 0, 0, 0, 0 )
Annotation_Sequence ( Track *track ) : Sequence( track )
{ {
_track = track;

color( fl_darker( FL_GREEN ) ); color( fl_darker( FL_GREEN ) );


log_create(); log_create();

// labeltype( FL_NO_LABEL );
} }


Annotation_Sequence ( int X, int Y, int W, int H ) : Sequence ( X, Y, W, H )
Annotation_Sequence ( int X, int Y, int W, int H ) : Sequence ( 0 )
{ {
// box( FL_UP_BOX );
} }


~Annotation_Sequence ( ) ~Annotation_Sequence ( )
@@ -88,13 +86,6 @@ public:
log_destroy(); log_destroy();
} }


/* void */
/* draw ( void ) */
/* { */
/* // timeline->draw_measure_BBT( x(), y(), w(), h(), FL_WHITE ); */
/* Sequence::draw(); */
/* } */

int handle ( int m ) int handle ( int m )
{ {




+ 1
- 0
Timeline/Audio_Region.C View File

@@ -23,6 +23,7 @@
#include "Waveform.H" #include "Waveform.H"


#include "Audio_Sequence.H" #include "Audio_Sequence.H"
#include "Track.H"


#include "dsp.h" #include "dsp.h"




+ 62
- 0
Timeline/Audio_Sequence.C View File

@@ -24,6 +24,68 @@


#include <Fl/fl_ask.H> #include <Fl/fl_ask.H>


#include "Track.H"

Audio_Sequence::Audio_Sequence ( Track *track ) : Sequence( track )
{

_track = track;

if ( track )
track->add( this );

log_create();

/* FIXME: temporary */
labeltype( FL_NO_LABEL );

}


Audio_Sequence::~Audio_Sequence ( )
{
log_destroy();
}


const Audio_Region *
Audio_Sequence::capture ( void ) const
{
return track()->capture();
}

void
Audio_Sequence::get ( Log_Entry &e ) const
{
e.add( ":t", _track );
e.add( ":n", name() );
}

void
Audio_Sequence::set ( Log_Entry &e )
{
for ( int i = 0; i < e.size(); ++i )
{
const char *s, *v;

e.get( i, &s, &v );

if ( ! strcmp( ":t", s ) )
{
int i;
sscanf( v, "%X", &i );
Track *t = (Track*)Loggable::find( i );

assert( t );

t->track( this );
}
else if ( ! strcmp( ":n", s ) )
name( strdup( v ) );
}
}


static static
void void
deurlify ( char *url ) deurlify ( char *url )


+ 7
- 51
Timeline/Audio_Sequence.H View File

@@ -21,76 +21,32 @@


#include "Sequence.H" #include "Sequence.H"
#include "Audio_Region.H" #include "Audio_Region.H"
#include "Track.H"


#include <FL/Fl_Input.H> #include <FL/Fl_Input.H>


class Audio_Sequence : public Sequence, public Loggable
class Audio_Sequence : public Sequence
{ {


protected: protected:


virtual void get ( Log_Entry &e ) const
{
e.add( ":t", _track );
e.add( ":n", name() );
}

void
set ( Log_Entry &e )
{
for ( int i = 0; i < e.size(); ++i )
{
const char *s, *v;

e.get( i, &s, &v );
void get ( Log_Entry &e ) const;


if ( ! strcmp( ":t", s ) )
{
int i;
sscanf( v, "%X", &i );
Track *t = (Track*)Loggable::find( i );
void set ( Log_Entry &e );


assert( t );

t->track( this );
}
else if ( ! strcmp( ":n", s ) )
name( strdup( v ) );
}
}

Audio_Sequence ( ) : Sequence( 0, 0, 0, 0 )
Audio_Sequence ( ) : Sequence( 0 )
{ {
} }





public: public:


LOG_CREATE_FUNC( Audio_Sequence ); LOG_CREATE_FUNC( Audio_Sequence );


Fl_Cursor cursor ( void ) const { return FL_CURSOR_DEFAULT; } Fl_Cursor cursor ( void ) const { return FL_CURSOR_DEFAULT; }


Audio_Sequence ( Track *track ) : Sequence( 0, 0, 0, 0, track )
{

_track = track;

if ( track )
track->add( this );

log_create();

/* FIXME: temporary */
labeltype( FL_NO_LABEL );


}

~Audio_Sequence ( )
{
log_destroy();
}
Audio_Sequence ( Track *track );
~Audio_Sequence ( );




Sequence * clone_empty ( void ) Sequence * clone_empty ( void )
@@ -107,7 +63,7 @@ public:
void dump ( void ); void dump ( void );
void remove_selected ( void ); void remove_selected ( void );


const Audio_Region *capture ( void ) const { return track()->capture(); }
const Audio_Region *capture ( void ) const;


nframes_t play ( sample_t *buf, nframes_t frame, nframes_t nframes, int channels ); nframes_t play ( sample_t *buf, nframes_t frame, nframes_t nframes, int channels );




+ 1
- 1
Timeline/Control_Sequence.C View File

@@ -29,7 +29,7 @@ bool Control_Sequence::draw_with_gradient = true;
bool Control_Sequence::draw_with_polygon = true; bool Control_Sequence::draw_with_polygon = true;
bool Control_Sequence::draw_with_grid = true; bool Control_Sequence::draw_with_grid = true;


Control_Sequence::Control_Sequence ( Track *track ) : Sequence( 0, 0, 0, 0 )
Control_Sequence::Control_Sequence ( Track *track ) : Sequence( 0 )
{ {
init(); init();




+ 2
- 2
Timeline/Control_Sequence.H View File

@@ -23,7 +23,7 @@
#include "Control_Point.H" #include "Control_Point.H"
#include "Port.H" #include "Port.H"


class Control_Sequence : public Sequence, public Loggable
class Control_Sequence : public Sequence
{ {
public: public:


@@ -46,7 +46,7 @@ protected:
virtual void get ( Log_Entry &e ) const; virtual void get ( Log_Entry &e ) const;
void set ( Log_Entry &e ); void set ( Log_Entry &e );


Control_Sequence ( ) : Sequence( 0, 0, 0, 1 )
Control_Sequence ( ) : Sequence( 0 )
{ {
init(); init();
} }


+ 1
- 8
Timeline/Loggable.C View File

@@ -249,14 +249,7 @@ Loggable::do_this ( const char *s, bool reverse )
Log_Entry e( sa ); Log_Entry e( sa );







assert( _class_map[ string( classname ) ] );

/* if ( ! _class_map[ string( classname ) ] ) */
/* printf( "error class %s is unregistered!\n", classname ); */
/* else */
ASSERT( _class_map[ string( classname ) ], "Journal contains an object of class \"%s\", but I don't know how to create such objects.", classname );


{ {
/* create */ /* create */


+ 32
- 18
Timeline/Loggable.H View File

@@ -37,23 +37,22 @@ using namespace std;
#include "debug.h" #include "debug.h"


/* welcome to C++ */ /* welcome to C++ */
class Loggable_ID
{

protected:
/* This class is just a dummy to allow base classes with null ids but
* whose children are really loggable. */


int _id;
/* class Loggable_ID */
/* { */


public:
/* public: */


Loggable_ID ( ) : _id( 0 ) { }
virtual ~Loggable_ID ( ) { }
/* Loggable_ID ( ) { } */
/* virtual ~Loggable_ID ( ) { } */


int id ( void ) { return _id; }
/* virtual int id ( void ) const = 0; */


virtual const char *class_name ( void ) const = 0;
/* virtual const char *class_name ( void ) const = 0; */


};
/* }; */


class Log_Entry; class Log_Entry;
class Loggable; class Loggable;
@@ -77,8 +76,11 @@ typedef Loggable *(create_func)(Log_Entry &);
LOG_NAME_FUNC( class ); \ LOG_NAME_FUNC( class ); \




#define LOG_NOT_LOGGABLE_FUNC( class ) \
virtual const char *class_name ( void ) const { return #class ; } \

class Logger; class Logger;
class Loggable : public Loggable_ID
class Loggable
{ {


static FILE *_fp; static FILE *_fp;
@@ -94,6 +96,7 @@ class Loggable : public Loggable_ID


private: private:


int _id;


char **_old_state; char **_old_state;
char **_new_state; char **_new_state;
@@ -117,6 +120,8 @@ private:


public: public:


int id ( void ) const { return _id; }

static bool open ( const char *filename ); static bool open ( const char *filename );
static bool close ( void ); static bool close ( void );
static void undo ( void ); static void undo ( void );
@@ -150,13 +155,19 @@ public:
return _loggables[ id - 1 ]; return _loggables[ id - 1 ];
} }


Loggable ( )
Loggable ( bool loggable=true )
{ {
_id = ++_log_id;
_old_state = NULL;
_nest = 0;
if ( loggable )
{
_id = ++_log_id;
_old_state = NULL;
_nest = 0;

_loggables.push_back( this );
}
else
_id = 0;


_loggables.push_back( this );
} }


/** must be called after construction in create() methods */ /** must be called after construction in create() methods */
@@ -201,6 +212,9 @@ public:
virtual void get ( Log_Entry &e ) const = 0; virtual void get ( Log_Entry &e ) const = 0;
virtual void set ( Log_Entry &e ) = 0; virtual void set ( Log_Entry &e ) = 0;


virtual const char *class_name ( void ) const = 0;


static bool do_this ( const char *s, bool reverse ); static bool do_this ( const char *s, bool reverse );


protected: protected:
@@ -356,7 +370,7 @@ public:
ADD( nframes_t, "%lu", (unsigned long)v ); ADD( nframes_t, "%lu", (unsigned long)v );
ADD( unsigned long, "%lu", v ); ADD( unsigned long, "%lu", v );
ADD( const char *, "\"%s\"", v ? v : "" ); ADD( const char *, "\"%s\"", v ? v : "" );
ADD( Loggable_ID *, "0x%X", v ? v->id() : 0 );
ADD( Loggable * , "0x%X", v ? v->id() : 0 );
ADD( float, "%f", v ); ADD( float, "%f", v );
ADD( double, "%f", v ); ADD( double, "%f", v );




+ 17
- 7
Timeline/Sequence.C View File

@@ -30,20 +30,30 @@


queue <Sequence_Widget *> Sequence::_delete_queue; queue <Sequence_Widget *> Sequence::_delete_queue;


Sequence::Sequence ( int X, int Y, int W, int H, Track *track ) : Fl_Widget( X, Y, W, H )
Sequence::Sequence ( Track *track ) : Fl_Widget( 0, 0, 0, 0 ), Loggable( true )
{ {
_name = NULL;
init();

_track = track; _track = track;


/* if ( track ) */
/* track->add( this ); */
// log_create();
}

Sequence::Sequence ( int X, int Y, int W, int H ) : Fl_Widget( X, Y, W, H ), Loggable( false )
{
init();
}

void
Sequence::init ( void )
{
_track = NULL;

_name = NULL;


box( FL_DOWN_BOX ); box( FL_DOWN_BOX );
// color( fl_darker( FL_GRAY ) );
color( FL_BACKGROUND_COLOR ); color( FL_BACKGROUND_COLOR );
align( FL_ALIGN_LEFT ); align( FL_ALIGN_LEFT );

// log_create();
} }


Sequence::~Sequence ( ) Sequence::~Sequence ( )


+ 5
- 2
Timeline/Sequence.H View File

@@ -38,11 +38,13 @@ class Sequence_Widget;


/* This is the base class for all track types. */ /* This is the base class for all track types. */


class Sequence : public Fl_Widget, public Loggable_ID
class Sequence : public Fl_Widget, public Loggable
{ {


static queue <Sequence_Widget *> _delete_queue; static queue <Sequence_Widget *> _delete_queue;


void init ( void );

protected: protected:


Track *_track; /* track this sequence belongs to */ Track *_track; /* track this sequence belongs to */
@@ -58,7 +60,8 @@ public:
/* welcome to C++ */ /* welcome to C++ */
LOG_NAME_FUNC( Sequence ); LOG_NAME_FUNC( Sequence );


Sequence ( int X, int Y, int W, int H, Track *track=0 );
Sequence ( Track *track=0 );
Sequence ( int X, int Y, int W, int H );


virtual ~Sequence ( ); virtual ~Sequence ( );




+ 1
- 1
Timeline/Sequence_Region.H View File

@@ -56,7 +56,7 @@ protected:


Sequence_Region ( ) Sequence_Region ( )
{ {
color( FL_CYAN );
} }


virtual ~Sequence_Region ( ) virtual ~Sequence_Region ( )


+ 6
- 0
Timeline/Tempo_Sequence.H View File

@@ -27,6 +27,12 @@
class Tempo_Sequence : public Sequence class Tempo_Sequence : public Sequence
{ {


protected:

/* not used */
void get ( Log_Entry &e ) const { }
void set ( Log_Entry &e ) { }

public: public:


Fl_Cursor cursor ( void ) const { return FL_CURSOR_DEFAULT; } Fl_Cursor cursor ( void ) const { return FL_CURSOR_DEFAULT; }


+ 6
- 0
Timeline/Time_Sequence.H View File

@@ -28,6 +28,12 @@ using std::list;
class Time_Sequence : public Sequence class Time_Sequence : public Sequence
{ {


protected:

/* not used */
void get ( Log_Entry &e ) const { }
void set ( Log_Entry &e ) { }

public: public:


Fl_Cursor cursor ( void ) const { return FL_CURSOR_DEFAULT; } Fl_Cursor cursor ( void ) const { return FL_CURSOR_DEFAULT; }


+ 1
- 1
Timeline/Timeline.C View File

@@ -918,7 +918,7 @@ Timeline::handle ( int m )


Track *t = new Track( name ); Track *t = new Track( name );


Sequence *o = new Audio_Sequence( t );
Audio_Sequence *o = new Audio_Sequence( t );


// new Control_Sequence( t ); // new Control_Sequence( t );




+ 8
- 6
Timeline/Track.C View File

@@ -93,7 +93,7 @@ Track::cb_button ( Fl_Widget *w )
show_all_takes( take_menu->menu()[ v ].value() ); show_all_takes( take_menu->menu()[ v ].value() );
return; return;
case 1: /* new */ case 1: /* new */
track( track()->clone_empty() );
track( (Audio_Sequence*)track()->clone_empty() );
return; return;
} }


@@ -101,7 +101,7 @@ Track::cb_button ( Fl_Widget *w )


for ( int i = takes->children(); i--; ) for ( int i = takes->children(); i--; )
{ {
Sequence *t = (Sequence*)takes->child( i );
Audio_Sequence *t = (Audio_Sequence*)takes->child( i );
if ( ! strcmp( s, t->name() ) ) if ( ! strcmp( s, t->name() ) )
{ {
track( t ); track( t );
@@ -319,7 +319,7 @@ Track::size ( int v )




void void
Track::add ( Sequence * t )
Track::add ( Audio_Sequence * t )
{ {
takes->insert( *t, 0 ); takes->insert( *t, 0 );
if ( ! t->name() ) if ( ! t->name() )
@@ -335,7 +335,7 @@ Track::add ( Sequence * t )
} }


void void
Track::remove ( Sequence *t )
Track::remove ( Audio_Sequence *t )
{ {
takes->remove( t ); takes->remove( t );


@@ -353,7 +353,7 @@ Track::remove ( Control_Sequence *t )
} }


void void
Track::track ( Sequence * t )
Track::track ( Audio_Sequence * t )
{ {
t->track( this ); t->track( this );


@@ -441,12 +441,13 @@ Track::draw ( void )
int int
Track::handle ( int m ) Track::handle ( int m )
{ {
Logger log( this );


switch ( m ) switch ( m )
{ {
case FL_MOUSEWHEEL: case FL_MOUSEWHEEL:
{ {
Logger log( this );

if ( ! Fl::event_shift() ) if ( ! Fl::event_shift() )
return 0; return 0;


@@ -463,6 +464,7 @@ Track::handle ( int m )
} }
case FL_PUSH: case FL_PUSH:
{ {
Logger log( this );


int X = Fl::event_x(); int X = Fl::event_x();
int Y = Fl::event_y(); int Y = Fl::event_y();


+ 11
- 6
Timeline/Track.H View File

@@ -48,6 +48,11 @@ class Port;
class Audio_Region; class Audio_Region;
class Audio_File; class Audio_File;



//class Audio_Sequence;

#include "Audio_Sequence.H"

class Track : public Fl_Group, public Loggable class Track : public Fl_Group, public Loggable
{ {


@@ -74,7 +79,7 @@ private:


enum { AUDIO } _type; enum { AUDIO } _type;


Sequence *_track;
Audio_Sequence *_track;


Audio_Region *_capture; /* capture region */ Audio_Region *_capture; /* capture region */
Audio_File *_capture_af; /* capture write source */ Audio_File *_capture_af; /* capture write source */
@@ -157,7 +162,7 @@ public:


if ( i ) if ( i )
{ {
Sequence *t = (Sequence*)Loggable::find( i );
Audio_Sequence *t = (Audio_Sequence*)Loggable::find( i );


/* FIXME: our track might not have been /* FIXME: our track might not have been
* defined yet... what should we do about this * defined yet... what should we do about this
@@ -192,8 +197,8 @@ public:
void remove ( Annotation_Sequence *t ); void remove ( Annotation_Sequence *t );


void add ( Control_Sequence *t ); void add ( Control_Sequence *t );
void add ( Sequence *t );
void remove ( Sequence *t );
void add ( Audio_Sequence *t );
void remove ( Audio_Sequence *t );
void remove ( Control_Sequence *t ); void remove ( Control_Sequence *t );


void select ( int X, int Y, int W, int H, bool include_control, bool merge_control ); void select ( int X, int Y, int W, int H, bool include_control, bool merge_control );
@@ -243,8 +248,8 @@ public:


static int width ( void ) { return 150; } static int width ( void ) { return 150; }


void track( Sequence * t );
Sequence * track ( void ) const { return _track; }
void track ( Audio_Sequence * t );
Audio_Sequence * track ( void ) const { return _track; }


void draw ( void ); void draw ( void );
int handle ( int m ); int handle ( int m );


+ 1
- 0
Timeline/main.C View File

@@ -90,6 +90,7 @@ main ( int argc, char **argv )
LOG_REGISTER_CREATE( Time_Point ); LOG_REGISTER_CREATE( Time_Point );
LOG_REGISTER_CREATE( Tempo_Point ); LOG_REGISTER_CREATE( Tempo_Point );
LOG_REGISTER_CREATE( Annotation_Point ); LOG_REGISTER_CREATE( Annotation_Point );
LOG_REGISTER_CREATE( Annotation_Region );
LOG_REGISTER_CREATE( Control_Point ); LOG_REGISTER_CREATE( Control_Point );
LOG_REGISTER_CREATE( Track ); LOG_REGISTER_CREATE( Track );
LOG_REGISTER_CREATE( Audio_Sequence ); LOG_REGISTER_CREATE( Audio_Sequence );


Loading…
Cancel
Save