comparison data/fileio/ResamplingWavFileReader.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 700cd3350391
children
comparison
equal deleted inserted replaced
391:5858cc462d0a 392:183ee2a55fc7
21 #include "base/Thread.h" 21 #include "base/Thread.h"
22 22
23 #include <set> 23 #include <set>
24 24
25 class WavFileReader; 25 class WavFileReader;
26 class QProgressDialog; 26 class ProgressReporter;
27 27
28 class ResamplingWavFileReader : public CodedAudioFileReader 28 class ResamplingWavFileReader : public CodedAudioFileReader
29 { 29 {
30 Q_OBJECT
30 public: 31 public:
31 enum ResampleMode { 32 enum ResampleMode {
32 ResampleAtOnce, // resample the file on construction, with progress dialog 33 ResampleAtOnce, // resample the file on construction, with progress dialog
33 ResampleThreaded // resample in a background thread after construction 34 ResampleThreaded // resample in a background thread after construction
34 }; 35 };
35 36
36 ResamplingWavFileReader(FileSource source, 37 ResamplingWavFileReader(FileSource source,
37 ResampleMode resampleMode, 38 ResampleMode resampleMode,
38 CacheMode cacheMode, 39 CacheMode cacheMode,
39 size_t targetRate = 0); 40 size_t targetRate = 0,
41 ProgressReporter *reporter = 0);
40 virtual ~ResamplingWavFileReader(); 42 virtual ~ResamplingWavFileReader();
41 43
42 virtual QString getError() const { return m_error; } 44 virtual QString getError() const { return m_error; }
43 virtual QString getLocation() const { return m_source.getLocation(); } 45 virtual QString getLocation() const { return m_source.getLocation(); }
44 static void getSupportedExtensions(std::set<QString> &extensions); 46 static void getSupportedExtensions(std::set<QString> &extensions);
50 52
51 virtual bool isUpdating() const { 53 virtual bool isUpdating() const {
52 return m_decodeThread && m_decodeThread->isRunning(); 54 return m_decodeThread && m_decodeThread->isRunning();
53 } 55 }
54 56
57 public slots:
58 void cancelled();
59
55 protected: 60 protected:
56 FileSource m_source; 61 FileSource m_source;
57 QString m_path; 62 QString m_path;
58 QString m_error; 63 QString m_error;
59 bool m_cancelled; 64 bool m_cancelled;
60 size_t m_processed; 65 size_t m_processed;
61 int m_completion; 66 int m_completion;
62 67
63 WavFileReader *m_original; 68 WavFileReader *m_original;
64 QProgressDialog *m_progress; 69 ProgressReporter *m_reporter;
65 70
66 void addBlock(const SampleBlock &frames); 71 void addBlock(const SampleBlock &frames);
67 72
68 class DecodeThread : public Thread 73 class DecodeThread : public Thread
69 { 74 {