mirror of
https://github.com/google/liblc3.git
synced 2026-04-17 21:25:30 +00:00
test: Various fixes on python simulation code
This commit is contained in:
18
test/ltpf.py
18
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)) \
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user