Mercurial > hg > constant-q-cpp
comparison vamp/CQVamp.cpp @ 36:cb072f01435b
Get remaining blocks from end of processing; fix some compile warnings, etc
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Wed, 06 Nov 2013 16:21:28 +0000 |
parents | 75d528478feb |
children | a25abb7a21c0 |
comparison
equal
deleted
inserted
replaced
35:75d528478feb | 36:cb072f01435b |
---|---|
157 if (m_cq) { | 157 if (m_cq) { |
158 delete m_cq; | 158 delete m_cq; |
159 m_cq = new ConstantQ | 159 m_cq = new ConstantQ |
160 (m_inputSampleRate, m_minFrequency, m_maxFrequency, m_bpo); | 160 (m_inputSampleRate, m_minFrequency, m_maxFrequency, m_bpo); |
161 } | 161 } |
162 m_prevFeature.clear(); | |
162 } | 163 } |
163 | 164 |
164 size_t | 165 size_t |
165 CQVamp::getPreferredStepSize() const | 166 CQVamp::getPreferredStepSize() const |
166 { | 167 { |
207 | 208 |
208 vector<double> data; | 209 vector<double> data; |
209 for (int i = 0; i < m_blockSize; ++i) data.push_back(inputBuffers[0][i]); | 210 for (int i = 0; i < m_blockSize; ++i) data.push_back(inputBuffers[0][i]); |
210 | 211 |
211 vector<vector<double> > cqout = m_cq->process(data); | 212 vector<vector<double> > cqout = m_cq->process(data); |
212 | 213 return convertToFeatures(cqout); |
214 } | |
215 | |
216 CQVamp::FeatureSet | |
217 CQVamp::getRemainingFeatures() | |
218 { | |
219 vector<vector<double> > cqout = m_cq->getRemainingBlocks(); | |
220 return convertToFeatures(cqout); | |
221 } | |
222 | |
223 CQVamp::FeatureSet | |
224 CQVamp::convertToFeatures(const vector<vector<double> > &cqout) | |
225 { | |
226 | |
213 FeatureSet returnFeatures; | 227 FeatureSet returnFeatures; |
214 | 228 |
215 for (int i = 0; i < cqout.size(); ++i) { | 229 for (int i = 0; i < (int)cqout.size(); ++i) { |
216 | 230 |
217 vector<float> column(m_cq->getTotalBins(), 0.f); | 231 vector<float> column(m_cq->getTotalBins(), 0.f); |
218 for (int j = 0; j < cqout[i].size(); ++j) { | 232 |
233 for (int j = 0; j < (int)cqout[i].size(); ++j) { | |
219 column[j] = cqout[i][j]; | 234 column[j] = cqout[i][j]; |
220 } | 235 } |
236 for (int j = cqout[i].size(); j < m_cq->getTotalBins(); ++j) { | |
237 if (j < (int)m_prevFeature.size()) { | |
238 column[j] = m_prevFeature[j]; | |
239 } | |
240 } | |
241 | |
242 m_prevFeature = column; | |
221 | 243 |
222 Feature feature; | 244 Feature feature; |
223 feature.hasTimestamp = false; | 245 feature.hasTimestamp = false; |
224 feature.values = column; | 246 feature.values = column; |
225 feature.label = ""; | 247 feature.label = ""; |
227 } | 249 } |
228 | 250 |
229 return returnFeatures; | 251 return returnFeatures; |
230 } | 252 } |
231 | 253 |
232 CQVamp::FeatureSet | |
233 CQVamp::getRemainingFeatures() | |
234 { | |
235 return FeatureSet(); | |
236 } | |
237 |