From ab20e03eb294c0938f942e59dffbcace1c0a744e Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sat, 12 Apr 2008 17:55:25 -0500 Subject: [PATCH] Make mutlti-region playback and overlapped region playback work. --- Timeline/Audio_Track.C | 18 ++++++++++++------ Timeline/Disk_Stream.C | 4 +++- Timeline/Engine.C | 1 + Timeline/Region.C | 11 +++-------- Timeline/Track_Widget.H | 25 +++++++++++++++++++++---- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/Timeline/Audio_Track.C b/Timeline/Audio_Track.C index 03c9318..8af936f 100644 --- a/Timeline/Audio_Track.C +++ b/Timeline/Audio_Track.C @@ -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 ::const_iterator i = _widgets.begin(); i != _widgets.end(); ++i ) + for ( list ::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++ ]; } } } diff --git a/Timeline/Disk_Stream.C b/Timeline/Disk_Stream.C index 3e7275b..f21b2e9 100644 --- a/Timeline/Disk_Stream.C +++ b/Timeline/Disk_Stream.C @@ -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 diff --git a/Timeline/Engine.C b/Timeline/Engine.C index bc92830..5e0f035 100644 --- a/Timeline/Engine.C +++ b/Timeline/Engine.C @@ -105,6 +105,7 @@ Engine::process ( nframes_t nframes ) transport.poll(); if ( ! transport.rolling ) + /* FIXME: fill all ports with silence */ return 0; if ( ! trylock() ) diff --git a/Timeline/Region.C b/Timeline/Region.C index 820a103..4ed4ce6 100644 --- a/Timeline/Region.C +++ b/Timeline/Region.C @@ -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; diff --git a/Timeline/Track_Widget.H b/Timeline/Track_Widget.H index b55e301..6e1339f 100644 --- a/Timeline/Track_Widget.H +++ b/Timeline/Track_Widget.H @@ -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 )