svcore
1.9
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file copyright 2007 QMUL. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #ifndef _DECODING_WAV_FILE_READER_H_ 00017 #define _DECODING_WAV_FILE_READER_H_ 00018 00019 #include "CodedAudioFileReader.h" 00020 00021 #include "base/Thread.h" 00022 00023 #include <set> 00024 00025 class WavFileReader; 00026 class ProgressReporter; 00027 00028 class DecodingWavFileReader : public CodedAudioFileReader 00029 { 00030 Q_OBJECT 00031 public: 00032 enum ResampleMode { 00033 ResampleAtOnce, // resample the file on construction, with progress dialog 00034 ResampleThreaded // resample in a background thread after construction 00035 }; 00036 00037 DecodingWavFileReader(FileSource source, 00038 ResampleMode resampleMode, 00039 CacheMode cacheMode, 00040 int targetRate = 0, 00041 bool normalised = false, 00042 ProgressReporter *reporter = 0); 00043 virtual ~DecodingWavFileReader(); 00044 00045 virtual QString getError() const { return m_error; } 00046 virtual QString getLocation() const { return m_source.getLocation(); } 00047 static void getSupportedExtensions(std::set<QString> &extensions); 00048 static bool supportsExtension(QString ext); 00049 static bool supportsContentType(QString type); 00050 static bool supports(FileSource &source); 00051 00052 virtual int getDecodeCompletion() const { return m_completion; } 00053 00054 virtual bool isUpdating() const { 00055 return m_decodeThread && m_decodeThread->isRunning(); 00056 } 00057 00058 public slots: 00059 void cancelled(); 00060 00061 protected: 00062 FileSource m_source; 00063 QString m_path; 00064 QString m_error; 00065 bool m_cancelled; 00066 int m_processed; 00067 int m_completion; 00068 00069 WavFileReader *m_original; 00070 ProgressReporter *m_reporter; 00071 00072 void addBlock(const SampleBlock &frames); 00073 00074 class DecodeThread : public Thread 00075 { 00076 public: 00077 DecodeThread(DecodingWavFileReader *reader) : m_reader(reader) { } 00078 virtual void run(); 00079 00080 protected: 00081 DecodingWavFileReader *m_reader; 00082 }; 00083 00084 DecodeThread *m_decodeThread; 00085 }; 00086 00087 #endif 00088