From 1e1676751c49fd531f89dec213e100a7ba128c96 Mon Sep 17 00:00:00 2001 From: davidweenink Date: Sat, 23 Nov 2024 15:19:58 +0100 Subject: [PATCH] repaired a bug that made the autocorrelation method have one coefficient missing --- LPC/SoundToLPCWorkspace.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/LPC/SoundToLPCWorkspace.cpp b/LPC/SoundToLPCWorkspace.cpp index d180e1072..fd7bad714 100644 --- a/LPC/SoundToLPCWorkspace.cpp +++ b/LPC/SoundToLPCWorkspace.cpp @@ -114,8 +114,8 @@ bool structSoundToLPCAutocorrelationWorkspace :: inputFrameToOutputFrame (void) a [1] = 1.0; a [2] = rc [1] = - r [2] / r [1]; thy gain = r [1] + r [2] * rc [1]; - integer iend = 1; - for (integer i = 2; i <= m; i ++) { + integer i = 1; + for (i = 2; i <= m; i ++) { long double s = 0.0; for (integer j = 1; j <= i; j ++) s += r [i - j + 2] * a [j]; @@ -131,11 +131,10 @@ bool structSoundToLPCAutocorrelationWorkspace :: inputFrameToOutputFrame (void) frameAnalysisInfo = 2; break; } - iend ++; } - -- iend; - thy a.part (1, iend) <<= a.part (2, iend + 1); - thy a.resize (iend); + -- i; + thy a.part (1, i) <<= a.part (2, i + 1); + thy a.resize (i); thy nCoefficients = thy a.size; // maintain invariant return true; }