Chris@148: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@148: Chris@148: /* Chris@148: Sonic Visualiser Chris@148: An audio file viewer and annotation editor. Chris@148: Centre for Digital Music, Queen Mary, University of London. Chris@148: This file copyright 2006 Chris Cannam. Chris@148: Chris@148: This program is free software; you can redistribute it and/or Chris@148: modify it under the terms of the GNU General Public License as Chris@148: published by the Free Software Foundation; either version 2 of the Chris@148: License, or (at your option) any later version. See the file Chris@148: COPYING included with this distribution for more information. Chris@148: */ Chris@148: Chris@148: #ifndef _AUDIO_FILE_READER_FACTORY_H_ Chris@148: #define _AUDIO_FILE_READER_FACTORY_H_ Chris@148: Chris@290: #include Chris@148: Chris@317: #include "FileSource.h" Chris@316: Chris@148: class AudioFileReader; Chris@392: class ProgressReporter; Chris@148: Chris@148: class AudioFileReaderFactory Chris@148: { Chris@148: public: Chris@148: /** Chris@148: * Return the file extensions that we have audio file readers for, Chris@148: * in a format suitable for use with QFileDialog. For example, Chris@148: * "*.wav *.aiff *.ogg". Chris@148: */ Chris@290: static QString getKnownExtensions(); Chris@148: Chris@148: /** Chris@148: * Return an audio file reader initialised to the file at the Chris@148: * given path, or NULL if no suitable reader for this path is Chris@148: * available or the file cannot be opened. Chris@297: * Chris@297: * If targetRate is non-zero, the file will be resampled to that Chris@297: * rate (transparently). You can query reader->getNativeRate() Chris@297: * if you want to find out whether the file is being resampled Chris@297: * or not. Chris@297: * Chris@920: * If normalised is true, the file data will be normalised to Chris@920: * abs(max) == 1.0. Otherwise the file will not be normalised. Chris@920: * Chris@392: * If a ProgressReporter is provided, it will be updated with Chris@392: * progress status. Caller retains ownership of the reporter Chris@392: * object. Chris@392: * Chris@148: * Caller owns the returned object and must delete it after use. Chris@148: */ Chris@327: static AudioFileReader *createReader(FileSource source, Chris@929: int targetRate = 0, Chris@920: bool normalised = false, Chris@392: ProgressReporter *reporter = 0); Chris@327: Chris@327: /** Chris@327: * Return an audio file reader initialised to the file at the Chris@327: * given path, or NULL if no suitable reader for this path is Chris@327: * available or the file cannot be opened. If the reader supports Chris@327: * threaded decoding, it will be used and the file decoded in a Chris@327: * background thread. Chris@327: * Chris@327: * If targetRate is non-zero, the file will be resampled to that Chris@327: * rate (transparently). You can query reader->getNativeRate() Chris@327: * if you want to find out whether the file is being resampled Chris@327: * or not. Chris@327: * Chris@920: * If normalised is true, the file data will be normalised to Chris@920: * abs(max) == 1.0. Otherwise the file will not be normalised. Chris@920: * Chris@392: * If a ProgressReporter is provided, it will be updated with Chris@392: * progress status. This will only be meaningful if threading Chris@392: * mode is not used because the file reader in use does not Chris@392: * support it; otherwise progress as reported will jump straight Chris@392: * to 100% before threading mode takes over. Caller retains Chris@392: * ownership of the reporter object. Chris@392: * Chris@327: * Caller owns the returned object and must delete it after use. Chris@327: */ Chris@327: static AudioFileReader *createThreadingReader(FileSource source, Chris@929: int targetRate = 0, Chris@920: bool normalised = false, Chris@392: ProgressReporter *reporter = 0); Chris@327: Chris@327: protected: Chris@327: static AudioFileReader *create(FileSource source, Chris@929: int targetRate, Chris@920: bool normalised, Chris@392: bool threading, Chris@392: ProgressReporter *reporter); Chris@148: }; Chris@148: Chris@148: #endif Chris@148: