From 8905484cb10de67489a267c5e9cbe7636fdf5431 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sat, 16 Feb 2008 17:28:48 -0600 Subject: [PATCH] Cleanups. --- Makefile | 27 +++++++++++++++++++++++---- Peaks.C | 5 +++++ Peaks.H | 2 ++ Timeline.H | 15 +++++++++++++++ Waveform.C | 4 ++-- Waveform.H | 14 +++++--------- 6 files changed, 52 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 05c0719..56e5f92 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,23 @@ -CXXFLAGS=-ggdb +CXXFLAGS=-ggdb -Wall -O0 LIBS=`fltk-config --ldflags` # 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: - $(CXX) $(CXXFLAGS) -c $< -o $@ + @ echo -n "Compiling: "; tput bold; tput setaf 3; echo $<; tput sgr0; true + @ $(CXX) $(CXXFLAGS) -c $< -o $@ + +$(OBJS): Makefile + test: $(OBJS) $(CXX) $(CXXFLAGS) $(LIBS) $(OBJS) -o $@ @@ -15,6 +25,15 @@ test: $(OBJS) clean: rm -f $(OBJS) test - valgrind: valgrind ./test + +TAGS: $(SRCS) + etags $(SRCS) + +makedepend: $(SRCS) + @ echo -n Checking dependencies... + @ makedepend -f- -- $(CXXFLAGS) -- $(SRCS) > makedepend 2>/dev/null && echo done. + + +include makedepend diff --git a/Peaks.C b/Peaks.C index 3da5ac6..0b7a4a7 100644 --- a/Peaks.C +++ b/Peaks.C @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -99,8 +100,12 @@ Peaks::open ( const char *filename ) _peaks = (peaks*)mmap( NULL, _len, PROT_READ, MAP_SHARED, fd, 0 ); + ::close( fd ); + if ( _peaks == MAP_FAILED ) printf( "failed to create mapping! " ); _len = (_len - sizeof( int )) / sizeof( Peak ); + + return true; } diff --git a/Peaks.H b/Peaks.H index 1c0dd9a..8d54052 100644 --- a/Peaks.H +++ b/Peaks.H @@ -17,6 +17,8 @@ /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /*******************************************************************************/ +#pragma once + #include struct Peak { diff --git a/Timeline.H b/Timeline.H index e89d6db..bce934b 100644 --- a/Timeline.H +++ b/Timeline.H @@ -21,10 +21,25 @@ #include +#include "Clip.H" + struct Timeline { Fl_Scroll *scroll; 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; diff --git a/Waveform.C b/Waveform.C index 9e0b5e0..b4a4f5d 100644 --- a/Waveform.C +++ b/Waveform.C @@ -61,7 +61,7 @@ Waveform::draw ( 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 ); } @@ -75,7 +75,7 @@ Waveform::draw ( int X, int Y, int W, int H ) int j; - int start = (_start + (X - x())) * 2; +// int start = (_start + (X - x())) * 2; j = 0; for ( int x = X; x < X + W; ++x ) diff --git a/Waveform.H b/Waveform.H index 7b3713e..35c4f31 100644 --- a/Waveform.H +++ b/Waveform.H @@ -24,8 +24,6 @@ #include "Timeline.H" -typedef unsigned long tick_t; - #include "Clip.H" class Waveform : public Fl_Widget @@ -35,10 +33,8 @@ protected: Clip *_clip; /* clip this waveform represents */ -// float *_peaks; - - tick_t _start; - tick_t _end; + nframes_t _start; + nframes_t _end; float _scale; /* vertical scaling */ float _zoom; /* horizontal zoom */ @@ -69,11 +65,11 @@ public: void draw ( void ); void draw ( int X, int Y, int W, int H ); - void start ( tick_t s ) { _start = s; } - void end ( tick_t e ) { _end = e; } + void start ( nframes_t s ) { _start = s; } + void end ( nframes_t e ) { _end = e; } // void peaks ( float *p ) { _peaks = p; } void normalize ( void ); - void read_peaks ( tick_t X, float *hi, float *lo ); + void read_peaks ( int X, float *hi, float *lo ); };