From f799a68c9ce3f85f2c766aac6502466123c34ed3 Mon Sep 17 00:00:00 2001 From: TeaPoly Date: Tue, 15 Feb 2022 17:19:17 +0800 Subject: [PATCH 1/2] Using modified pitch correlation from LPCNet --- src/pitch.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pitch.cpp b/src/pitch.cpp index 11a1a14..27024d6 100755 --- a/src/pitch.cpp +++ b/src/pitch.cpp @@ -382,7 +382,18 @@ void pitch_search(const opus_val16 *x_lp, opus_val16 *y, offset = 0; } *pitch = 2*best_pitch[0]-offset; - *pitch_corr = xcorr[best_pitch[0]]; + /* *pitch_corr = xcorr[best_pitch[0]]; */ + /* + An estimate of the pitch correlation modified pitch correlation inspired by + section 3.1 Features and Quantization: Pitch in the paper + >2)+ + celt_inner_prod(&y_lp4[best_pitch[0]], &y_lp4[best_pitch[0]], len>>2) + ); } #ifdef FIXED_POINT From d9781ea012e59ef0a96ff5f93deb6ae8d1e0f673 Mon Sep 17 00:00:00 2001 From: TeaPoly Date: Tue, 15 Feb 2022 17:35:26 +0800 Subject: [PATCH 2/2] Fix pitch correlation denominator --- src/pitch.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pitch.cpp b/src/pitch.cpp index 27024d6..6f9d646 100755 --- a/src/pitch.cpp +++ b/src/pitch.cpp @@ -365,6 +365,17 @@ void pitch_search(const opus_val16 *x_lp, opus_val16 *y, #endif ); + /* + A modified pitch correlation inspired by section 3.1 Features and Quantization: Pitch + in the paper . + + Link: https://jmvalin.ca/papers/lpcnet_codec.pdf + */ + *pitch_corr = 2*xcorr[best_pitch[0]] / ( + 1+celt_inner_prod(x_lp, x_lp, len>>1)+ + celt_inner_prod(&y[best_pitch[0]], &y[best_pitch[0]], len>>1) + ); + /* Refine by pseudo-interpolation */ if (best_pitch[0]>0 && best_pitch[0]<(max_pitch>>1)-1) { @@ -383,17 +394,6 @@ void pitch_search(const opus_val16 *x_lp, opus_val16 *y, } *pitch = 2*best_pitch[0]-offset; /* *pitch_corr = xcorr[best_pitch[0]]; */ - /* - An estimate of the pitch correlation modified pitch correlation inspired by - section 3.1 Features and Quantization: Pitch in the paper - >2)+ - celt_inner_prod(&y_lp4[best_pitch[0]], &y_lp4[best_pitch[0]], len>>2) - ); } #ifdef FIXED_POINT