TODO for codec2
---------------
+Mysteries
+---------
+
+[ ] buzzy sound in bg noise ofr b0067
+[ ] LSP quantiser has problems for b0067
+[ ] synthetic sound for hts2a and to bg nouse on _uq models
+ + breakdown in sinusoidal model for noise
+ + MELP does better
+ + perhaps synth UV using white noise might work better
+
29 July 2010, current status:
- g729a is a bit better, but c2 is not put to shame
- c2 betters GSM in some cases
-
\ No newline at end of file
+
model_name = strcat(samname,"_model.txt");
model = load(model_name);
+ sw__name = strcat(samname,"_sw_.txt");
+ if (file_in_path(".",sw__name))
+ Sw_ = load(sw__name);
+ endif
+
pw_name = strcat(samname,"_pw.txt");
if (file_in_path(".",pw_name))
Pw = load(pw_name);
k = ' ';
do
figure(1);
- clg;
+ clf;
s = [ Sn(2*f-1,:) Sn(2*f,:) ];
plot(s);
grid;
Wo = model(f,1);
L = model(f,2);
Am = model(f,3:(L+2));
- plot((1:L)*Wo*4000/pi, 20*log10(Am),";Am;");
+ plot((1:L)*Wo*4000/pi, 20*log10(Am),"r;Am;");
axis([1 4000 -10 80]);
hold on;
plot((0:255)*4000/256, Sw(f,:),";Sw;");
grid;
+ if (file_in_path(".",sw__name))
+ plot((0:255)*4000/256, Sw_(f,:),"g;Sw_;");
+ endif
+
if (file_in_path(".",pw_name))
plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;");
endif
noise = (orig-synth) * (orig-synth)';
snr_phase = 10*log10(signal/noise);
- phase_err_label = sprintf(";phase_err SNR %4.2f dB;",snr_phase);
+ phase_err_label = sprintf("g;phase_err SNR %4.2f dB;",snr_phase);
plot((1:L)*Wo*4000/pi, 20*log10(orig-synth), phase_err_label);
endif
axis;
if (file_in_path(".", phase_name_))
hold on;
- plot((1:L)*Wo*4000/pi, phase_(f,1:L)*180/pi, ";phase_;");
+ plot((1:L)*Wo*4000/pi, phase_(f,1:L)*180/pi, "g;phase_;");
grid
hold off;
endif
SINENC_OBJ = sinenc.o globals.o initenc.o four1.o refine.o spec.o dump.o
SINEDEC_OBJ = sinedec.o globals.o initenc.o initdec.o four1.o synth.o \
quantise.o lpc.o dump.o refine.o lsp.o phase.o postfilter.o \
- interp.o
+ interp.o nlp.o
all: sinenc sinedec
-1.0818124e-03
};
-float test_candidate_mbe(COMP Sw[], float f0);
float post_process_mbe(COMP Fw[], int pmin, int pmax, float gmax);
float post_process_sub_multiples(COMP Fw[],
int pmin, int pmax, float gmax, int gmax_bin,
int bin;
float f0_min, f0_max;
float f0_start, f0_end;
+ COMP Sw_[FFT_ENC];
f0_min = (float)SAMPLE_RATE/pmax;
f0_max = (float)SAMPLE_RATE/pmin;
if (f0_end > f0_max) f0_end = f0_max;
for(f0=f0_start; f0<=f0_end; f0+= 2.5) {
- e = test_candidate_mbe(Sw, f0);
+ e = test_candidate_mbe(Sw, f0, Sw_);
bin = floor(f0); assert((bin > 0) && (bin < F0_MAX));
e_hz[bin] = e;
if (e < e_min) {
float test_candidate_mbe(
COMP Sw[],
- float f0
+ float f0,
+ COMP Sw_[] /* DFT of all voiced synthesised signal for f0 */
+ /* useful for debugging/dump file */
)
{
- COMP Sw_[FFT_ENC]; /* DFT of all voiced synthesised signal */
- int l,al,bl,m; /* loop variables */
+ int i,l,al,bl,m; /* loop variables */
COMP Am; /* amplitude sample for this band */
int offset; /* centers Hw[] about current harmonic */
float den; /* denominator of Am expression */
float Wo; /* current "test" fundamental freq. */
int L;
+ for(i=0; i<FFT_ENC; i++) {
+ Sw_[i].real = 0.0;
+ Sw_[i].imag = 0.0;
+ }
+
L = floor((SAMPLE_RATE/2.0)/f0);
Wo = f0*(2*PI/SAMPLE_RATE);
/* Just test across the harmonics in the first 1000 Hz (L/4) */
- for(l=1; l<L/4; l++) {
+ for(l=1; l<=L/4; l++) {
Am.real = 0.0;
Am.imag = 0.0;
den = 0.0;
#define NLP_NTAP 48 /* Decimation LPF order */
float nlp(float Sn[], int n, int m, int pmin, int pmax, float *pitch, COMP Sw[], float *prev_Wo);
+float test_candidate_mbe(COMP Sw[], float f0, COMP Sw_[]);
#endif
#include "synth.h"
#include "postfilter.h"
#include "interp.h"
+#include "nlp.h"
/*---------------------------------------------------------------------------*\
assert(order == PHASE_LPC_ORD);
dump_ak(ak_phase, PHASE_LPC_ORD);
- snr = phase_model_first_order(ak_phase, H, &n_min, &min_Am, &voiced);
+
+ {
+ COMP Sw_[FFT_ENC];
+ float sig = 0.0;
+ float noise;
+ int m;
+ float candidate_f0;
+ float f0,best_f0;
+ float e,e_min;
+ int i;
+ float f0_min, f0_max;
+ float f0_start, f0_end;
+
+ for(m=1; m<=model.L/4; m++) {
+ sig += model.A[m]*model.A[m];
+ }
+ f0_min = (float)8000.0/P_MAX;
+ f0_max = (float)8000.0/P_MIN;
+ candidate_f0 = (4000.0/PI)*model.Wo;
+ f0_start = candidate_f0-5;
+ f0_end = candidate_f0+5;
+ if (f0_start < f0_min) f0_start = f0_min;
+ if (f0_end > f0_max) f0_end = f0_max;
+ e_min = 1E32;
+
+ for(f0=f0_start; f0<=f0_end; f0+= 1) {
+ e = test_candidate_mbe(Sw, f0, Sw_);
+ if (e < e_min) {
+ e_min = e;
+ best_f0 = f0;
+ }
+ }
+ noise = test_candidate_mbe(Sw,best_f0, Sw_);
+ snr = sig/noise;
+ dump_Sw_(Sw_);
+ }
+
+ phase_model_first_order(ak_phase, H, &n_min, &min_Am, &voiced);
+ if (snr > 4.0)
+ voiced = 1;
+ else
+ voiced = 0;
+
dump_snr(snr);
if (phase_model == 0) {
//dump_phase_(&model.phi[0]);
}
- /* optional LPC model amplitudes */
+ /* optional LPC model amplitudes */
if (lpc_model) {
snr = lpc_model_amplitudes(Sn, &model, order, lsp, ak);
synthesise_continuous_phase(Pn, &model, Sn_, 1, &Wo_prev, phi_prev);
#else
phase_synth_zero_order(5.0, H, &Wo_prev, &ex_phase);
- synthesise_mixed(Pn,&model,Sn_);
+ synthesise_mixed(Pn,&model,Sn_,1);
#endif
for(i=0; i<N; i++)