# HG changeset patch # User Chris Cannam # Date 1399725864 -3600 # Node ID 54c4b7719ff29c1d3e8c4cb200ffb97d42bc1956 # Parent fb5bcb44277ac669135afadbc1d4080da1f397e5 Simplify a bit, add some debug out diff -r fb5bcb44277a -r 54c4b7719ff2 cpp-qm-dsp/CQInverse.cpp --- a/cpp-qm-dsp/CQInverse.cpp Sat May 10 11:57:59 2014 +0100 +++ b/cpp-qm-dsp/CQInverse.cpp Sat May 10 13:44:24 2014 +0100 @@ -108,6 +108,8 @@ Resampler *r = new Resampler (sourceRate / factor, sourceRate, 60, 0.02); + cerr << "inverse: octave " << i << ": resample from " << sourceRate/factor << " to " << sourceRate << endl; + // See ConstantQ.cpp for discussion on latency -- output // latency here is at target rate which, this way around, is // what we want diff -r fb5bcb44277a -r 54c4b7719ff2 cpp-qm-dsp/ConstantQ.cpp --- a/cpp-qm-dsp/ConstantQ.cpp Sat May 10 11:57:59 2014 +0100 +++ b/cpp-qm-dsp/ConstantQ.cpp Sat May 10 13:44:24 2014 +0100 @@ -110,6 +110,8 @@ Resampler *r = new Resampler (sourceRate, sourceRate / factor, 60, 0.02); + cerr << "forward: octave " << i << ": resample from " << sourceRate << " to " << sourceRate / factor << endl; + // We need to adapt the latencies so as to get the first input // sample to be aligned, in time, at the decimator output // across all octaves. diff -r fb5bcb44277a -r 54c4b7719ff2 cpp-qm-dsp/processfile.cpp --- a/cpp-qm-dsp/processfile.cpp Sat May 10 11:57:59 2014 +0100 +++ b/cpp-qm-dsp/processfile.cpp Sat May 10 13:44:24 2014 +0100 @@ -78,6 +78,15 @@ 100, sfinfo.samplerate / 3, 60); + cerr << "max freq = " << cq.getMaxFrequency() << ", min freq = " + << cq.getMinFrequency() << ", octaves = " << cq.getOctaves() << endl; + + cerr << "octave boundaries: "; + for (int i = 0; i < cq.getOctaves(); ++i) { + cerr << cq.getMaxFrequency() / pow(2, i) << " "; + } + cerr << endl; + int inframe = 0; int outframe = 0; int latency = cq.getLatency() + cqi.getLatency(); @@ -116,6 +125,11 @@ vector cqout = cqi.process(cq.process(cqin)); + for (int i = 0; i < int(cqout.size()); ++i) { + if (cqout[i] > 1.0) cqout[i] = 1.0; + if (cqout[i] < -1.0) cqout[i] = -1.0; + } + if (outframe >= latency) { sf_writef_double(sndfileOut, @@ -154,26 +168,24 @@ outframe += cqout.size(); } - vector r1 = cqi.process(cq.getRemainingOutput()); + vector r = cqi.process(cq.getRemainingOutput()); vector r2 = cqi.getRemainingOutput(); - sf_writef_double(sndfileOut, r1.data(), r1.size()); + r.insert(r.end(), r2.begin(), r2.end()); + + for (int i = 0; i < int(r.size()); ++i) { + if (r[i] > 1.0) r[i] = 1.0; + if (r[i] < -1.0) r[i] = -1.0; + } + + sf_writef_double(sndfileOut, r.data(), r.size()); if (doDiff) { - for (int i = 0; i < (int)r1.size(); ++i) { - r1[i] -= buffer[outframe + i - latency]; + for (int i = 0; i < (int)r.size(); ++i) { + r[i] -= buffer[outframe + i - latency]; } - sf_writef_double(sndDiffFile, r1.data(), r1.size()); + sf_writef_double(sndDiffFile, r.data(), r.size()); } - outframe += r1.size(); - - sf_writef_double(sndfileOut, r2.data(), r2.size()); - if (doDiff) { - for (int i = 0; i < (int)r2.size(); ++i) { - r2[i] -= buffer[outframe + i - latency]; - } - sf_writef_double(sndDiffFile, r2.data(), r2.size()); - } - outframe += r2.size(); + outframe += r.size(); sf_close(sndfile); sf_close(sndfileOut);