comparison data/fileio/DecodingWavFileReader.cpp @ 1126:39019ce29178 tony-2.0-integration

Merge through to branch for Tony 2.0
author Chris Cannam
date Thu, 20 Aug 2015 14:54:21 +0100
parents abc309f507ae
children 0a9193dc136b
comparison
equal deleted inserted replaced
1119:e22bfe8ca248 1126:39019ce29178
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 23
24 using namespace std;
25
24 DecodingWavFileReader::DecodingWavFileReader(FileSource source, 26 DecodingWavFileReader::DecodingWavFileReader(FileSource source,
25 ResampleMode resampleMode, 27 DecodeMode decodeMode,
26 CacheMode mode, 28 CacheMode mode,
27 sv_samplerate_t targetRate, 29 sv_samplerate_t targetRate,
28 bool normalised, 30 bool normalised,
29 ProgressReporter *reporter) : 31 ProgressReporter *reporter) :
30 CodedAudioFileReader(mode, targetRate, normalised), 32 CodedAudioFileReader(mode, targetRate, normalised),
54 m_channelCount = m_original->getChannelCount(); 56 m_channelCount = m_original->getChannelCount();
55 m_fileRate = m_original->getSampleRate(); 57 m_fileRate = m_original->getSampleRate();
56 58
57 initialiseDecodeCache(); 59 initialiseDecodeCache();
58 60
59 if (resampleMode == ResampleAtOnce) { 61 if (decodeMode == DecodeAtOnce) {
60 62
61 if (m_reporter) { 63 if (m_reporter) {
62 connect(m_reporter, SIGNAL(cancelled()), this, SLOT(cancelled())); 64 connect(m_reporter, SIGNAL(cancelled()), this, SLOT(cancelled()));
63 m_reporter->setMessage 65 m_reporter->setMessage
64 (tr("Decoding %1...").arg(QFileInfo(m_path).fileName())); 66 (tr("Decoding %1...").arg(QFileInfo(m_path).fileName()));
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