annotate data/fileio/AudioFileReaderFactory.h @ 392:183ee2a55fc7

* More work to abstract out interactive components used in the data library, so that it does not need to depend on QtGui.
author Chris Cannam
date Fri, 14 Mar 2008 17:14:21 +0000
parents 1d656dcda8ef
children f3cda3280398 59e7fe1b1003
rev   line source
Chris@148 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@148 2
Chris@148 3 /*
Chris@148 4 Sonic Visualiser
Chris@148 5 An audio file viewer and annotation editor.
Chris@148 6 Centre for Digital Music, Queen Mary, University of London.
Chris@148 7 This file copyright 2006 Chris Cannam.
Chris@148 8
Chris@148 9 This program is free software; you can redistribute it and/or
Chris@148 10 modify it under the terms of the GNU General Public License as
Chris@148 11 published by the Free Software Foundation; either version 2 of the
Chris@148 12 License, or (at your option) any later version. See the file
Chris@148 13 COPYING included with this distribution for more information.
Chris@148 14 */
Chris@148 15
Chris@148 16 #ifndef _AUDIO_FILE_READER_FACTORY_H_
Chris@148 17 #define _AUDIO_FILE_READER_FACTORY_H_
Chris@148 18
Chris@290 19 #include <QString>
Chris@148 20
Chris@317 21 #include "FileSource.h"
Chris@316 22
Chris@148 23 class AudioFileReader;
Chris@392 24 class ProgressReporter;
Chris@148 25
Chris@148 26 class AudioFileReaderFactory
Chris@148 27 {
Chris@148 28 public:
Chris@148 29 /**
Chris@148 30 * Return the file extensions that we have audio file readers for,
Chris@148 31 * in a format suitable for use with QFileDialog. For example,
Chris@148 32 * "*.wav *.aiff *.ogg".
Chris@148 33 */
Chris@290 34 static QString getKnownExtensions();
Chris@148 35
Chris@148 36 /**
Chris@148 37 * Return an audio file reader initialised to the file at the
Chris@148 38 * given path, or NULL if no suitable reader for this path is
Chris@148 39 * available or the file cannot be opened.
Chris@297 40 *
Chris@297 41 * If targetRate is non-zero, the file will be resampled to that
Chris@297 42 * rate (transparently). You can query reader->getNativeRate()
Chris@297 43 * if you want to find out whether the file is being resampled
Chris@297 44 * or not.
Chris@297 45 *
Chris@392 46 * If a ProgressReporter is provided, it will be updated with
Chris@392 47 * progress status. Caller retains ownership of the reporter
Chris@392 48 * object.
Chris@392 49 *
Chris@148 50 * Caller owns the returned object and must delete it after use.
Chris@148 51 */
Chris@327 52 static AudioFileReader *createReader(FileSource source,
Chris@392 53 size_t targetRate = 0,
Chris@392 54 ProgressReporter *reporter = 0);
Chris@327 55
Chris@327 56 /**
Chris@327 57 * Return an audio file reader initialised to the file at the
Chris@327 58 * given path, or NULL if no suitable reader for this path is
Chris@327 59 * available or the file cannot be opened. If the reader supports
Chris@327 60 * threaded decoding, it will be used and the file decoded in a
Chris@327 61 * background thread.
Chris@327 62 *
Chris@327 63 * If targetRate is non-zero, the file will be resampled to that
Chris@327 64 * rate (transparently). You can query reader->getNativeRate()
Chris@327 65 * if you want to find out whether the file is being resampled
Chris@327 66 * or not.
Chris@327 67 *
Chris@392 68 * If a ProgressReporter is provided, it will be updated with
Chris@392 69 * progress status. This will only be meaningful if threading
Chris@392 70 * mode is not used because the file reader in use does not
Chris@392 71 * support it; otherwise progress as reported will jump straight
Chris@392 72 * to 100% before threading mode takes over. Caller retains
Chris@392 73 * ownership of the reporter object.
Chris@392 74 *
Chris@327 75 * Caller owns the returned object and must delete it after use.
Chris@327 76 */
Chris@327 77 static AudioFileReader *createThreadingReader(FileSource source,
Chris@392 78 size_t targetRate = 0,
Chris@392 79 ProgressReporter *reporter = 0);
Chris@327 80
Chris@327 81 protected:
Chris@327 82 static AudioFileReader *create(FileSource source,
Chris@327 83 size_t targetRate,
Chris@392 84 bool threading,
Chris@392 85 ProgressReporter *reporter);
Chris@148 86 };
Chris@148 87
Chris@148 88 #endif
Chris@148 89