Chris@1098: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
Chris@1098: 
Chris@1098: /*
Chris@1098:     Sonic Visualiser
Chris@1098:     An audio file viewer and annotation editor.
Chris@1098:     Centre for Digital Music, Queen Mary, University of London.
Chris@1098:     
Chris@1098:     This program is free software; you can redistribute it and/or
Chris@1098:     modify it under the terms of the GNU General Public License as
Chris@1098:     published by the Free Software Foundation; either version 2 of the
Chris@1098:     License, or (at your option) any later version.  See the file
Chris@1098:     COPYING included with this distribution for more information.
Chris@1098: */
Chris@1098: 
Chris@1098: #ifndef AUDIO_FILE_SIZE_ESTIMATOR_H
Chris@1098: #define AUDIO_FILE_SIZE_ESTIMATOR_H
Chris@1098: 
Chris@1098: #include "base/BaseTypes.h"
Chris@1098: #include "data/fileio/FileSource.h"
Chris@1098: 
Chris@1098: /**
Chris@1098:  * Estimate the number of samples in an audio file. For many
Chris@1098:  * compressed files this returns only a very approximate estimate,
Chris@1098:  * based on a rough estimate of compression ratio. Initially we're
Chris@1098:  * only aiming for a conservative estimate for purposes like "will
Chris@1098:  * this file fit in memory?" (and if unsure, say no).
Chris@1098:  */
Chris@1098: class AudioFileSizeEstimator
Chris@1098: {
Chris@1098: public:
Chris@1098:     /**
Chris@1098:      * Return an estimate of the number of samples (across all
Chris@1098:      * channels) in the given audio file, once it has been decoded and
Chris@1098:      * (if applicable) resampled to the given rate.
Chris@1098:      *
Chris@1098:      * This function is intended to be reasonably fast -- it may open
Chris@1098:      * the file, but it should not do any decoding. (However, if the
Chris@1098:      * file source is remote, it will probably be downloaded in its
Chris@1098:      * entirety before anything can be estimated.)
Chris@1098:      *
Chris@1098:      * The returned value is an estimate, and is deliberately usually
Chris@1098:      * on the high side. If the estimator has no idea at all, this
Chris@1098:      * will return 0.
Chris@1098:      */
Chris@1098:     static sv_frame_t estimate(FileSource source,
Chris@1343:                                sv_samplerate_t targetRate = 0);
Chris@1098: };
Chris@1098: 
Chris@1098: #endif