From 44a0279e4c4f9008176b3290897c2d6db4211578 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Mon, 18 Jun 2012 21:27:59 -0700 Subject: [PATCH] Timeline: Just redraw the whole waveform when recording... --- timeline/src/Audio_Region.C | 24 +++++++++++------------- timeline/src/Audio_Region.H | 1 + timeline/src/Track.H | 2 -- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/timeline/src/Audio_Region.C b/timeline/src/Audio_Region.C index 7b9ed85..c119126 100644 --- a/timeline/src/Audio_Region.C +++ b/timeline/src/Audio_Region.C @@ -441,7 +441,7 @@ Audio_Region::draw_box( void ) color = fl_color_average( color, sequence()->color(), 0.75f ); - if ( this == ((Audio_Sequence*)sequence())->capture_region() ) + if ( recording() ) { color = FL_RED; } @@ -478,6 +478,12 @@ Audio_Region::peaks_ready_callback ( void *v ) Fl::awake(); } +bool +Audio_Region::recording ( void ) const +{ + return this == sequence()->track()->capture_region(); +} + /** Draw (part of) region. X, Y, W and H are the rectangle we're clipped to. */ void Audio_Region::draw ( void ) @@ -505,15 +511,10 @@ Audio_Region::draw ( void ) Fl_Color c = selected() ? fl_invert_color( _color ) : _color; - if ( sequence()->damage() & FL_DAMAGE_USER1 && this == sequence()->track()->capture_region() ) + if ( sequence()->damage() & FL_DAMAGE_USER1 && + recording() ) { - /* just draw the section with the updated peaks... */ - - nframes_t absolute_frame = _r->start + sequence()->track()->capture()->last_frame_drawn; - int nx = sequence()->x() + timeline->ts_to_x( absolute_frame - scroll_ts() ); - - W -= nx - X; - X = nx; + /* TODO: limit drawing. */ } /* calculate waveform offset due to scrolling */ @@ -555,7 +556,7 @@ Audio_Region::draw ( void ) Fl_Color c = Fl::get_color( _color ); - if ( this == ((Audio_Sequence*)sequence())->capture_region() ) + if ( recording() ) { // loop_peaks_needed = timeline->ts_to_x( _range.length ); c = FL_BLACK; @@ -640,9 +641,6 @@ Audio_Region::draw ( void ) } else WARNING( "Pbuf == %p, peaks = %lu", pbuf, (unsigned long)peaks ); - - if ( sequence()->damage() & FL_DAMAGE_USER1 && this == sequence()->track()->capture_region() ) - sequence()->track()->capture()->last_frame_drawn = start + peaks; if ( peaks < loop_peaks_needed ) { diff --git a/timeline/src/Audio_Region.H b/timeline/src/Audio_Region.H index 6ed700f..6920fc1 100644 --- a/timeline/src/Audio_Region.H +++ b/timeline/src/Audio_Region.H @@ -162,6 +162,7 @@ public: void normalize ( void ); void split ( nframes_t where ); + bool recording ( void ) const; /* Engine */ nframes_t read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channel ) const; diff --git a/timeline/src/Track.H b/timeline/src/Track.H index cbd960b..523165f 100644 --- a/timeline/src/Track.H +++ b/timeline/src/Track.H @@ -70,13 +70,11 @@ public: struct Capture { - nframes_t last_frame_drawn; Audio_File *audio_file; Audio_Region *region; Capture ( ) { - last_frame_drawn = 0; region = 0; audio_file = 0; }