diff --git a/Timeline/Audio_Region.C b/Timeline/Audio_Region.C index 0807a34..7a38de4 100644 --- a/Timeline/Audio_Region.C +++ b/Timeline/Audio_Region.C @@ -645,6 +645,22 @@ Audio_Region::draw ( void ) } +/** split region at absolute frame /where/ */ +void +Audio_Region::split ( nframes_t where ) +{ + nframes_t old_fade_in = _fade_in.length; + + _fade_in.length = 256; + + Audio_Region *copy = new Audio_Region( *this ); + + _fade_in.length = old_fade_in; + _fade_out.length = 256; + + Sequence_Region::split( copy, where ); +} + int Audio_Region::handle ( int m ) { @@ -679,19 +695,7 @@ Audio_Region::handle ( int m ) { Loggable::block_start(); - nframes_t old_fade_in = _fade_in.length; - _fade_in.length = 256; - - Audio_Region *copy = new Audio_Region( *this ); - - _fade_in.length = old_fade_in; - - trim( RIGHT, X ); - copy->trim( LEFT, X ); - - _fade_out.length = 256; - - sequence()->add( copy ); + split( timeline->x_to_offset( X ) ); log_end(); diff --git a/Timeline/Audio_Region.H b/Timeline/Audio_Region.H index 8f5390d..881f76d 100644 --- a/Timeline/Audio_Region.H +++ b/Timeline/Audio_Region.H @@ -154,6 +154,7 @@ public: Fl_Align align ( void ) const { return (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_BOTTOM /*| FL_ALIGN_CLIP*/ | FL_ALIGN_INSIDE); } void normalize ( void ); + void split ( nframes_t where ); /* Engine */ nframes_t read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channel ) const; diff --git a/Timeline/Sequence_Region.C b/Timeline/Sequence_Region.C index b73822a..58786c1 100644 --- a/Timeline/Sequence_Region.C +++ b/Timeline/Sequence_Region.C @@ -124,6 +124,17 @@ Sequence_Region::trim ( enum trim_e t, int X ) } } +/** split region at absolute frame /where/. due to inheritance issues, + * the copy must be made in the derived classed and passed in */ +void +Sequence_Region::split ( Sequence_Region * copy, nframes_t where ) +{ + trim_right( where ); + copy->trim_left( where ); + sequence()->add( copy ); +} + + #include "FL/test_press.H" int diff --git a/Timeline/Sequence_Region.H b/Timeline/Sequence_Region.H index c09dbbd..c17e240 100644 --- a/Timeline/Sequence_Region.H +++ b/Timeline/Sequence_Region.H @@ -51,4 +51,5 @@ public: enum trim_e { NO, LEFT, RIGHT }; void trim ( enum trim_e t, int X ); + void split ( Sequence_Region *copy, nframes_t where ); };