Mercurial > hg > svcore
comparison data/fileio/DecodingWavFileReader.cpp @ 1096:4d9816ba0ebe simple-fft-model
Rework audio file reader API to prefer using std containers
author | Chris Cannam |
---|---|
date | Mon, 15 Jun 2015 12:19:47 +0100 |
parents | 843f67be0ed9 |
children | abc309f507ae |
comparison
equal
deleted
inserted
replaced
1095:b66734b5f806 | 1096:4d9816ba0ebe |
---|---|
18 #include "WavFileReader.h" | 18 #include "WavFileReader.h" |
19 #include "base/Profiler.h" | 19 #include "base/Profiler.h" |
20 #include "base/ProgressReporter.h" | 20 #include "base/ProgressReporter.h" |
21 | 21 |
22 #include <QFileInfo> | 22 #include <QFileInfo> |
23 | |
24 using namespace std; | |
23 | 25 |
24 DecodingWavFileReader::DecodingWavFileReader(FileSource source, | 26 DecodingWavFileReader::DecodingWavFileReader(FileSource source, |
25 ResampleMode resampleMode, | 27 ResampleMode resampleMode, |
26 CacheMode mode, | 28 CacheMode mode, |
27 sv_samplerate_t targetRate, | 29 sv_samplerate_t targetRate, |
65 } | 67 } |
66 | 68 |
67 sv_frame_t blockSize = 16384; | 69 sv_frame_t blockSize = 16384; |
68 sv_frame_t total = m_original->getFrameCount(); | 70 sv_frame_t total = m_original->getFrameCount(); |
69 | 71 |
70 SampleBlock block; | 72 vector<float> block; |
71 | 73 |
72 for (sv_frame_t i = 0; i < total; i += blockSize) { | 74 for (sv_frame_t i = 0; i < total; i += blockSize) { |
73 | 75 |
74 sv_frame_t count = blockSize; | 76 sv_frame_t count = blockSize; |
75 if (i + count > total) count = total - i; | 77 if (i + count > total) count = total - i; |
122 } | 124 } |
123 | 125 |
124 sv_frame_t blockSize = 16384; | 126 sv_frame_t blockSize = 16384; |
125 sv_frame_t total = m_reader->m_original->getFrameCount(); | 127 sv_frame_t total = m_reader->m_original->getFrameCount(); |
126 | 128 |
127 SampleBlock block; | 129 vector<float> block; |
128 | 130 |
129 for (sv_frame_t i = 0; i < total; i += blockSize) { | 131 for (sv_frame_t i = 0; i < total; i += blockSize) { |
130 | 132 |
131 sv_frame_t count = blockSize; | 133 sv_frame_t count = blockSize; |
132 if (i + count > total) count = total - i; | 134 if (i + count > total) count = total - i; |
145 delete m_reader->m_original; | 147 delete m_reader->m_original; |
146 m_reader->m_original = 0; | 148 m_reader->m_original = 0; |
147 } | 149 } |
148 | 150 |
149 void | 151 void |
150 DecodingWavFileReader::addBlock(const SampleBlock &frames) | 152 DecodingWavFileReader::addBlock(const vector<float> &frames) |
151 { | 153 { |
152 addSamplesToDecodeCache(frames); | 154 addSamplesToDecodeCache(frames); |
153 | 155 |
154 m_processed += frames.size(); | 156 m_processed += frames.size(); |
155 | 157 |
165 m_reporter->setProgress(progress); | 167 m_reporter->setProgress(progress); |
166 } | 168 } |
167 } | 169 } |
168 | 170 |
169 void | 171 void |
170 DecodingWavFileReader::getSupportedExtensions(std::set<QString> &extensions) | 172 DecodingWavFileReader::getSupportedExtensions(set<QString> &extensions) |
171 { | 173 { |
172 WavFileReader::getSupportedExtensions(extensions); | 174 WavFileReader::getSupportedExtensions(extensions); |
173 } | 175 } |
174 | 176 |
175 bool | 177 bool |