Browse Source

Actually store captures under sources/ subdirectory.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
eb11a409d2
4 changed files with 38 additions and 10 deletions
  1. +24
    -0
      Timeline/Engine/Audio_File.C
  2. +4
    -0
      Timeline/Engine/Audio_File.H
  3. +3
    -3
      Timeline/Engine/Audio_File_SF.C
  4. +7
    -7
      Timeline/Engine/Peaks.C

+ 24
- 0
Timeline/Engine/Audio_File.C View File

@@ -55,6 +55,30 @@ Audio_File::all_supported_formats ( std::list <const char *> &formats )
formats.push_back( fd->name );
}

static bool
is_absolute ( const char *name )
{
return *name == '/';
}

/** return a static pointer to /name/ corrected for relative path. */
const char *Audio_File::realname ( const char *name )
{
static char rname[512];

if ( is_absolute( name ) )
strncpy( rname, name, sizeof( rname ) );
else
snprintf( rname, sizeof( rname ), "sources/%s", name );

return rname;
}

const char *
Audio_File::filename ( void ) const
{
return realname( _filename );
}

/** attmpet to open any supported filetype */
Audio_File *


+ 4
- 0
Timeline/Engine/Audio_File.H View File

@@ -58,6 +58,8 @@ protected:

static const format_desc * find_format ( const format_desc *fd, const char *name );

static const char *realname ( const char *name );

public:

Audio_File ( ) : _peaks( this )
@@ -75,7 +77,9 @@ public:

static Audio_File *from_file ( const char *filename );


Peaks const * peaks ( ) { return &_peaks; }
const char *filename ( void ) const;
const char *name ( void ) const { return _filename; }
nframes_t length ( void ) const { return _length; }
int channels ( void ) const { return _channels; }


+ 3
- 3
Timeline/Engine/Audio_File_SF.C View File

@@ -61,7 +61,7 @@ Audio_File_SF::from_file ( const char *filename )

memset( &si, 0, sizeof( si ) );

if ( ! ( in = sf_open( filename, SFM_READ, &si ) ) )
if ( ! ( in = sf_open( realname( filename ), SFM_READ, &si ) ) )
return NULL;

/* if ( si.samplerate != timeline->sample_rate() ) */
@@ -110,7 +110,7 @@ Audio_File_SF::create ( const char *filename, nframes_t samplerate, int channels
char *name;
asprintf( &name, "%s.%s", filename, fd->extension );

if ( ! ( out = sf_open( name, SFM_WRITE, &si ) ) )
if ( ! ( out = sf_open( realname( name ), SFM_WRITE, &si ) ) )
{
printf( "couldn't create soundfile.\n" );
free( name );
@@ -140,7 +140,7 @@ Audio_File_SF::open ( void )

memset( &si, 0, sizeof( si ) );

if ( ! ( _in = sf_open( _filename, SFM_READ, &si ) ) )
if ( ! ( _in = sf_open( realname( _filename ), SFM_READ, &si ) ) )
return false;

_current_read = 0;


+ 7
- 7
Timeline/Engine/Peaks.C View File

@@ -353,7 +353,7 @@ Peaks::ready ( nframes_t s, int npeaks, nframes_t chunksize ) const
{
Peakfile _peakfile;

if ( ! _peakfile.open( _clip->name(), _clip->channels(), chunksize ) )
if ( ! _peakfile.open( _clip->filename(), _clip->channels(), chunksize ) )
return false;

return _peakfile.ready( s, npeaks );
@@ -377,7 +377,7 @@ Peaks::read_peakfile_peaks ( Peak *peaks, nframes_t s, int npeaks, nframes_t chu

Peakfile _peakfile;

if ( ! _peakfile.open( _clip->name(), _clip->channels(), chunksize ) )
if ( ! _peakfile.open( _clip->filename(), _clip->channels(), chunksize ) )
return 0;

return _peakfile.read_peaks( peaks, s, npeaks, chunksize );
@@ -465,7 +465,7 @@ Peaks::read_peaks ( nframes_t s, int npeaks, nframes_t chunksize ) const
bool
Peaks::current ( void ) const
{
return ! newer( _clip->name(), peakname( _clip->name() ) );
return ! newer( _clip->filename(), peakname( _clip->filename() ) );
}

bool
@@ -507,7 +507,7 @@ Peaks::prepare_for_writing ( void )

assert( ! _peak_writer );

_peak_writer = new Peaks::Streamer( _clip->name(), _clip->channels(), cache_minimum );
_peak_writer = new Peaks::Streamer( _clip->filename(), _clip->channels(), cache_minimum );
}

void
@@ -678,7 +678,7 @@ Peaks::Builder::make_peaks_mipmap ( void )

Audio_File *_clip = _peaks->_clip;

const char *filename = _clip->name();
const char *filename = _clip->filename();

FILE *rfp;

@@ -728,7 +728,7 @@ Peaks::Builder::make_peaks_mipmap ( void )
/* open the peakfile for the previous cache level */
pf.open( rfp, _clip->channels(), cs >> Peaks::cache_step );

// pf.open( _clip->name(), _clip->channels(), cs >> Peaks::cache_step );
// pf.open( _clip->filename(), _clip->channels(), cs >> Peaks::cache_step );

write_block_header( cs );

@@ -758,7 +758,7 @@ Peaks::Builder::make_peaks ( void )
{
Audio_File *_clip = _peaks->_clip;

const char *filename = _clip->name();
const char *filename = _clip->filename();

DMESSAGE( "building peaks for \"%s\"", filename );



Loading…
Cancel
Save