Make mutlti-region playback and overlapped region playback work.

This commit is contained in:
Jonathan Moore Liles 2008-04-12 17:55:25 -05:00
parent fb94e119c4
commit ab20e03eb2
5 changed files with 40 additions and 19 deletions

View File

@ -124,25 +124,31 @@ Audio_Track::play ( sample_t *buf, nframes_t frame, nframes_t nframes, int chann
sample_t *cbuf = new sample_t[ nframes ];
/* quick and dirty--let the regions figure out coverage for themselves */
for ( list <Track_Widget *>::const_iterator i = _widgets.begin(); i != _widgets.end(); ++i )
for ( list <Track_Widget *>::const_iterator i = _widgets.begin();
i != _widgets.end(); i++ )
{
const Region *r = (Region*)(*i);
for ( int i = channels; i--; )
{
memset( cbuf, 0, nframes * sizeof( sample_t ) );
// memset( cbuf, 0, nframes * sizeof( sample_t ) );
if ( ! r->read( cbuf, frame, nframes, i ) )
/* error ? */;
/* error ? */
continue;
if ( channels == 1 )
memcpy( buf, cbuf, nframes * sizeof( sample_t ) );
{
// memcpy( buf, cbuf, nframes * sizeof( sample_t ) );
for ( unsigned int j = 0; j < nframes; ++j )
buf[ j ] += cbuf[ j ];
}
else
{
/* interleave */
/* mix and interleave */
int k = 0;
for ( unsigned int j = i; k < nframes; j += channels )
buf[ j ] = cbuf[ k++ ];
buf[ j ] += cbuf[ k++ ];
}
}
}

View File

@ -174,6 +174,8 @@ void
Disk_Stream::read_block ( sample_t *buf, nframes_t nframes )
{
memset( buf, 0, nframes * sizeof( sample_t ) * channels() );
/* stupid chicken/egg */
if ( ! timeline )
return;
@ -224,7 +226,7 @@ Disk_Stream::io_thread ( void )
{
// printf( "IO: RT thread is ready for more data...\n" );
printf( "IO: disk buffer is %3d%% full\r", output_buffer_percent() );
// printf( "IO: disk buffer is %3d%% full\r", output_buffer_percent() );
// lock(); // for seeking

View File

@ -105,6 +105,7 @@ Engine::process ( nframes_t nframes )
transport.poll();
if ( ! transport.rolling )
/* FIXME: fill all ports with silence */
return 0;
if ( ! trylock() )

View File

@ -94,15 +94,10 @@ Region::init ( void )
/* copy constructor */
Region::Region ( const Region & rhs )
{
_r->offset = rhs._r->offset;
_track = rhs._track;
// _track = NULL;
*((Track_Widget*)this) = (Track_Widget &)rhs;
_clip = rhs._clip;
_r->start = rhs._r->start;
_r->end = rhs._r->end;
_scale = rhs._scale;
_box_color = rhs._box_color;
_color = rhs._color;
log_create();
}
@ -553,7 +548,7 @@ Region::normalize ( void )
nframes_t
Region::read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channel ) const
{
const Range &r = _range;
const Range r = _range;
const nframes_t length = r.end - r.start;

View File

@ -61,6 +61,9 @@ class Track_Widget : public Loggable
static Track_Widget * _original; /* the original of the /pushed/ widget */
static Track_Widget * _belowmouse; /* the widget below the mouse cursor */
/* can't have this */
Track_Widget ( const Track_Widget &rhs );
protected:
Track *_track; /* track this region belongs to */
@ -99,13 +102,27 @@ public:
_selection.remove( this );
}
Track_Widget ( const Track_Widget &rhs )
const Track_Widget &
operator= ( const Track_Widget &rhs )
{
*_r = *rhs._r;
_track = rhs._track;
if ( this == &rhs )
return *this;
_r = &_range;
_range = rhs._range;
_track = rhs._track;
_box_color = rhs._box_color;
_color = rhs._color;
return *this;
}
/* Track_Widget ( const Track_Widget &rhs ) */
/* { */
/* *this = rhs; */
/* } */
virtual Track_Widget *clone ( const Track_Widget *r ) = 0;
bool selected ( void )