AudioFileSizeEstimator Class Reference

Estimate the number of samples in an audio file. More...

#include <AudioFileSizeEstimator.h>

Static Public Member Functions

static sv_frame_t estimate (FileSource source, sv_samplerate_t targetRate=0)
 Return an estimate of the number of samples (across all channels) in the given audio file, once it has been decoded and (if applicable) resampled to the given rate. More...
 

Detailed Description

Estimate the number of samples in an audio file.

For many compressed files this returns only a very approximate estimate, based on a rough estimate of compression ratio. Initially we're only aiming for a conservative estimate for purposes like "will this file fit in memory?" (and if unsure, say no).

Definition at line 28 of file AudioFileSizeEstimator.h.

Member Function Documentation

sv_frame_t AudioFileSizeEstimator::estimate ( FileSource  source,
sv_samplerate_t  targetRate = 0 
)
static

Return an estimate of the number of samples (across all channels) in the given audio file, once it has been decoded and (if applicable) resampled to the given rate.

This function is intended to be reasonably fast – it may open the file, but it should not do any decoding. (However, if the file source is remote, it will probably be downloaded in its entirety before anything can be estimated.)

The returned value is an estimate, and is deliberately usually on the high side. If the estimator has no idea at all, this will return 0.

Definition at line 24 of file AudioFileSizeEstimator.cpp.

References AudioFileReader::getChannelCount(), FileSource::getExtension(), AudioFileReader::getFrameCount(), FileSource::getLocalFilename(), AudioFileReader::getSampleRate(), AudioFileReader::isOK(), FileSource::isOK(), SVDEBUG, and FileSource::waitForData().

Referenced by AudioFileReaderFactory::createReader().


The documentation for this class was generated from the following files: