Mercurial > hg > silvet
comparison src/Silvet.cpp @ 34:7d81407a2fd8
Start on EM class
author | Chris Cannam |
---|---|
date | Fri, 04 Apr 2014 14:28:41 +0100 |
parents | e08c330a761d |
children | 74b77a4d6552 |
comparison
equal
deleted
inserted
replaced
33:e08c330a761d | 34:7d81407a2fd8 |
---|---|
12 License, or (at your option) any later version. See the file | 12 License, or (at your option) any later version. See the file |
13 COPYING included with this distribution for more information. | 13 COPYING included with this distribution for more information. |
14 */ | 14 */ |
15 | 15 |
16 #include "Silvet.h" | 16 #include "Silvet.h" |
17 | 17 #include "EM.h" |
18 #include "data/include/templates.h" | |
19 | 18 |
20 #include "maths/MedianFilter.h" | 19 #include "maths/MedianFilter.h" |
21 #include "dsp/rateconversion/Resampler.h" | 20 #include "dsp/rateconversion/Resampler.h" |
22 | 21 |
23 #include "constant-q-cpp/cpp-qm-dsp/CQInterpolated.h" | 22 #include "constant-q-cpp/cpp-qm-dsp/CQInterpolated.h" |
265 if (m_resampler) { | 264 if (m_resampler) { |
266 data = m_resampler->process(data.data(), data.size()); | 265 data = m_resampler->process(data.data(), data.size()); |
267 } | 266 } |
268 | 267 |
269 Grid cqout = m_cq->process(data); | 268 Grid cqout = m_cq->process(data); |
269 return transcribe(cqout); | |
270 } | |
271 | |
272 Silvet::FeatureSet | |
273 Silvet::getRemainingFeatures() | |
274 { | |
275 Grid cqout = m_cq->getRemainingBlocks(); | |
276 return transcribe(cqout); | |
277 } | |
278 | |
279 Silvet::FeatureSet | |
280 Silvet::transcribe(const Grid &cqout) | |
281 { | |
270 Grid filtered = preProcess(cqout); | 282 Grid filtered = preProcess(cqout); |
271 | 283 |
272 FeatureSet fs; | 284 FeatureSet fs; |
273 | 285 |
274 for (int i = 0; i < (int)filtered.size(); ++i) { | 286 for (int i = 0; i < (int)filtered.size(); ++i) { |
277 f.values.push_back(float(filtered[i][j])); | 289 f.values.push_back(float(filtered[i][j])); |
278 } | 290 } |
279 fs[m_cqOutputNo].push_back(f); | 291 fs[m_cqOutputNo].push_back(f); |
280 } | 292 } |
281 | 293 |
294 int width = filtered.size(); | |
295 | |
296 int iterations = 12; | |
297 | |
298 for (int i = 0; i < width; ++i) { | |
299 EM em; | |
300 for (int j = 0; j < iterations; ++j) { | |
301 em.iterate(filtered[i]); | |
302 } | |
303 //!!! now do something with the results from em! | |
304 } | |
305 | |
282 return fs; | 306 return fs; |
283 } | |
284 | |
285 Silvet::FeatureSet | |
286 Silvet::getRemainingFeatures() | |
287 { | |
288 | |
289 return FeatureSet(); | |
290 } | 307 } |
291 | 308 |
292 Silvet::Grid | 309 Silvet::Grid |
293 Silvet::preProcess(const Grid &in) | 310 Silvet::preProcess(const Grid &in) |
294 { | 311 { |
329 | 346 |
330 for (int j = 0; j < processingHeight; ++j) { | 347 for (int j = 0; j < processingHeight; ++j) { |
331 | 348 |
332 int ix = inCol.size() - j - 55; | 349 int ix = inCol.size() - j - 55; |
333 | 350 |
334 //!!! note these filters introduce more latency | |
335 | |
336 double val = inCol[ix]; | 351 double val = inCol[ix]; |
337 m_filterA[j]->push(val); | 352 m_filterA[j]->push(val); |
338 | 353 |
339 double a = m_filterA[j]->get(); | 354 double a = m_filterA[j]->get(); |
340 m_filterB[j]->push(std::min(a, val)); | 355 m_filterB[j]->push(std::min(a, val)); |