Move input time after seeking
This commit is contained in:
parent
37f855cc7f
commit
94553a3789
11
cmd/main.cpp
11
cmd/main.cpp
@ -121,9 +121,14 @@ int main(int argc, char* argv[]) {
|
|||||||
diff2 /= prevWav.samples.size();
|
diff2 /= prevWav.samples.size();
|
||||||
double diffDb = 10*std::log10(diff2);
|
double diffDb = 10*std::log10(diff2);
|
||||||
std::cout << "Reference:\n\tdifference: ";
|
std::cout << "Reference:\n\tdifference: ";
|
||||||
if (diff2 < 1e-6) std::cout << Console::Red;
|
if (diff2 < 1e-6) {
|
||||||
if (diff2 < 1e-8) std::cout << Console::Yellow;
|
std::cout << Console::Yellow;
|
||||||
if (diff2 < 1e-10) std::cout << Console::Green;
|
} else if (diff2 < 1e-10) {
|
||||||
|
std::cout << Console::Green;
|
||||||
|
} else {
|
||||||
|
std::cout << Console::Red;
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << Console::Bright << diffDb << Console::Reset << " dB\n";
|
std::cout << Console::Bright << diffDb << Console::Reset << " dB\n";
|
||||||
if (diffDb > -60) args.errorExit("too much difference\n");
|
if (diffDb > -60) args.errorExit("too much difference\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,18 +93,21 @@ struct SignalsmithStretch {
|
|||||||
tmpBuffer.resize(0);
|
tmpBuffer.resize(0);
|
||||||
tmpBuffer.resize(stft.blockSamples() + stft.defaultInterval());
|
tmpBuffer.resize(stft.blockSamples() + stft.defaultInterval());
|
||||||
|
|
||||||
|
int startIndex = std::max<int>(0, inputSamples - int(tmpBuffer.size())); // start position in input
|
||||||
|
int padStart = tmpBuffer.size() - (inputSamples - startIndex); // start position in tmpBuffer
|
||||||
|
|
||||||
Sample totalEnergy = 0;
|
Sample totalEnergy = 0;
|
||||||
for (int c = 0; c < channels; ++c) {
|
for (int c = 0; c < channels; ++c) {
|
||||||
auto &&inputChannel = inputs[c];
|
auto &&inputChannel = inputs[c];
|
||||||
int startIndex = std::max<int>(0, inputSamples - int(tmpBuffer.size()));
|
|
||||||
for (int i = startIndex; i < inputSamples; ++i) {
|
for (int i = startIndex; i < inputSamples; ++i) {
|
||||||
Sample s = inputChannel[i];
|
Sample s = inputChannel[i];
|
||||||
totalEnergy += s*s;
|
totalEnergy += s*s;
|
||||||
tmpBuffer[i - startIndex] = s;
|
tmpBuffer[i - startIndex + padStart] = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
stft.writeInput(c, 0, tmpBuffer.size(), tmpBuffer.data());
|
stft.writeInput(c, tmpBuffer.size(), tmpBuffer.data());
|
||||||
}
|
}
|
||||||
|
stft.moveInput(tmpBuffer.size());
|
||||||
if (totalEnergy >= noiseFloor) {
|
if (totalEnergy >= noiseFloor) {
|
||||||
silenceCounter = 0;
|
silenceCounter = 0;
|
||||||
silenceFirst = true;
|
silenceFirst = true;
|
||||||
@ -127,7 +130,7 @@ struct SignalsmithStretch {
|
|||||||
}
|
}
|
||||||
stft.writeInput(c, length, tmpBuffer.data());
|
stft.writeInput(c, length, tmpBuffer.data());
|
||||||
}
|
}
|
||||||
stft.moveInput(toIndex - prevCopiedInput);
|
stft.moveInput(length);
|
||||||
prevCopiedInput = toIndex;
|
prevCopiedInput = toIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user