comparison data/fileio/WavFileReader.h @ 1527:710e6250a401 zoom

Merge from default branch
author Chris Cannam
date Mon, 17 Sep 2018 13:51:14 +0100
parents 954d0cf29ca7
children c01cbe41aeb5 f8e3dcbafb4d
comparison
equal deleted inserted replaced
1324:d4a28d1479a8 1527:710e6250a401
11 published by the Free Software Foundation; either version 2 of the 11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file 12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information. 13 COPYING included with this distribution for more information.
14 */ 14 */
15 15
16 #ifndef _WAV_FILE_READER_H_ 16 #ifndef SV_WAV_FILE_READER_H
17 #define _WAV_FILE_READER_H_ 17 #define SV_WAV_FILE_READER_H
18 18
19 #include "AudioFileReader.h" 19 #include "AudioFileReader.h"
20
21 #ifdef Q_OS_WIN
22 #include <windows.h>
23 #define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1
24 #endif
20 25
21 #include <sndfile.h> 26 #include <sndfile.h>
22 #include <QMutex> 27 #include <QMutex>
23 28
24 #include <set> 29 #include <set>
34 * to an intermediate cached file). 39 * to an intermediate cached file).
35 */ 40 */
36 class WavFileReader : public AudioFileReader 41 class WavFileReader : public AudioFileReader
37 { 42 {
38 public: 43 public:
39 WavFileReader(FileSource source, bool fileUpdating = false); 44 enum class Normalisation { None, Peak };
45
46 WavFileReader(FileSource source,
47 bool fileUpdating = false,
48 Normalisation normalise = Normalisation::None);
40 virtual ~WavFileReader(); 49 virtual ~WavFileReader();
41 50
42 virtual QString getLocation() const { return m_source.getLocation(); } 51 virtual QString getLocation() const { return m_source.getLocation(); }
43 virtual QString getError() const { return m_error; } 52 virtual QString getError() const { return m_error; }
44 53
48 57
49 /** 58 /**
50 * Must be safe to call from multiple threads with different 59 * Must be safe to call from multiple threads with different
51 * arguments on the same object at the same time. 60 * arguments on the same object at the same time.
52 */ 61 */
53 virtual std::vector<float> getInterleavedFrames(sv_frame_t start, sv_frame_t count) const; 62 virtual floatvec_t getInterleavedFrames(sv_frame_t start, sv_frame_t count)
63 const;
54 64
55 static void getSupportedExtensions(std::set<QString> &extensions); 65 static void getSupportedExtensions(std::set<QString> &extensions);
56 static bool supportsExtension(QString ext); 66 static bool supportsExtension(QString ext);
57 static bool supportsContentType(QString type); 67 static bool supportsContentType(QString type);
58 static bool supports(FileSource &source); 68 static bool supports(FileSource &source);
73 QString m_error; 83 QString m_error;
74 84
75 bool m_seekable; 85 bool m_seekable;
76 86
77 mutable QMutex m_mutex; 87 mutable QMutex m_mutex;
78 mutable std::vector<float> m_buffer; 88 mutable floatvec_t m_buffer;
79 mutable sv_frame_t m_lastStart; 89 mutable sv_frame_t m_lastStart;
80 mutable sv_frame_t m_lastCount; 90 mutable sv_frame_t m_lastCount;
81 91
92 Normalisation m_normalisation;
93 float m_max;
94
82 bool m_updating; 95 bool m_updating;
96
97 floatvec_t getInterleavedFramesUnnormalised(sv_frame_t start,
98 sv_frame_t count) const;
99 float getMax() const;
83 }; 100 };
84 101
85 #endif 102 #endif