Bug 1427267 - Improve libsoundtouch high playback rate speech clarity with pitch preservation by using a smaller time stretcher sequence size r=padenot
authorKestrel <ke5trel@protonmail.com>
Mon, 16 Dec 2019 13:03:10 +0000
changeset 507086 f21621632fac449db8d93dbecc8a063f84550eef
parent 507085 165cef8cb8ebfd33630ada38b84eeda079facc37
child 507087 52e6fc030c2f9a9bf54d44dbade100644e5f3f41
push id36922
push userncsoregi@mozilla.com
push dateMon, 16 Dec 2019 17:21:47 +0000
treeherdermozilla-central@27d0d6cc2131 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1427267
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1427267 - Improve libsoundtouch high playback rate speech clarity with pitch preservation by using a smaller time stretcher sequence size r=padenot Differential Revision: https://phabricator.services.mozilla.com/D57085
dom/media/AudioStream.cpp
--- a/dom/media/AudioStream.cpp
+++ b/dom/media/AudioStream.cpp
@@ -170,16 +170,27 @@ size_t AudioStream::SizeOfIncludingThis(
 
 nsresult AudioStream::EnsureTimeStretcherInitializedUnlocked() {
   mMonitor.AssertCurrentThreadOwns();
   if (!mTimeStretcher) {
     mTimeStretcher = soundtouch::createSoundTouchObj();
     mTimeStretcher->setSampleRate(mAudioClock.GetInputRate());
     mTimeStretcher->setChannels(mOutChannels);
     mTimeStretcher->setPitch(1.0);
+
+    // SoundTouch v2.1.2 uses automatic time-stretch settings with the following
+    // values:
+    // Tempo 0.5: 90ms sequence, 20ms seekwindow, 8ms overlap
+    // Tempo 2.0: 40ms sequence, 15ms seekwindow, 8ms overlap
+    // We are going to use a smaller 10ms sequence size to improve speech
+    // clarity, giving more resolution at high tempo and less reverb at low
+    // tempo. Maintain 15ms seekwindow and 8ms overlap for smoothness.
+    mTimeStretcher->setSetting(SETTING_SEQUENCE_MS, 10);
+    mTimeStretcher->setSetting(SETTING_SEEKWINDOW_MS, 15);
+    mTimeStretcher->setSetting(SETTING_OVERLAP_MS, 8);
   }
   return NS_OK;
 }
 
 nsresult AudioStream::SetPlaybackRate(double aPlaybackRate) {
   TRACE();
   // MUST lock since the rate transposer is used from the cubeb callback,
   // and rate changes can cause the buffer to be reallocated