From b5b1f69d223f716581282c43f2fabbd5a47daf43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hock?= Date: Mon, 11 Dec 2023 18:34:54 +0100 Subject: [PATCH] Reset vocoder phase buffer on pitch shifting factor change #45 --- cpp/StftPitchShift/StftPitchShiftCore.h | 1 + cpp/StftPitchShift/Vocoder.h | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/cpp/StftPitchShift/StftPitchShiftCore.h b/cpp/StftPitchShift/StftPitchShiftCore.h index 2105775..144ac5f 100755 --- a/cpp/StftPitchShift/StftPitchShiftCore.h +++ b/cpp/StftPitchShift/StftPitchShiftCore.h @@ -78,6 +78,7 @@ namespace stftpitchshift void factors(const std::vector& factors) { pitcher.factors(factors); + vocoder.reset(); // #45 } double quefrency() const diff --git a/cpp/StftPitchShift/Vocoder.h b/cpp/StftPitchShift/Vocoder.h index 438bff9..b0e2871 100755 --- a/cpp/StftPitchShift/Vocoder.h +++ b/cpp/StftPitchShift/Vocoder.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -45,6 +46,12 @@ namespace stftpitchshift } } + void reset() + { + // zero decode phase buffer according to #45 + std::fill(decode_phase_buffer.begin(), decode_phase_buffer.end(), 0); + } + void encode(const std::span> dft) { assert(dft.size() == encode_phase_buffer.size());