Give each capture a unique name.

pull/3/head
Jonathan Moore Liles 2008-04-19 14:21:49 -05:00
parent 77ff82e9f4
commit d3fcb162f3
3 changed files with 37 additions and 2 deletions

View File

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

View File

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

View File

@ -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 <time.h>
/** 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 <stdio.h>
/* THREAD: IO */
void
Track::stop ( nframes_t nframes )
{
_capture->finalize();
_capture = NULL;
}