Mercurial > hg > silvet
comparison src/Silvet.cpp @ 47:ccb1a437a828 preshift
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 07 Apr 2014 14:18:39 +0100 |
parents | e92376d450b0 d7f1c10f4e1d |
children | 1a4cab304d68 |
comparison
equal
deleted
inserted
replaced
45:e92376d450b0 | 47:ccb1a437a828 |
---|---|
46 | 46 |
47 Silvet::~Silvet() | 47 Silvet::~Silvet() |
48 { | 48 { |
49 delete m_resampler; | 49 delete m_resampler; |
50 delete m_cq; | 50 delete m_cq; |
51 for (int i = 0; i < (int)m_filterA.size(); ++i) { | |
52 delete m_filterA[i]; | |
53 delete m_filterB[i]; | |
54 } | |
55 for (int i = 0; i < (int)m_postFilter.size(); ++i) { | 51 for (int i = 0; i < (int)m_postFilter.size(); ++i) { |
56 delete m_postFilter[i]; | 52 delete m_postFilter[i]; |
57 } | 53 } |
58 } | 54 } |
59 | 55 |
287 | 283 |
288 m_cq = new CQInterpolated | 284 m_cq = new CQInterpolated |
289 (processingSampleRate, 27.5, processingSampleRate / 3, processingBPO, | 285 (processingSampleRate, 27.5, processingSampleRate / 3, processingBPO, |
290 CQInterpolated::Linear); | 286 CQInterpolated::Linear); |
291 | 287 |
292 for (int i = 0; i < (int)m_filterA.size(); ++i) { | |
293 delete m_filterA[i]; | |
294 delete m_filterB[i]; | |
295 } | |
296 for (int i = 0; i < (int)m_postFilter.size(); ++i) { | 288 for (int i = 0; i < (int)m_postFilter.size(); ++i) { |
297 delete m_postFilter[i]; | 289 delete m_postFilter[i]; |
298 } | 290 } |
299 m_filterA.clear(); | |
300 m_filterB.clear(); | |
301 m_postFilter.clear(); | 291 m_postFilter.clear(); |
302 for (int i = 0; i < processingHeight; ++i) { | |
303 m_filterA.push_back(new MedianFilter<double>(40)); | |
304 m_filterB.push_back(new MedianFilter<double>(40)); | |
305 } | |
306 for (int i = 0; i < processingNotes; ++i) { | 292 for (int i = 0; i < processingNotes; ++i) { |
307 m_postFilter.push_back(new MedianFilter<double>(3)); | 293 m_postFilter.push_back(new MedianFilter<double>(3)); |
308 } | 294 } |
309 m_pianoRoll.clear(); | 295 m_pianoRoll.clear(); |
310 m_columnCount = 0; | 296 m_columnCount = 0; |
433 // each column, and we want it the other way around) and | 419 // each column, and we want it the other way around) and |
434 // then ignore the first 55 (lowest-frequency) bins, | 420 // then ignore the first 55 (lowest-frequency) bins, |
435 // giving us 545 bins instead of 600 | 421 // giving us 545 bins instead of 600 |
436 | 422 |
437 for (int j = 0; j < processingHeight; ++j) { | 423 for (int j = 0; j < processingHeight; ++j) { |
438 | |
439 int ix = inCol.size() - j - 55; | 424 int ix = inCol.size() - j - 55; |
440 | 425 outCol[j] = inCol[ix]; |
441 double val = inCol[ix]; | 426 } |
442 m_filterA[j]->push(val); | 427 |
443 | 428 vector<double> noiseLevel1 = |
444 double a = m_filterA[j]->get(); | 429 MedianFilter<double>::filter(40, outCol); |
445 m_filterB[j]->push(std::min(a, val)); | 430 for (int j = 0; j < processingHeight; ++j) { |
446 | 431 noiseLevel1[j] = std::min(outCol[j], noiseLevel1[j]); |
447 double filtered = m_filterB[j]->get(); | 432 } |
448 outCol[j] = filtered; | 433 |
434 vector<double> noiseLevel2 = | |
435 MedianFilter<double>::filter(40, noiseLevel1); | |
436 for (int j = 0; j < processingHeight; ++j) { | |
437 outCol[j] = std::max(outCol[j] - noiseLevel2[j], 0.0); | |
449 } | 438 } |
450 | 439 |
451 // then we only use every fourth filtered column, for 25 | 440 // then we only use every fourth filtered column, for 25 |
452 // columns per second in the eventual grid | 441 // columns per second in the eventual grid |
442 //!!! why, if we're filtering the time columns, don't we just | |
443 // reduce to this frame rate before filtering at all? | |
453 | 444 |
454 if (m_reducedColumnCount % 4 == 0) { | 445 if (m_reducedColumnCount % 4 == 0) { |
455 out.push_back(outCol); | 446 out.push_back(outCol); |
456 } | 447 } |
457 | 448 |