# HG changeset patch # User Chris Cannam # Date 1400062982 -3600 # Node ID 1ffa08f9df266f87a5cdafdd158df7a33214b800 # Parent 0a089d7d162d8768a3be874811487af52504d9e1 Fixes to peak diff display diff -r 0a089d7d162d -r 1ffa08f9df26 cpp-qm-dsp/processfile.cpp --- a/cpp-qm-dsp/processfile.cpp Wed May 14 11:22:51 2014 +0100 +++ b/cpp-qm-dsp/processfile.cpp Wed May 14 11:23:02 2014 +0100 @@ -200,10 +200,14 @@ if (doDiff) { for (int i = 0; i < (int)cqout.size(); ++i) { if (outframe + i >= latency) { - cqout[i] -= buffer[outframe + i - latency]; - if (fabs(cqout[i]) > maxdiff) { + int dframe = outframe + i - latency; + if (dframe >= (int)buffer.size()) cqout[i] = 0; + else cqout[i] -= buffer[dframe]; + if (fabs(cqout[i]) > maxdiff && + dframe > sfinfo.samplerate && // ignore first/last sec + dframe + sfinfo.samplerate < sfinfo.frames) { maxdiff = fabs(cqout[i]); - maxdiffidx = outframe + i - latency; + maxdiffidx = dframe; } } } @@ -241,10 +245,14 @@ if (doDiff) { for (int i = 0; i < (int)r.size(); ++i) { if (outframe + i >= latency) { - r[i] -= buffer[outframe + i - latency]; - if (fabs(r[i]) > maxdiff) { + int dframe = outframe + i - latency; + if (dframe >= (int)buffer.size()) r[i] = 0; + else r[i] -= buffer[dframe]; + if (fabs(r[i]) > maxdiff && + dframe > sfinfo.samplerate && // ignore first/last sec + dframe + sfinfo.samplerate < sfinfo.frames) { maxdiff = fabs(r[i]); - maxdiffidx = outframe + i - latency; + maxdiffidx = dframe; } } } @@ -262,7 +270,9 @@ cerr << "in: " << inframe << ", out: " << outframe - latency << endl; if (doDiff) { - cerr << "max diff is " << maxdiff + double db = 10 * log10(maxdiff); + cerr << "max diff [excluding first and last second of audio] is " + << maxdiff << " (" << db << " dBFS)" << " at sample index " << maxdiffidx << endl; }