comparison src/Silvet.cpp @ 327:df9a8e16bae6 livemode-octave-higher

Experiment with dropping the bottom octave off each template (since most of the information is in higher harmonics anyway!) -- this is about 15% faster again and has half the latency, but per
author Chris Cannam
date Tue, 19 May 2015 09:29:00 +0100
parents 4cf4313d7e30
children
comparison
equal deleted inserted replaced
326:caaac814c22a 327:df9a8e16bae6
498 498
499 double minFreq = 27.5; 499 double minFreq = 27.5;
500 500
501 if (m_mode != HighQualityMode) { 501 if (m_mode != HighQualityMode) {
502 // We don't actually return any notes from the bottom octave, 502 // We don't actually return any notes from the bottom octave,
503 // so we can just pad with zeros 503 // so we can just pad with zeros. In live mode the template is
504 minFreq *= 2; 504 // an octave shorter as well. Each octave the min frequency is
505 // raised by halves the processing latency.
506 if (m_mode == LiveMode) {
507 minFreq *= 4;
508 } else {
509 minFreq *= 2;
510 }
505 } 511 }
506 512
507 int bpo = 12 * 513 int bpo = 12 *
508 (m_mode == LiveMode ? binsPerSemitoneLive : binsPerSemitoneNormal); 514 (m_mode == LiveMode ? binsPerSemitoneLive : binsPerSemitoneNormal);
509 515
772 bool wantShifts) 778 bool wantShifts)
773 { 779 {
774 double columnThreshold = 1e-5; 780 double columnThreshold = 1e-5;
775 781
776 if (m_mode == LiveMode) { 782 if (m_mode == LiveMode) {
777 columnThreshold /= 15; 783 columnThreshold /= 20;
778 } 784 }
779 785
780 vector<double> pitches(pack.templateNoteCount, 0.0); 786 vector<double> pitches(pack.templateNoteCount, 0.0);
781 vector<int> bestShifts; 787 vector<int> bestShifts;
782 788
863 869
864 if (select) { 870 if (select) {
865 vector<double> inCol = in[i]; 871 vector<double> inCol = in[i];
866 vector<double> outCol(pack.templateHeight); 872 vector<double> outCol(pack.templateHeight);
867 873
868 // In HQ mode, the CQ returns 600 bins and we ignore the 874 // In HQ mode, the CQ returns 600 bins (10 octaves at 5
869 // lowest 55 of them (assuming binsPerSemitone == 5). 875 // bins per semitone) and we ignore the lowest 55 of them,
870 // 876 // giving us 545 bins total, which matches the height of
871 // In draft and live mode the CQ is an octave shorter, 877 // each of our instrument templates.
872 // returning 540 bins or equivalent, so we instead pad 878 //
873 // them with an additional 5 or equivalent zeros. 879 // In draft mode the CQ is an octave shorter, returning
880 // 540 bins, so we instead pad with an additional 5 zeros
881 // at the lowest frequencies to get the same 545 bins.
882 //
883 // In live mode the CQ is two octaves shorter and only has
884 // 1 bin per semitone, and the template is also an octave
885 // shorter. So we get 96 bins (= 8 * 12) and want 97 (=
886 // (545 / 5) - 12), meaning we have to pad with one extra
887 // bin at the lowest frequency position. Essentially this
888 // is the same as draft mode (pad with bins-per-semitone
889 // bins), just that the result is a shorter vector.
874 // 890 //
875 // We also need to reverse the column as we go, since the 891 // We also need to reverse the column as we go, since the
876 // raw CQ has the high frequencies first and we need it 892 // raw CQ has the high frequencies first and we need it
877 // the other way around. 893 // the other way around.
878 894
883 for (int j = 0; j < pack.templateHeight; ++j) { 899 for (int j = 0; j < pack.templateHeight; ++j) {
884 int ix = inCol.size() - j - (11 * bps); 900 int ix = inCol.size() - j - (11 * bps);
885 outCol[j] = inCol[ix]; 901 outCol[j] = inCol[ix];
886 } 902 }
887 } else { 903 } else {
888 for (int j = 0; j < bps; ++j) { 904 int pad = bps;
905 for (int j = 0; j < pad; ++j) {
889 outCol[j] = 0.0; 906 outCol[j] = 0.0;
890 } 907 }
891 for (int j = bps; j < pack.templateHeight; ++j) { 908 for (int j = pad; j < pack.templateHeight; ++j) {
892 int ix = inCol.size() - j + (bps-1); 909 int ix = inCol.size() - j + (pad-1);
893 outCol[j] = inCol[ix]; 910 outCol[j] = inCol[ix];
894 } 911 }
895 } 912 }
896 913
897 vector<double> noiseLevel1 = 914 vector<double> noiseLevel1 =