diff --git a/test/ltpf.py b/test/ltpf.py index 4bf3e72..f60dc71 100644 --- a/test/ltpf.py +++ b/test/ltpf.py @@ -133,15 +133,6 @@ class Ltpf: (self.pitch_present, self.pitch_index) = (None, None) - def get_data(self): - - return { 'active' : self.active, - 'pitch_index' : self.pitch_index } - - def get_nbits(self): - - return 1 + 10 * int(self.pitch_present) - class LtpfAnalysis(Ltpf): @@ -160,6 +151,15 @@ class LtpfAnalysis(Ltpf): self.pitch = 0 self.nc = np.zeros(2) + def get_data(self): + + return { 'active' : self.active, + 'pitch_index' : self.pitch_index } + + def get_nbits(self): + + return 1 + 10 * int(self.pitch_present) + def correlate(self, x, n, k0, k1): return [ np.dot(x[:n], np.take(x, np.arange(n) - k)) \ diff --git a/test/run.py b/test/run.py index 4b61f7a..293527f 100755 --- a/test/run.py +++ b/test/run.py @@ -37,4 +37,4 @@ for m in [ ( mdct , "MDCT" ), ok = ok and ret -exit(0 if ok else 1); +exit(0 if ok else 1) diff --git a/test/spec.py b/test/spec.py index 4be4054..7bce317 100644 --- a/test/spec.py +++ b/test/spec.py @@ -68,6 +68,9 @@ class SpectrumAnalysis(SpectrumQuantization): self.g_idx = None + (noise_factor, xq, lastnz, nbits_residual_max, xg) = \ + (None, None, None, None, None) + def estimate_gain(self, x, nbits_spec, nbits_off, g_off): nbits = int(nbits_spec + nbits_off + 0.5) @@ -402,6 +405,9 @@ class SpectrumSynthesis(SpectrumQuantization): super().__init__(dt, sr) + (lastnz, lsb_mode, g_idx) = \ + (None, None, None) + def fill_noise(self, bw, x, lastnz, f_nf, nf_seed): (i_nf, nf_start, nf_stop) = self.get_noise_indices(bw, x, lastnz) @@ -537,7 +543,7 @@ class SpectrumSynthesis(SpectrumQuantization): nf_seed = sum(abs(x.astype(np.int)) * range(len(x))) zero_frame = (self.lastnz <= 2 and x[0] == 0 and x[1] == 0 - and self.g_idx <= 0 and nf >= 7) + and self.g_idx <= 0 and f_nf >= 7) if self.lsb_mode == 0: diff --git a/test/tns.py b/test/tns.py index 18426e8..ad7e560 100644 --- a/test/tns.py +++ b/test/tns.py @@ -68,7 +68,7 @@ class Tns: self.dt = dt (self.nfilters, self.lpc_weighting, self.rc_order, self.rc) = \ - (None, None, None, None) + (None, None, [ None, None ], [ None, None ]) def get_data(self): @@ -133,7 +133,7 @@ class TnsAnalysis(Tns): return (r[0] / err, a) - def lpc_weighting(self, pred_gain, a): + def lpc_weight(self, pred_gain, a): gamma = 1 - (1 - 0.85) * (2 - pred_gain) / (2 - 1.5) return a * np.power(gamma, np.arange(len(a))) @@ -199,7 +199,7 @@ class TnsAnalysis(Tns): continue if self.lpc_weighting and pred_gain < 2: - a = self.lpc_weighting(pred_gain, a) + a = self.lpc_weight(pred_gain, a) rc = self.coeffs_reflexion(a)