Clean up region splitting code.

pull/3/head
Jonathan Moore Liles 2009-01-22 22:48:08 -06:00
parent 99937affb9
commit 71bd1c27d9
4 changed files with 30 additions and 13 deletions

View File

@ -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();

View File

@ -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;

View File

@ -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

View File

@ -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 );
};