From 1049304b5dc524769cef79adc341f429a0262e4e Mon Sep 17 00:00:00 2001
From: oparviai
Date: Sun, 8 Jan 2017 16:27:02 +0000
Subject: [PATCH] Fixed issue that clipped brief sequence of audio from
beginning of the input audio
---
README.html | 35 +++++++++++++++++++++------------
source/SoundTouch/TDStretch.cpp | 35 ++++++++++++++++++++++++++++-----
2 files changed, 52 insertions(+), 18 deletions(-)
diff --git a/README.html b/README.html
index ba02f21..1230739 100644
--- a/README.html
+++ b/README.html
@@ -14,7 +14,7 @@
SoundTouch audio processing library v1.9.3pre
-SoundTouch library Copyright © Olli Parviainen 2001-2015
+SoundTouch library Copyright © Olli Parviainen 2001-2017
1. Introduction
SoundTouch is an open-source audio processing library that allows
@@ -570,6 +570,14 @@ this corresponds to lowering the pitch by -0.318 semitones:
5. Change History
5.1. SoundTouch library Change History
+ 1.9.3:
+
+ - Added functions to get initial processing latency, duration ratio between the original input and processed output tracks, and clarified reporting of input/output batch sizes
+ - Fixed issue that added brief sequence of silence to beginning of output audio
+ - Bugfix: Fixed a glitch that could cause negative array indexing in quick seek algorithm
+ - Bugfix: flush() didn't properly flush final samples from the pipeline on 2nd time in case that soundtouch object instance was recycled and used for processing a second audio stream.
+ - Bugfix: Pi value had incorrect 9th/10th decimals
+
1.9.2:
David Clark
Patrick Colis
Miquel Colon
- Jim Credland
+ Jim Credland
Sandro Cumerlato
Justin Frankel
- Masa H.
+ Masa H.
Jason Garland
Takashi Iwai
- Thomas Klausner
- Tony Mechelynck
- Mathias Möhl
+ Thomas Klausner
+ Tony Mechelynck
+ Mathias Möhl
Yuval Naveh
- Mats Palmgren
+ Mats Palmgren
Paulo Pizarro
- Andrey Ponomarenko
+ Andrey Ponomarenko
Blaise Potard
- Michael Pruett
+ Michael Pruett
Rajeev Puran
- RJ Ryan
- John Sheehy
+ RJ Ryan
+ John Sheehy
Tim Shuttleworth
Albert Sirvent
John Stumpo
diff --git a/source/SoundTouch/TDStretch.cpp b/source/SoundTouch/TDStretch.cpp
index f478cb0..3a4ccbb 100644
--- a/source/SoundTouch/TDStretch.cpp
+++ b/source/SoundTouch/TDStretch.cpp
@@ -310,6 +310,7 @@ int TDStretch::seekBestOverlapPositionFull(const SAMPLETYPE *refPos)
// Scans for the best correlation value by testing each possible position
// over the permitted range.
bestCorr = calcCrossCorr(refPos, pMidBuffer, norm);
+ bestCorr = (bestCorr + 0.1) * 0.75;
#pragma omp parallel for
for (i = 1; i < seekLength; i ++)
@@ -670,26 +671,50 @@ void TDStretch::processSamples()
// (that's in 'midBuffer')
overlap(outputBuffer.ptrEnd((uint)overlapLength), inputBuffer.ptrBegin(), (uint)offset);
outputBuffer.putSamples((uint)overlapLength);
+ offset += overlapLength;
+ }
+ else
+ {
+ // Adjust processing offset at beginning of track:
+ // - do not perform initial overlapping
+ // - compensate expected value of 'seekBestOverlapPosition' offset landing to middle of seekLength
+ isBeginning = false;
+ int skip = overlapLength + seekLength / 2;
+
+ #ifdef SOUNDTOUCH_ALLOW_NONEXACT_SIMD_OPTIMIZATION
+ #ifdef SOUNDTOUCH_ALLOW_SSE
+ // if SSE mode, round the skip amount to value corresponding to aligned memory address
+ if (channels == 1)
+ {
+ skip &= -4;
+ }
+ else if (channels == 2)
+ {
+ skip &= -2;
+ }
+ #endif
+ #endif
+ skipFract -= skip;
+ assert(nominalSkip >= -skipFract);
}
- isBeginning = false;
// ... then copy sequence samples from 'inputBuffer' to output:
// crosscheck that we don't have buffer overflow...
- if ((int)inputBuffer.numSamples() < (offset + seekWindowLength))
+ if ((int)inputBuffer.numSamples() < (offset + seekWindowLength - overlapLength))
{
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, (uint)temp);
// Copies the end of the current sequence from 'inputBuffer' to
// 'midBuffer' for being mixed with the beginning of the next
// processing sequence and so on
- assert((offset + temp + overlapLength * 2) <= (int)inputBuffer.numSamples());
- memcpy(pMidBuffer, inputBuffer.ptrBegin() + channels * (offset + temp + overlapLength),
+ assert((offset + temp + overlapLength) <= (int)inputBuffer.numSamples());
+ memcpy(pMidBuffer, inputBuffer.ptrBegin() + channels * (offset + temp),
channels * sizeof(SAMPLETYPE) * overlapLength);
// Remove the processed samples from the input buffer. Update