Browse Source

Give each capture a unique name.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
d3fcb162f3
3 changed files with 37 additions and 2 deletions
  1. +11
    -0
      Timeline/Region.C
  2. +3
    -0
      Timeline/Region.H
  3. +23
    -2
      Timeline/Track.C

+ 11
- 0
Timeline/Region.C View File

@@ -931,3 +931,14 @@ Region::write ( sample_t *buf, nframes_t nframes )


return l; 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;
}

+ 3
- 0
Timeline/Region.H View File

@@ -203,6 +203,8 @@ public:
public: public:




const char *source_name ( void ) const { return _clip->name(); }

static Loggable * static Loggable *
create ( char **sa ) create ( char **sa )
{ {
@@ -240,5 +242,6 @@ public:
/* Engine */ /* Engine */
nframes_t read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channel ) const; 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 ( sample_t *buf, nframes_t nframes );
bool finalize ( void );


}; };

+ 23
- 2
Timeline/Track.C 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 ) : Track::Track ( int X, int Y, int W, int H, const char *L ) :
Fl_Group ( X, Y, W, H, L ) Fl_Group ( X, Y, W, H, L )
{ {
_capture = NULL;
_track = NULL; _track = NULL;
_name = NULL; _name = NULL;
_selected = false; _selected = false;
@@ -366,6 +366,19 @@ Track::seek ( nframes_t frame )


#include "Region.H" #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 */ /* THREAD: IO */
/** create capture region and prepare to record */ /** create capture region and prepare to record */
void void
@@ -373,8 +386,12 @@ Track::record ( nframes_t frame )
{ {
assert( _capture == NULL ); assert( _capture == NULL );


char pat[256];

snprintf( pat, sizeof( pat ), "%s-%llu.wav", name(), uuid() );

/* FIXME: hack */ /* 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 ); _capture = new Region( af, track(), frame );


@@ -390,9 +407,13 @@ Track::write ( sample_t *buf, nframes_t nframes )
_capture->write( buf, nframes ); _capture->write( buf, nframes );
} }


#include <stdio.h>

/* THREAD: IO */ /* THREAD: IO */
void void
Track::stop ( nframes_t nframes ) Track::stop ( nframes_t nframes )
{ {
_capture->finalize();

_capture = NULL; _capture = NULL;
} }

Loading…
Cancel
Save