From d3fcb162f33249cf8fb14c05075f3a340589e6c6 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sat, 19 Apr 2008 14:21:49 -0500 Subject: [PATCH] Give each capture a unique name. --- Timeline/Region.C | 11 +++++++++++ Timeline/Region.H | 3 +++ Timeline/Track.C | 25 +++++++++++++++++++++++-- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Timeline/Region.C b/Timeline/Region.C index 2f3cfe6..6d1d420 100644 --- a/Timeline/Region.C +++ b/Timeline/Region.C @@ -931,3 +931,14 @@ Region::write ( sample_t *buf, nframes_t nframes ) return l; } + +/** finalize region capture. Assumes that this *is* a captured region + and that no other regions refer to the same source */ +bool +Region::finalize ( void ) +{ + _clip->close(); + _clip->open(); + + return true; +} diff --git a/Timeline/Region.H b/Timeline/Region.H index 5b38260..d729492 100644 --- a/Timeline/Region.H +++ b/Timeline/Region.H @@ -203,6 +203,8 @@ public: public: + const char *source_name ( void ) const { return _clip->name(); } + static Loggable * create ( char **sa ) { @@ -240,5 +242,6 @@ 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 ); + bool finalize ( void ); }; diff --git a/Timeline/Track.C b/Timeline/Track.C index a2074eb..cfb4292 100644 --- a/Timeline/Track.C +++ b/Timeline/Track.C @@ -99,7 +99,7 @@ Track::cb_button ( Fl_Widget *w ) Track::Track ( int X, int Y, int W, int H, const char *L ) : Fl_Group ( X, Y, W, H, L ) { - + _capture = NULL; _track = NULL; _name = NULL; _selected = false; @@ -366,6 +366,19 @@ Track::seek ( nframes_t frame ) #include "Region.H" + +#include + +/** very cheap UUID generator... */ +unsigned long long +uuid ( void ) +{ + time_t t = time( NULL ); + + return (unsigned long long) t; +} + + /* THREAD: IO */ /** create capture region and prepare to record */ void @@ -373,8 +386,12 @@ Track::record ( nframes_t frame ) { assert( _capture == NULL ); + char pat[256]; + + snprintf( pat, sizeof( pat ), "%s-%llu.wav", name(), uuid() ); + /* FIXME: hack */ - Audio_File *af = Audio_File_SF::create( "testing.wav", 48000, input.size(), "Wav/24" ); + Audio_File *af = Audio_File_SF::create( pat, 48000, input.size(), "Wav/24" ); _capture = new Region( af, track(), frame ); @@ -390,9 +407,13 @@ Track::write ( sample_t *buf, nframes_t nframes ) _capture->write( buf, nframes ); } +#include + /* THREAD: IO */ void Track::stop ( nframes_t nframes ) { + _capture->finalize(); + _capture = NULL; }