From a27d0b171876d7839d1b7bf66139052166163d1f Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Wed, 13 Jun 2012 18:28:49 -0700 Subject: [PATCH] Timeline: Add basic punch in/out support (may require latency compensation). --- timeline/src/Engine/Timeline.C | 6 ++++++ timeline/src/Engine/Track.C | 2 +- timeline/src/TLE.fl | 10 +++++++++- timeline/src/Timeline.C | 9 +++++++++ timeline/src/Transport.C | 18 +++++++++++++++++- timeline/src/Transport.H | 4 ++-- 6 files changed, 44 insertions(+), 5 deletions(-) diff --git a/timeline/src/Engine/Timeline.C b/timeline/src/Engine/Timeline.C index db80700..4fd37b3 100644 --- a/timeline/src/Engine/Timeline.C +++ b/timeline/src/Engine/Timeline.C @@ -40,6 +40,9 @@ Timeline::record ( void ) nframes_t frame = transport->frame; + if ( transport->punch_enabled() && frame < range_start() ) + frame = range_start(); + DMESSAGE( "Going to record starting at frame %lu", (unsigned long)frame ); for ( int i = tracks->children(); i-- ; ) @@ -61,6 +64,9 @@ Timeline::stop ( void ) { nframes_t frame = transport->frame; + if ( transport->punch_enabled() && frame > range_end() ) + frame = range_end(); + for ( int i = tracks->children(); i-- ; ) { Track *t = (Track*)tracks->child( i ); diff --git a/timeline/src/Engine/Track.C b/timeline/src/Engine/Track.C index e5acb1d..881a636 100644 --- a/timeline/src/Engine/Track.C +++ b/timeline/src/Engine/Track.C @@ -202,7 +202,7 @@ Track::process_output ( nframes_t nframes ) } /* FIXME: should we blank the control output here or leave it floating? */ - for ( int i = control->children(); i--; ) + for ( int i = 0; i < control->children(); i++ ) ((Control_Sequence*)control->child( i ))->process( nframes ); if ( playback_ds ) diff --git a/timeline/src/TLE.fl b/timeline/src/TLE.fl index d611d4e..fde1216 100644 --- a/timeline/src/TLE.fl +++ b/timeline/src/TLE.fl @@ -855,7 +855,15 @@ if ( engine && engine->zombified() && ! zombie ) } solo_blinker->value( Track::soloing() ); -rec_blinker->value( transport->rolling && transport->rec_enabled() ); + +if ( transport->punch_enabled() ) + rec_blinker->value( transport->rolling && + transport->rec_enabled() && + transport->frame >= timeline->range_start() && + transport->frame <= timeline->range_end() ); +else + rec_blinker->value( transport->rolling && transport->rec_enabled() ); + sm_blinker->value( timeline->session_manager_name() != NULL ); sm_blinker->tooltip( timeline->session_manager_name() ); selected_blinker->value( timeline->nselected() ); diff --git a/timeline/src/Timeline.C b/timeline/src/Timeline.C index 737e07c..d0960ec 100644 --- a/timeline/src/Timeline.C +++ b/timeline/src/Timeline.C @@ -1058,6 +1058,15 @@ Timeline::redraw_playhead ( void ) static nframes_t last_playhead = -1; static int last_playhead_x = -1; + + /* FIXME: kind of a hackish way to invoke punch stop from the UI thread... */ + + if ( transport->rolling && + transport->rec_enabled() && + transport->punch_enabled() && + transport->frame > range_end() ) + transport->stop(); + int playhead_x = ts_to_x( transport->frame ); if ( last_playhead_x != playhead_x ) diff --git a/timeline/src/Transport.C b/timeline/src/Transport.C index 2866892..7490271 100644 --- a/timeline/src/Transport.C +++ b/timeline/src/Transport.C @@ -45,7 +45,7 @@ Transport::Transport ( int X, int Y, int W, int H, const char *L ) frame_rate = 48000; frame = 0; - const int bw = W / 3; + const int bw = W / 5; type( HORIZONTAL ); @@ -77,6 +77,16 @@ Transport::Transport ( int X, int Y, int W, int H, const char *L ) o->when( FL_WHEN_CHANGED ); o->box( FL_UP_BOX ); + _punch_button = o = new Fl_Button( 0, 0, bw, 0, "Punch" ); + o->type( FL_TOGGLE_BUTTON ); + o->labelsize( 9 ); + o->labeltype( FL_NORMAL_LABEL ); + o->shortcut( 'P' ); + o->callback( cb_button, this ); + o->when( FL_WHEN_CHANGED ); + o->color2( FL_GREEN ); + o->box( FL_UP_BOX ); + end(); } @@ -147,6 +157,12 @@ Transport::rec_enabled ( void ) const return _record_button->value(); } +bool +Transport::punch_enabled ( void ) const +{ + return _punch_button->value(); +} + int Transport::handle ( int m ) { diff --git a/timeline/src/Transport.H b/timeline/src/Transport.H index 30ead51..d653ac1 100644 --- a/timeline/src/Transport.H +++ b/timeline/src/Transport.H @@ -23,8 +23,6 @@ #include #include "types.h" -#include "Timeline.H" - #include #include @@ -48,6 +46,7 @@ private: Fl_Button *_end_button; Fl_Button *_play_button; Fl_Button *_record_button; + Fl_Button *_punch_button; void update_record_state ( void ); @@ -56,6 +55,7 @@ public: Transport ( int X, int Y, int W, int H, const char *L=0 ); bool rec_enabled ( void ) const; + bool punch_enabled ( void ) const; void stop_disables_record ( bool b ) { _stop_disables_record = b; } bool stop_disables_record ( void ) const { return _stop_disables_record; }