annotate data/fileio/AudioFileSizeEstimator.h @ 1817:23d5cb3f9f38

Merge from branch csv-export-dialog
author Chris Cannam
date Tue, 14 Jan 2020 15:48:22 +0000
parents c380e56c95f5
children
rev   line source
Chris@1098 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1098 2
Chris@1098 3 /*
Chris@1098 4 Sonic Visualiser
Chris@1098 5 An audio file viewer and annotation editor.
Chris@1098 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1098 7
Chris@1098 8 This program is free software; you can redistribute it and/or
Chris@1098 9 modify it under the terms of the GNU General Public License as
Chris@1098 10 published by the Free Software Foundation; either version 2 of the
Chris@1098 11 License, or (at your option) any later version. See the file
Chris@1098 12 COPYING included with this distribution for more information.
Chris@1098 13 */
Chris@1098 14
Chris@1098 15 #ifndef AUDIO_FILE_SIZE_ESTIMATOR_H
Chris@1098 16 #define AUDIO_FILE_SIZE_ESTIMATOR_H
Chris@1098 17
Chris@1098 18 #include "base/BaseTypes.h"
Chris@1098 19 #include "data/fileio/FileSource.h"
Chris@1098 20
Chris@1098 21 /**
Chris@1098 22 * Estimate the number of samples in an audio file. For many
Chris@1098 23 * compressed files this returns only a very approximate estimate,
Chris@1098 24 * based on a rough estimate of compression ratio. Initially we're
Chris@1098 25 * only aiming for a conservative estimate for purposes like "will
Chris@1098 26 * this file fit in memory?" (and if unsure, say no).
Chris@1098 27 */
Chris@1098 28 class AudioFileSizeEstimator
Chris@1098 29 {
Chris@1098 30 public:
Chris@1098 31 /**
Chris@1098 32 * Return an estimate of the number of samples (across all
Chris@1098 33 * channels) in the given audio file, once it has been decoded and
Chris@1098 34 * (if applicable) resampled to the given rate.
Chris@1098 35 *
Chris@1098 36 * This function is intended to be reasonably fast -- it may open
Chris@1098 37 * the file, but it should not do any decoding. (However, if the
Chris@1098 38 * file source is remote, it will probably be downloaded in its
Chris@1098 39 * entirety before anything can be estimated.)
Chris@1098 40 *
Chris@1098 41 * The returned value is an estimate, and is deliberately usually
Chris@1098 42 * on the high side. If the estimator has no idea at all, this
Chris@1098 43 * will return 0.
Chris@1098 44 */
Chris@1098 45 static sv_frame_t estimate(FileSource source,
Chris@1343 46 sv_samplerate_t targetRate = 0);
Chris@1098 47 };
Chris@1098 48
Chris@1098 49 #endif