Mercurial > hg > svcore
comparison data/model/ReadOnlyWaveFileModel.cpp @ 1326:54af1e21705c 3.0-integration
Update to use bqvec allocator for float vectors
author | Chris Cannam |
---|---|
date | Tue, 13 Dec 2016 15:23:21 +0000 |
parents | ff9697592bef |
children | d40246df828b |
comparison
equal
deleted
inserted
replaced
1325:3aea4f7617bb | 1326:54af1e21705c |
---|---|
200 { | 200 { |
201 if (m_reader) return m_reader->getLocalFilename(); | 201 if (m_reader) return m_reader->getLocalFilename(); |
202 return ""; | 202 return ""; |
203 } | 203 } |
204 | 204 |
205 vector<float> | 205 floatvec_t |
206 ReadOnlyWaveFileModel::getData(int channel, sv_frame_t start, sv_frame_t count) const | 206 ReadOnlyWaveFileModel::getData(int channel, sv_frame_t start, sv_frame_t count) const |
207 { | 207 { |
208 // Read directly from the file. This is used for e.g. audio | 208 // Read directly from the file. This is used for e.g. audio |
209 // playback or input to transforms. | 209 // playback or input to transforms. |
210 | 210 |
234 count -= (m_startFrame - start); | 234 count -= (m_startFrame - start); |
235 start = 0; | 235 start = 0; |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 vector<float> interleaved = m_reader->getInterleavedFrames(start, count); | 239 floatvec_t interleaved = m_reader->getInterleavedFrames(start, count); |
240 if (channels == 1) return interleaved; | 240 if (channels == 1) return interleaved; |
241 | 241 |
242 sv_frame_t obtained = interleaved.size() / channels; | 242 sv_frame_t obtained = interleaved.size() / channels; |
243 | 243 |
244 vector<float> result(obtained, 0.f); | 244 floatvec_t result(obtained, 0.f); |
245 | 245 |
246 if (channel != -1) { | 246 if (channel != -1) { |
247 // get a single channel | 247 // get a single channel |
248 for (int i = 0; i < obtained; ++i) { | 248 for (int i = 0; i < obtained; ++i) { |
249 result[i] = interleaved[i * channels + channel]; | 249 result[i] = interleaved[i * channels + channel]; |
258 } | 258 } |
259 | 259 |
260 return result; | 260 return result; |
261 } | 261 } |
262 | 262 |
263 vector<vector<float>> | 263 vector<floatvec_t> |
264 ReadOnlyWaveFileModel::getMultiChannelData(int fromchannel, int tochannel, | 264 ReadOnlyWaveFileModel::getMultiChannelData(int fromchannel, int tochannel, |
265 sv_frame_t start, sv_frame_t count) const | 265 sv_frame_t start, sv_frame_t count) const |
266 { | 266 { |
267 // Read directly from the file. This is used for e.g. audio | 267 // Read directly from the file. This is used for e.g. audio |
268 // playback or input to transforms. | 268 // playback or input to transforms. |
302 count -= (m_startFrame - start); | 302 count -= (m_startFrame - start); |
303 start = 0; | 303 start = 0; |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
307 vector<float> interleaved = m_reader->getInterleavedFrames(start, count); | 307 floatvec_t interleaved = m_reader->getInterleavedFrames(start, count); |
308 if (channels == 1) return { interleaved }; | 308 if (channels == 1) return { interleaved }; |
309 | 309 |
310 sv_frame_t obtained = interleaved.size() / channels; | 310 sv_frame_t obtained = interleaved.size() / channels; |
311 vector<vector<float>> result(reqchannels, vector<float>(obtained, 0.f)); | 311 vector<floatvec_t> result(reqchannels, floatvec_t(obtained, 0.f)); |
312 | 312 |
313 for (int c = fromchannel; c <= tochannel; ++c) { | 313 for (int c = fromchannel; c <= tochannel; ++c) { |
314 int destc = c - fromchannel; | 314 int destc = c - fromchannel; |
315 for (int i = 0; i < obtained; ++i) { | 315 for (int i = 0; i < obtained; ++i) { |
316 result[destc][i] = interleaved[i * channels + c]; | 316 result[destc][i] = interleaved[i * channels + c]; |
586 cacheBlockSize[1] = (int((1 << m_model.m_zoomConstraint.getMinCachePower()) * | 586 cacheBlockSize[1] = (int((1 << m_model.m_zoomConstraint.getMinCachePower()) * |
587 sqrt(2.) + 0.01)); | 587 sqrt(2.) + 0.01)); |
588 | 588 |
589 sv_frame_t frame = 0; | 589 sv_frame_t frame = 0; |
590 const sv_frame_t readBlockSize = 32768; | 590 const sv_frame_t readBlockSize = 32768; |
591 vector<float> block; | 591 floatvec_t block; |
592 | 592 |
593 if (!m_model.isOK()) return; | 593 if (!m_model.isOK()) return; |
594 | 594 |
595 int channels = m_model.getChannelCount(); | 595 int channels = m_model.getChannelCount(); |
596 bool updating = m_model.m_reader->isUpdating(); | 596 bool updating = m_model.m_reader->isUpdating(); |