Continue working on engine functionality.

This commit is contained in:
Jonathan Moore Liles 2008-04-08 15:06:38 -05:00
parent 2a26aa85ac
commit 0dff4be584
10 changed files with 113 additions and 9 deletions

View File

@ -22,7 +22,7 @@
/* Base class for all audio file library interfaces */
#include <stdlib.h>
typedef unsigned long nframes_t;
#include "types.h"
typedef float sample_t;
#include "Peaks.H"

View File

@ -13,6 +13,7 @@ SRCS= \
Audio_File_SF.C \
Port.C \
Disk_Stream.C \
Engine.C \
Loggable.C \
OBJS=$(SRCS:.C=.o)

54
Timeline/Mutex.H Normal file
View File

@ -0,0 +1,54 @@
/*******************************************************************************/
/* Copyright (C) 2008 Jonathan Moore Liles */
/* */
/* This program is free software; you can redistribute it and/or modify it */
/* under the terms of the GNU General Public License as published by the */
/* Free Software Foundation; either version 2 of the License, or (at your */
/* option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT */
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
/* more details. */
/* */
/* You should have received a copy of the GNU General Public License along */
/* with This program; see the file COPYING. If not,write to the Free Software */
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/
#pragma once
#include <pthread.h>
class Mutex
{
pthread_mutex_t _lock;
public:
Mutex ( )
{
// _lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
}
void
lock ( void )
{
pthread_mutex_lock( &_lock );
}
void
unlock ( void )
{
pthread_mutex_unlock( &_lock );
}
int
trylock ( void )
{
return pthread_mutex_trylock( &_lock );
}
};

View File

@ -21,7 +21,7 @@
#include <stdlib.h>
typedef unsigned long nframes_t;
#include "types.h"
struct Peak {
float min;

View File

@ -23,7 +23,7 @@
typedef float sample_t;
//typedef jack_nframes_t nframes_t;
typedef unsigned long nframes_t;
#include "types.h"
class Port
{

View File

@ -17,7 +17,6 @@
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/
#include "Timeline.H"
#include "Tempo_Track.H"
#include "Time_Track.H"
@ -597,3 +596,23 @@ Timeline::handle ( int m )
}
}
/**********/
/* Engine */
/**********/
/** call process() on each track header */
nframes_t
Timeline::process ( nframes_t nframes )
{
for ( int i = tracks->children(); i-- ; )
{
Track_Header *t = (Track_Header*)tracks->child( i );
t->process( nframes );
}
/* FIXME: BOGUS */
return nframes;
}

View File

@ -27,9 +27,12 @@
#include "Scalebar.H"
/* FIXME: this class needs a lot of cleaning up. Too many public
* members etc. */
/* #include "Audio_File.H" // just for nframes_t */
typedef unsigned long nframes_t;
#include "types.h"
#include <math.h>
#include <assert.h>
@ -74,8 +77,11 @@ struct Rectangle
};
class Engine;
class Timeline : public Fl_Overlay_Window
#include "Mutex.H"
class Timeline : public Fl_Overlay_Window, public Mutex
{
static void draw_clip ( void * v, int X, int Y, int W, int H );
@ -112,7 +118,6 @@ class Timeline : public Fl_Overlay_Window
public:
nframes_t xoffset;
int _yposition;
@ -139,4 +144,9 @@ public:
void select( const Rectangle &r );
private:
friend class Engine; // FIXME: only Engine::process() needs to be friended.x
nframes_t process ( nframes_t nframes );
};

View File

@ -38,6 +38,8 @@ class Region;
class Track_Widget;
#include "types.h"
/* This is the base class for all track types. */
class Track : public Fl_Widget, public Loggable
@ -124,4 +126,6 @@ public:
virtual int handle ( int m );
virtual void draw ( void );
virtual nframes_t process ( nframes_t nframes ) { return 0; }
};

View File

@ -96,6 +96,8 @@ Track_Header::Track_Header ( int X, int Y, int W, int H, const char *L ) :
_show_all_takes = false;
_size = 1;
// diskstream = new Disk_Stream( this );
Fl_Group::size( w(), height() );
Track_Header *o = this;
@ -276,3 +278,14 @@ Track_Header::add_control( Track *t )
resize();
}
/**********/
/* Engine */
/**********/
nframes_t
Track_Header::process ( nframes_t nframes )
{
return track()->process( nframes );
}

View File

@ -34,6 +34,8 @@
#include <vector>
using std::vector;
class Disk_Stream;
class Track_Header : public Fl_Group, public Loggable
{
@ -71,9 +73,8 @@ public:
Fl_Pack *control;
Fl_Pack *takes;
vector <Port> output; /* output ports... */
Disk_Stream *diskstream;
const char *class_name ( void ) { return "Track_Header"; }
@ -262,5 +263,7 @@ public:
}
}
nframes_t process ( nframes_t nframes );
};
#endif