comparison data/fileio/DecodingWavFileReader.h @ 823:f0558e69a074

Rename Resampling- to DecodingWavFileReader, and use it whenever we have an audio file that is not quickly seekable using libsndfile. Avoids very slow performance when analysing ogg files.
author Chris Cannam
date Wed, 17 Jul 2013 15:40:01 +0100
parents data/fileio/ResamplingWavFileReader.h@183ee2a55fc7
children f3cda3280398 59e7fe1b1003
comparison
equal deleted inserted replaced
821:06c64a1c6785 823:f0558e69a074
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2007 QMUL.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #ifndef _DECODING_WAV_FILE_READER_H_
17 #define _DECODING_WAV_FILE_READER_H_
18
19 #include "CodedAudioFileReader.h"
20
21 #include "base/Thread.h"
22
23 #include <set>
24
25 class WavFileReader;
26 class ProgressReporter;
27
28 class DecodingWavFileReader : public CodedAudioFileReader
29 {
30 Q_OBJECT
31 public:
32 enum ResampleMode {
33 ResampleAtOnce, // resample the file on construction, with progress dialog
34 ResampleThreaded // resample in a background thread after construction
35 };
36
37 DecodingWavFileReader(FileSource source,
38 ResampleMode resampleMode,
39 CacheMode cacheMode,
40 size_t targetRate = 0,
41 ProgressReporter *reporter = 0);
42 virtual ~DecodingWavFileReader();
43
44 virtual QString getError() const { return m_error; }
45 virtual QString getLocation() const { return m_source.getLocation(); }
46 static void getSupportedExtensions(std::set<QString> &extensions);
47 static bool supportsExtension(QString ext);
48 static bool supportsContentType(QString type);
49 static bool supports(FileSource &source);
50
51 virtual int getDecodeCompletion() const { return m_completion; }
52
53 virtual bool isUpdating() const {
54 return m_decodeThread && m_decodeThread->isRunning();
55 }
56
57 public slots:
58 void cancelled();
59
60 protected:
61 FileSource m_source;
62 QString m_path;
63 QString m_error;
64 bool m_cancelled;
65 size_t m_processed;
66 int m_completion;
67
68 WavFileReader *m_original;
69 ProgressReporter *m_reporter;
70
71 void addBlock(const SampleBlock &frames);
72
73 class DecodeThread : public Thread
74 {
75 public:
76 DecodeThread(DecodingWavFileReader *reader) : m_reader(reader) { }
77 virtual void run();
78
79 protected:
80 DecodingWavFileReader *m_reader;
81 };
82
83 DecodeThread *m_decodeThread;
84 };
85
86 #endif
87