Fix to issue that started audio track with brief sequence of silence

This commit is contained in:
oparviai 2016-10-20 16:30:11 +00:00
parent 753848865d
commit e302cd7123
2 changed files with 19 additions and 13 deletions

View File

@ -225,6 +225,7 @@ void TDStretch::clearInput()
{ {
inputBuffer.clear(); inputBuffer.clear();
clearMidBuffer(); clearMidBuffer();
isBeginning = true;
} }
@ -639,7 +640,8 @@ void TDStretch::processNominalTempo()
// the result into 'outputBuffer' // the result into 'outputBuffer'
void TDStretch::processSamples() void TDStretch::processSamples()
{ {
int ovlSkip, offset; int ovlSkip;
int offset = 0;
int temp; int temp;
/* Removed this small optimization - can introduce a click to sound when tempo setting /* Removed this small optimization - can introduce a click to sound when tempo setting
@ -656,28 +658,31 @@ void TDStretch::processSamples()
// to form a processing frame. // to form a processing frame.
while ((int)inputBuffer.numSamples() >= sampleReq) while ((int)inputBuffer.numSamples() >= sampleReq)
{ {
// If tempo differs from the normal ('SCALE'), scan for the best overlapping if (isBeginning == false)
// position {
offset = seekBestOverlapPosition(inputBuffer.ptrBegin()); // apart from the very beginning of the track,
// scan for the best overlapping position & do overlap-add
offset = seekBestOverlapPosition(inputBuffer.ptrBegin());
// Mix the samples in the 'inputBuffer' at position of 'offset' with the // Mix the samples in the 'inputBuffer' at position of 'offset' with the
// samples in 'midBuffer' using sliding overlapping // samples in 'midBuffer' using sliding overlapping
// ... first partially overlap with the end of the previous sequence // ... first partially overlap with the end of the previous sequence
// (that's in 'midBuffer') // (that's in 'midBuffer')
overlap(outputBuffer.ptrEnd((uint)overlapLength), inputBuffer.ptrBegin(), (uint)offset); overlap(outputBuffer.ptrEnd((uint)overlapLength), inputBuffer.ptrBegin(), (uint)offset);
outputBuffer.putSamples((uint)overlapLength); outputBuffer.putSamples((uint)overlapLength);
}
isBeginning = false;
// ... then copy sequence samples from 'inputBuffer' to output: // ... then copy sequence samples from 'inputBuffer' to output:
// length of sequence
temp = (seekWindowLength - 2 * overlapLength);
// crosscheck that we don't have buffer overflow... // crosscheck that we don't have buffer overflow...
if ((int)inputBuffer.numSamples() < (offset + seekWindowLength)) if ((int)inputBuffer.numSamples() < (offset + seekWindowLength))
{ {
continue; // just in case, shouldn't really happen continue; // just in case, shouldn't really happen
} }
// length of sequence
temp = (seekWindowLength - 2 * overlapLength);
outputBuffer.putSamples(inputBuffer.ptrBegin() + channels * (offset + overlapLength), (uint)temp); outputBuffer.putSamples(inputBuffer.ptrBegin() + channels * (offset + overlapLength), (uint)temp);
// Copies the end of the current sequence from 'inputBuffer' to // Copies the end of the current sequence from 'inputBuffer' to

View File

@ -134,6 +134,7 @@ protected:
bool bQuickSeek; bool bQuickSeek;
bool bAutoSeqSetting; bool bAutoSeqSetting;
bool bAutoSeekSetting; bool bAutoSeekSetting;
bool isBeginning;
SAMPLETYPE *pMidBuffer; SAMPLETYPE *pMidBuffer;
SAMPLETYPE *pMidBufferUnaligned; SAMPLETYPE *pMidBufferUnaligned;