Further investigation
This commit is contained in:
@@ -211,36 +211,40 @@ static void check_sinusoid_shifted(int n, int rate, float freq, float shift,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int reportedDelay = shifter.getStartDelay();
|
int reportedDelay = shifter.getStartDelay();
|
||||||
|
int slackpart = 2048;
|
||||||
|
|
||||||
|
for (int section = 0; section < 2; ++section) {
|
||||||
|
|
||||||
double lastCrossing = -1;
|
double lastCrossing = -1;
|
||||||
int nCrossings = 0;
|
double freqeps = (section == 1 ? 0.15 : 5.0) * fabs(shift);
|
||||||
double accWavelength = 0;
|
|
||||||
double minWavelength = 0;
|
|
||||||
double maxWavelength = 0;
|
|
||||||
sumSquares = 0;
|
sumSquares = 0;
|
||||||
double peakOut = 0;
|
|
||||||
for (int i = reportedDelay; i < endpoint; ++i) {
|
int i0 = reportedDelay;
|
||||||
|
int i1 = reportedDelay + slackpart;
|
||||||
|
if (section == 1) {
|
||||||
|
i0 = i1;
|
||||||
|
i1 = endpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = i0; i < i1; ++i) {
|
||||||
sumSquares += out[i] * out[i];
|
sumSquares += out[i] * out[i];
|
||||||
if (fabs(out[i]) > peakOut) peakOut = fabs(out[i]);
|
|
||||||
if (out[i-1] < 0.f && out[i] >= 0.f) {
|
if (out[i-1] < 0.f && out[i] >= 0.f) {
|
||||||
double crossing = (i-1) + (out[i-1] / (out[i-1] - out[i]));
|
double crossing = (i-1) + (out[i-1] / (out[i-1] - out[i]));
|
||||||
if (lastCrossing >= 0) {
|
if (lastCrossing >= 0) {
|
||||||
double wavelength = crossing - lastCrossing;
|
double f = rate / (crossing - lastCrossing);
|
||||||
accWavelength += wavelength;
|
double diff = freq * shift - f;
|
||||||
if (minWavelength == 0 || wavelength < minWavelength) {
|
if (fabs(diff) > freqeps) {
|
||||||
minWavelength = wavelength;
|
cerr << "i = " << i << " (from " << i0 << " to " << i1 << "), f = " << f << ", freq = " << freq * shift << ", diff = " << diff << ", freqeps = " << freqeps << ", shift = " << shift << ", factor = " << fabs(diff)/freqeps << endl;
|
||||||
}
|
}
|
||||||
if (maxWavelength == 0 || wavelength > maxWavelength) {
|
|
||||||
maxWavelength = wavelength;
|
|
||||||
}
|
|
||||||
cerr << "wavelength = " << wavelength << " (freq " << rate / wavelength << ")" << endl;
|
|
||||||
nCrossings ++;
|
|
||||||
}
|
}
|
||||||
lastCrossing = crossing;
|
lastCrossing = crossing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cerr << endl;
|
|
||||||
|
|
||||||
|
// check rms
|
||||||
|
}
|
||||||
|
/*
|
||||||
double avgWavelength = 1;
|
double avgWavelength = 1;
|
||||||
if (nCrossings > 0) {
|
if (nCrossings > 0) {
|
||||||
avgWavelength = accWavelength / nCrossings;
|
avgWavelength = accWavelength / nCrossings;
|
||||||
@@ -287,10 +291,10 @@ static void check_sinusoid_shifted(int n, int rate, float freq, float shift,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
if (printDebug) {
|
if (printDebug) {
|
||||||
RubberBandLiveShifter::setDefaultDebugLevel(0);
|
RubberBandLiveShifter::setDefaultDebugLevel(0);
|
||||||
dump(debugPrefix, in, out, expected, delay);
|
dump(debugPrefix, in, out, expected, reportedDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user