diff --git a/Timeline/Audio_File_SF.C b/Timeline/Audio_File_SF.C index 5e0c7e1..6839bf4 100644 --- a/Timeline/Audio_File_SF.C +++ b/Timeline/Audio_File_SF.C @@ -69,6 +69,7 @@ Audio_File_SF::from_file ( const char *filename ) c = new Audio_File_SF; + c->_peak_writer = NULL; c->_current_read = 0; c->_filename = strdup( filename ); c->_length = si.frames; @@ -124,7 +125,7 @@ Audio_File_SF::create ( const char *filename, nframes_t samplerate, int channels c->_in = out; /* FIXME: 256 ? */ - c->_peak_writer = new Peak_Writer( filename, 256, channels ); + c->_peak_writer = new Peak_Writer( name, 256, channels ); return c; } diff --git a/Timeline/Region.C b/Timeline/Region.C index fa2e711..2f3a1bd 100644 --- a/Timeline/Region.C +++ b/Timeline/Region.C @@ -893,10 +893,6 @@ Region::read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channel ) co /* now that we know how much and where to read, get on with it */ - /* FIXME: seeking can be very expensive. Esp. with compressed - * formats. We should attempt to avoid it. But here or in the - * Audio_File class? */ - // printf( "reading region ofs = %lu, sofs = %lu, %lu-%lu\n", ofs, sofs, start, end ); cnt = _clip->read( buf + ofs, channel, start, end ); @@ -947,19 +943,23 @@ Region::read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channel ) co /** write /nframes/ from /buf/ to source. /buf/ is interleaved and must match the channel layout of the write source! */ nframes_t -Region::write ( sample_t *buf, nframes_t nframes ) +Region::write ( nframes_t nframes ) { - nframes_t l = _clip->write( buf, nframes ); - - _range.end += l; + _range.end += nframes; /* FIXME: too much? */ // _track->damage( FL_DAMAGE_EXPOSE, x() + w(), y(), 10/* FIXME: guess */, h() ); if ( 0 == ( timeline->ts_to_x( _range.end ) % 20 ) ) + { + /* FIXME: hack to get new size */ + _clip->close(); + _clip->open(); + redraw(); + } - return l; + return nframes; } diff --git a/Timeline/Region.H b/Timeline/Region.H index 132c05e..9059933 100644 --- a/Timeline/Region.H +++ b/Timeline/Region.H @@ -201,7 +201,7 @@ public: /* Engine */ nframes_t read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channel ) const; - nframes_t write ( sample_t *buf, nframes_t nframes ); + nframes_t write ( nframes_t nframes ); void prepare ( void ); bool finalize ( void ); diff --git a/Timeline/Track.C b/Timeline/Track.C index fd93c9d..df35276 100644 --- a/Timeline/Track.C +++ b/Timeline/Track.C @@ -643,8 +643,16 @@ Track::record ( nframes_t frame ) snprintf( pat, sizeof( pat ), "%s-%llu", name(), uuid() ); - /* FIXME: hack */ - Audio_File *af = Audio_File_SF::create( pat, 48000, input.size(), Track::capture_format ); + _capture_af = Audio_File_SF::create( pat, 48000, input.size(), Track::capture_format ); + + if ( ! _capture_af ) + { + /* ERROR */ + + } + + /* open it again for reading in the GUI thread */ + Audio_File *af = Audio_File::from_file( _capture_af->name() ); _capture = new Region( af, track(), frame ); @@ -656,7 +664,9 @@ Track::record ( nframes_t frame ) void Track::write ( sample_t *buf, nframes_t nframes ) { - _capture->write( buf, nframes ); + nframes_t l = _capture_af->write( buf, nframes ); + + _capture->write( l ); } #include diff --git a/Timeline/Track.H b/Timeline/Track.H index 89a1e3d..b967093 100644 --- a/Timeline/Track.H +++ b/Timeline/Track.H @@ -45,6 +45,7 @@ class Playback_DS; class Record_DS; class Port; class Region; +class Audio_File; class Track : public Fl_Group, public Loggable { @@ -75,6 +76,7 @@ private: Sequence *_track; Region *_capture; /* capture region */ + Audio_File *_capture_af; /* capture write source */ bool configure_outputs ( int n ); bool configure_inputs ( int n );