Mercurial > hg > qm-vamp-plugins
comparison plugins/SimilarityPlugin.cpp @ 178:f96ea0e4b475
Fix compiler warnings with -Wall -Wextra
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Mon, 28 Sep 2015 12:33:17 +0100 |
parents | dcf5800f0f00 |
children | af6a5ba00a8f |
comparison
equal
deleted
inserted
replaced
177:a83a81ed1303 | 178:f96ea0e4b475 |
---|---|
505 } | 505 } |
506 | 506 |
507 void | 507 void |
508 SimilarityPlugin::reset() | 508 SimilarityPlugin::reset() |
509 { | 509 { |
510 for (int i = 0; i < m_values.size(); ++i) { | 510 for (int i = 0; i < int(m_values.size()); ++i) { |
511 m_values[i].clear(); | 511 m_values[i].clear(); |
512 } | 512 } |
513 | 513 |
514 for (int i = 0; i < m_rhythmValues.size(); ++i) { | 514 for (int i = 0; i < int(m_rhythmValues.size()); ++i) { |
515 m_rhythmValues[i].clear(); | 515 m_rhythmValues[i].clear(); |
516 } | 516 } |
517 | 517 |
518 for (int i = 0; i < m_lastNonEmptyFrame.size(); ++i) { | 518 for (int i = 0; i < int(m_lastNonEmptyFrame.size()); ++i) { |
519 m_lastNonEmptyFrame[i] = -1; | 519 m_lastNonEmptyFrame[i] = -1; |
520 } | 520 } |
521 | 521 |
522 for (int i = 0; i < m_emptyFrameCount.size(); ++i) { | 522 for (int i = 0; i < int(m_emptyFrameCount.size()); ++i) { |
523 m_emptyFrameCount[i] = 0; | 523 m_emptyFrameCount[i] = 0; |
524 } | 524 } |
525 | 525 |
526 m_done = false; | 526 m_done = false; |
527 } | 527 } |
542 | 542 |
543 float threshold = 1e-10; | 543 float threshold = 1e-10; |
544 | 544 |
545 bool someRhythmFrameNeeded = false; | 545 bool someRhythmFrameNeeded = false; |
546 | 546 |
547 for (size_t c = 0; c < m_channels; ++c) { | 547 for (int c = 0; c < m_channels; ++c) { |
548 | 548 |
549 bool empty = true; | 549 bool empty = true; |
550 | 550 |
551 for (int i = 0; i < m_blockSize; ++i) { | 551 for (int i = 0; i < m_blockSize; ++i) { |
552 float val = inputBuffers[c][i]; | 552 float val = inputBuffers[c][i]; |
555 } | 555 } |
556 | 556 |
557 if (empty) { | 557 if (empty) { |
558 if (needRhythm() && ((m_frameNo % 2) == 0)) { | 558 if (needRhythm() && ((m_frameNo % 2) == 0)) { |
559 for (int i = 0; i < m_fftSize / m_rhythmClipFrameSize; ++i) { | 559 for (int i = 0; i < m_fftSize / m_rhythmClipFrameSize; ++i) { |
560 if (m_rhythmValues[c].size() < m_rhythmClipFrames) { | 560 if (int(m_rhythmValues[c].size()) < m_rhythmClipFrames) { |
561 FeatureColumn mf(m_rhythmColumnSize); | 561 FeatureColumn mf(m_rhythmColumnSize); |
562 for (int i = 0; i < m_rhythmColumnSize; ++i) { | 562 for (int i = 0; i < m_rhythmColumnSize; ++i) { |
563 mf[i] = 0.0; | 563 mf[i] = 0.0; |
564 } | 564 } |
565 m_rhythmValues[c].push_back(mf); | 565 m_rhythmValues[c].push_back(mf); |
607 | 607 |
608 while (frameOffset + m_rhythmClipFrameSize <= m_fftSize) { | 608 while (frameOffset + m_rhythmClipFrameSize <= m_fftSize) { |
609 | 609 |
610 bool needRhythmFrame = true; | 610 bool needRhythmFrame = true; |
611 | 611 |
612 if (m_rhythmValues[c].size() >= m_rhythmClipFrames) { | 612 if (int(m_rhythmValues[c].size()) >= m_rhythmClipFrames) { |
613 | 613 |
614 needRhythmFrame = false; | 614 needRhythmFrame = false; |
615 | 615 |
616 // assumes hopsize = framesize/2 | 616 // assumes hopsize = framesize/2 |
617 float current = m_frameNo * (m_fftSize/2) + frameOffset; | 617 float current = m_frameNo * (m_fftSize/2) + frameOffset; |
679 // We want to take values up to, but not including, the | 679 // We want to take values up to, but not including, the |
680 // last non-empty frame (which may be partial) | 680 // last non-empty frame (which may be partial) |
681 | 681 |
682 int sz = m_lastNonEmptyFrame[i] - m_emptyFrameCount[i]; | 682 int sz = m_lastNonEmptyFrame[i] - m_emptyFrameCount[i]; |
683 if (sz < 0) sz = 0; | 683 if (sz < 0) sz = 0; |
684 if (sz >= m_values[i].size()) sz = m_values[i].size()-1; | 684 if (sz >= int(m_values[i].size())) { |
685 sz = int(m_values[i].size())-1; | |
686 } | |
685 | 687 |
686 count = 0; | 688 count = 0; |
687 for (int k = 0; k < sz; ++k) { | 689 for (int k = 0; k < sz; ++k) { |
688 double val = m_values[i][k][j]; | 690 double val = m_values[i][k][j]; |
689 if (ISNAN(val) || ISINF(val)) continue; | 691 if (ISNAN(val) || ISINF(val)) continue; |
801 // reasons, but BeatSpectrum::process wants a vector of vectors | 803 // reasons, but BeatSpectrum::process wants a vector of vectors |
802 // (which is what FeatureMatrix happens to be). | 804 // (which is what FeatureMatrix happens to be). |
803 | 805 |
804 FeatureMatrixSet bsinput(m_channels); | 806 FeatureMatrixSet bsinput(m_channels); |
805 for (int i = 0; i < m_channels; ++i) { | 807 for (int i = 0; i < m_channels; ++i) { |
806 for (int j = 0; j < m_rhythmValues[i].size(); ++j) { | 808 for (int j = 0; j < int(m_rhythmValues[i].size()); ++j) { |
807 bsinput[i].push_back(m_rhythmValues[i][j]); | 809 bsinput[i].push_back(m_rhythmValues[i][j]); |
808 } | 810 } |
809 } | 811 } |
810 | 812 |
811 FeatureMatrix bs(m_channels); | 813 FeatureMatrix bs(m_channels); |
832 | 834 |
833 sprintf(labelBuffer, "Beat spectrum for channel %d", i+1); | 835 sprintf(labelBuffer, "Beat spectrum for channel %d", i+1); |
834 feature.label = labelBuffer; | 836 feature.label = labelBuffer; |
835 | 837 |
836 feature.values.clear(); | 838 feature.values.clear(); |
837 for (int j = 0; j < bs[i].size(); ++j) { | 839 for (int j = 0; j < int(bs[i].size()); ++j) { |
838 feature.values.push_back(bs[i][j]); | 840 feature.values.push_back(bs[i][j]); |
839 } | 841 } |
840 | 842 |
841 returnFeatures[m_beatSpectraOutput].push_back(feature); | 843 returnFeatures[m_beatSpectraOutput].push_back(feature); |
842 } | 844 } |