Mercurial > hg > svcore
comparison data/fileio/AudioFileReader.h @ 1313:ff9697592bef 3.0-integration
Add gapless preference to prefs dialog; much work on audio read tests
author | Chris Cannam |
---|---|
date | Thu, 01 Dec 2016 17:45:40 +0000 |
parents | 4d9816ba0ebe |
children | 54af1e21705c |
comparison
equal
deleted
inserted
replaced
1312:079e553dc16e | 1313:ff9697592bef |
---|---|
29 Q_OBJECT | 29 Q_OBJECT |
30 | 30 |
31 public: | 31 public: |
32 virtual ~AudioFileReader() { } | 32 virtual ~AudioFileReader() { } |
33 | 33 |
34 /** | |
35 * Return true if the file was opened successfully and no error | |
36 * has subsequently occurred. | |
37 */ | |
34 bool isOK() const { return (m_channelCount > 0); } | 38 bool isOK() const { return (m_channelCount > 0); } |
35 | 39 |
40 /** | |
41 * If isOK() is false, return an error string. | |
42 */ | |
36 virtual QString getError() const { return ""; } | 43 virtual QString getError() const { return ""; } |
37 | 44 |
45 /** | |
46 * Return the number of audio sample frames (i.e. samples per | |
47 * channel) in the file. | |
48 */ | |
38 sv_frame_t getFrameCount() const { return m_frameCount; } | 49 sv_frame_t getFrameCount() const { return m_frameCount; } |
50 | |
51 /** | |
52 * Return the number of channels in the file. | |
53 */ | |
39 int getChannelCount() const { return m_channelCount; } | 54 int getChannelCount() const { return m_channelCount; } |
55 | |
56 /** | |
57 * Return the samplerate at which the file is being read. This is | |
58 * the rate requested when the file was opened, which may differ | |
59 * from the native rate of the file (in which case the file will | |
60 * be resampled as it is read). | |
61 */ | |
40 sv_samplerate_t getSampleRate() const { return m_sampleRate; } | 62 sv_samplerate_t getSampleRate() const { return m_sampleRate; } |
41 | 63 |
42 virtual sv_samplerate_t getNativeRate() const { return m_sampleRate; } // if resampled | 64 /** |
65 * Return the native samplerate of the file. This will differ from | |
66 * getSampleRate() if the file is being resampled because it was | |
67 * requested to open at a different rate from native. | |
68 */ | |
69 virtual sv_samplerate_t getNativeRate() const { return m_sampleRate; } | |
43 | 70 |
44 /** | 71 /** |
45 * Return the location of the audio data in the reader (as passed | 72 * Return the location of the audio data in the reader (as passed |
46 * in to the FileSource constructor, for example). | 73 * in to the FileSource constructor, for example). |
47 */ | 74 */ |
88 * | 115 * |
89 * The subclass implementations of this function must be | 116 * The subclass implementations of this function must be |
90 * thread-safe -- that is, safe to call from multiple threads with | 117 * thread-safe -- that is, safe to call from multiple threads with |
91 * different arguments on the same object at the same time. | 118 * different arguments on the same object at the same time. |
92 */ | 119 */ |
93 virtual std::vector<float> getInterleavedFrames(sv_frame_t start, sv_frame_t count) const = 0; | 120 virtual std::vector<float> getInterleavedFrames(sv_frame_t start, |
121 sv_frame_t count) const = 0; | |
94 | 122 |
95 /** | 123 /** |
96 * Return de-interleaved samples for count frames from index | 124 * Return de-interleaved samples for count frames from index |
97 * start. Implemented in this class (it calls | 125 * start. Implemented in this class (it calls |
98 * getInterleavedFrames and de-interleaves). The resulting vector | 126 * getInterleavedFrames and de-interleaves). The resulting vector |
99 * will contain getChannelCount() sample blocks of count samples | 127 * will contain getChannelCount() sample blocks of count samples |
100 * each (or fewer if end of file is reached). | 128 * each (or fewer if end of file is reached). |
101 */ | 129 */ |
102 virtual std::vector<std::vector<float> > getDeInterleavedFrames(sv_frame_t start, sv_frame_t count) const; | 130 virtual std::vector<std::vector<float> > getDeInterleavedFrames(sv_frame_t start, |
131 sv_frame_t count) const; | |
103 | 132 |
104 // only subclasses that do not know exactly how long the audio | 133 // only subclasses that do not know exactly how long the audio |
105 // file is until it's been completely decoded should implement this | 134 // file is until it's been completely decoded should implement this |
106 virtual int getDecodeCompletion() const { return 100; } // % | 135 virtual int getDecodeCompletion() const { return 100; } // % |
107 | 136 |