Mercurial > hg > silvet
comparison src/Silvet.cpp @ 106:ac750e222ad3 bqvec-openmp
Merge OpenMP and bqvec stuff into bqvec-openmp branch
author | Chris Cannam |
---|---|
date | Tue, 06 May 2014 16:36:46 +0100 |
parents | 81eaba98985b 62b7be1226d5 |
children | 2169e7a448c5 |
comparison
equal
deleted
inserted
replaced
103:e6b4235fa2ea | 106:ac750e222ad3 |
---|---|
373 { | 373 { |
374 Grid filtered = preProcess(cqout); | 374 Grid filtered = preProcess(cqout); |
375 | 375 |
376 FeatureSet fs; | 376 FeatureSet fs; |
377 | 377 |
378 if (filtered.empty()) return fs; | |
379 | |
378 for (int i = 0; i < (int)filtered.size(); ++i) { | 380 for (int i = 0; i < (int)filtered.size(); ++i) { |
379 Feature f; | 381 Feature f; |
380 for (int j = 0; j < processingHeight; ++j) { | 382 for (int j = 0; j < processingHeight; ++j) { |
381 f.values.push_back(float(filtered[i][j])); | 383 f.values.push_back(float(filtered[i][j])); |
382 } | 384 } |
385 | 387 |
386 int width = filtered.size(); | 388 int width = filtered.size(); |
387 | 389 |
388 int iterations = 12; | 390 int iterations = 12; |
389 | 391 |
390 for (int i = 0; i < width; ++i) { | 392 int stride = 8; |
391 | 393 |
392 double sum = 0.0; | 394 for (int i = 0; i < width; i += stride) { |
393 for (int j = 0; j < processingHeight; ++j) { | 395 |
394 sum += filtered[i][j]; | 396 int chunk = stride; |
395 } | 397 if (i + chunk > width) { |
396 | 398 chunk = width - i; |
397 if (sum < 1e-5) continue; | 399 } |
398 | 400 |
399 EM em; | 401 vector<vector<double> > pitchSubMatrix |
400 for (int j = 0; j < iterations; ++j) { | 402 (chunk, vector<double>(processingNotes)); |
401 em.iterate(filtered[i].data()); | 403 |
402 } | 404 #pragma omp parallel for |
403 | 405 for (int k = 0; k < chunk; ++k) { |
404 const double *pd = em.getPitchDistribution(); | 406 |
405 vector<double> pitches(pd, pd + processingNotes); | 407 double sum = 0.0; |
408 for (int j = 0; j < processingHeight; ++j) { | |
409 sum += filtered[i + k][j]; | |
410 } | |
411 | |
412 if (sum < 1e-5) continue; | |
413 | |
414 EM em; | |
415 for (int j = 0; j < iterations; ++j) { | |
416 em.iterate(filtered[i + k].data()); | |
417 } | |
418 | |
419 const double *pitches = em.getPitchDistribution(); | |
406 | 420 |
407 for (int j = 0; j < processingNotes; ++j) { | 421 for (int j = 0; j < processingNotes; ++j) { |
408 pitches[j] *= sum; | 422 pitchSubMatrix[k][j] = pitches[j] * sum; |
409 } | 423 } |
410 | 424 } |
411 Feature f; | 425 |
412 for (int j = 0; j < processingNotes; ++j) { | 426 for (int k = 0; k < chunk; ++k) { |
413 f.values.push_back(float(pitches[j])); | 427 |
414 } | 428 const vector<double> &pitches = pitchSubMatrix[k]; |
415 fs[m_pitchOutputNo].push_back(f); | 429 |
416 | 430 Feature f; |
417 FeatureList noteFeatures = postProcess(pitches); | 431 for (int j = 0; j < processingNotes; ++j) { |
418 | 432 f.values.push_back(float(pitches[j])); |
419 for (FeatureList::const_iterator fi = noteFeatures.begin(); | 433 } |
420 fi != noteFeatures.end(); ++fi) { | 434 fs[m_pitchOutputNo].push_back(f); |
421 fs[m_notesOutputNo].push_back(*fi); | 435 |
436 FeatureList noteFeatures = postProcess(pitches); | |
437 | |
438 for (FeatureList::const_iterator fi = noteFeatures.begin(); | |
439 fi != noteFeatures.end(); ++fi) { | |
440 fs[m_notesOutputNo].push_back(*fi); | |
441 } | |
422 } | 442 } |
423 } | 443 } |
424 | 444 |
425 return fs; | 445 return fs; |
426 } | 446 } |