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();
|
||||
double diffDb = 10*std::log10(diff2);
|
||||
std::cout << "Reference:\n\tdifference: ";
|
||||
if (diff2 < 1e-6) std::cout << Console::Red;
|
||||
if (diff2 < 1e-8) std::cout << Console::Yellow;
|
||||
if (diff2 < 1e-10) std::cout << Console::Green;
|
||||
if (diff2 < 1e-6) {
|
||||
std::cout << Console::Yellow;
|
||||
} else if (diff2 < 1e-10) {
|
||||
std::cout << Console::Green;
|
||||
} else {
|
||||
std::cout << Console::Red;
|
||||
}
|
||||
|
||||
std::cout << Console::Bright << diffDb << Console::Reset << " dB\n";
|
||||
if (diffDb > -60) args.errorExit("too much difference\n");
|
||||
}
|
||||
|
||||
@ -93,18 +93,21 @@ struct SignalsmithStretch {
|
||||
tmpBuffer.resize(0);
|
||||
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;
|
||||
for (int c = 0; c < channels; ++c) {
|
||||
auto &&inputChannel = inputs[c];
|
||||
int startIndex = std::max<int>(0, inputSamples - int(tmpBuffer.size()));
|
||||
for (int i = startIndex; i < inputSamples; ++i) {
|
||||
Sample s = inputChannel[i];
|
||||
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) {
|
||||
silenceCounter = 0;
|
||||
silenceFirst = true;
|
||||
@ -127,7 +130,7 @@ struct SignalsmithStretch {
|
||||
}
|
||||
stft.writeInput(c, length, tmpBuffer.data());
|
||||
}
|
||||
stft.moveInput(toIndex - prevCopiedInput);
|
||||
stft.moveInput(length);
|
||||
prevCopiedInput = toIndex;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user