Cleanups.

This commit is contained in:
Jonathan Moore Liles 2008-02-16 17:28:48 -06:00
parent 41b62781d1
commit 8905484cb1
6 changed files with 52 additions and 15 deletions

View File

@ -1,13 +1,23 @@
CXXFLAGS=-ggdb CXXFLAGS=-ggdb -Wall -O0
LIBS=`fltk-config --ldflags` LIBS=`fltk-config --ldflags`
# CXXFLAGS=`fltk-config -cxxflags` # CXXFLAGS=`fltk-config -cxxflags`
OBJS=Waveform.o Region.o main.o Peaks.o SRCS= Waveform.C Region.C Peaks.C main.C
OBJS=$(SRCS:.C=.o)
.PHONEY: all clean install dist valgrind
all: test makedepend
.C.o: .C.o:
$(CXX) $(CXXFLAGS) -c $< -o $@ @ echo -n "Compiling: "; tput bold; tput setaf 3; echo $<; tput sgr0; true
@ $(CXX) $(CXXFLAGS) -c $< -o $@
$(OBJS): Makefile
test: $(OBJS) test: $(OBJS)
$(CXX) $(CXXFLAGS) $(LIBS) $(OBJS) -o $@ $(CXX) $(CXXFLAGS) $(LIBS) $(OBJS) -o $@
@ -15,6 +25,15 @@ test: $(OBJS)
clean: clean:
rm -f $(OBJS) test rm -f $(OBJS) test
valgrind: valgrind:
valgrind ./test valgrind ./test
TAGS: $(SRCS)
etags $(SRCS)
makedepend: $(SRCS)
@ echo -n Checking dependencies...
@ makedepend -f- -- $(CXXFLAGS) -- $(SRCS) > makedepend 2>/dev/null && echo done.
include makedepend

View File

@ -23,6 +23,7 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -99,8 +100,12 @@ Peaks::open ( const char *filename )
_peaks = (peaks*)mmap( NULL, _len, PROT_READ, MAP_SHARED, fd, 0 ); _peaks = (peaks*)mmap( NULL, _len, PROT_READ, MAP_SHARED, fd, 0 );
::close( fd );
if ( _peaks == MAP_FAILED ) if ( _peaks == MAP_FAILED )
printf( "failed to create mapping! " ); printf( "failed to create mapping! " );
_len = (_len - sizeof( int )) / sizeof( Peak ); _len = (_len - sizeof( int )) / sizeof( Peak );
return true;
} }

View File

@ -17,6 +17,8 @@
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/ /*******************************************************************************/
#pragma once
#include <stdlib.h> #include <stdlib.h>
struct Peak { struct Peak {

View File

@ -21,10 +21,25 @@
#include <FL/Fl_Scroll.H> #include <FL/Fl_Scroll.H>
#include "Clip.H"
struct Timeline { struct Timeline {
Fl_Scroll *scroll; Fl_Scroll *scroll;
float fpp; /* frames per pixel */ float fpp; /* frames per pixel */
int
ts_to_x( nframes_t ts )
{
return ts / fpp;
}
nframes_t
x_to_ts ( int x )
{
return x * fpp;
}
}; };
extern Timeline timeline; extern Timeline timeline;

View File

@ -61,7 +61,7 @@ Waveform::draw ( void )
} }
void void
Waveform::read_peaks ( tick_t X, float *hi, float *lo ) Waveform::read_peaks ( int X, float *hi, float *lo )
{ {
_clip->peaks()->read( X, hi, lo ); _clip->peaks()->read( X, hi, lo );
} }
@ -75,7 +75,7 @@ Waveform::draw ( int X, int Y, int W, int H )
int j; int j;
int start = (_start + (X - x())) * 2; // int start = (_start + (X - x())) * 2;
j = 0; j = 0;
for ( int x = X; x < X + W; ++x ) for ( int x = X; x < X + W; ++x )

View File

@ -24,8 +24,6 @@
#include "Timeline.H" #include "Timeline.H"
typedef unsigned long tick_t;
#include "Clip.H" #include "Clip.H"
class Waveform : public Fl_Widget class Waveform : public Fl_Widget
@ -35,10 +33,8 @@ protected:
Clip *_clip; /* clip this waveform represents */ Clip *_clip; /* clip this waveform represents */
// float *_peaks; nframes_t _start;
nframes_t _end;
tick_t _start;
tick_t _end;
float _scale; /* vertical scaling */ float _scale; /* vertical scaling */
float _zoom; /* horizontal zoom */ float _zoom; /* horizontal zoom */
@ -69,11 +65,11 @@ public:
void draw ( void ); void draw ( void );
void draw ( int X, int Y, int W, int H ); void draw ( int X, int Y, int W, int H );
void start ( tick_t s ) { _start = s; } void start ( nframes_t s ) { _start = s; }
void end ( tick_t e ) { _end = e; } void end ( nframes_t e ) { _end = e; }
// void peaks ( float *p ) { _peaks = p; } // void peaks ( float *p ) { _peaks = p; }
void normalize ( void ); void normalize ( void );
void read_peaks ( tick_t X, float *hi, float *lo ); void read_peaks ( int X, float *hi, float *lo );
}; };