From: drowe67 Date: Wed, 11 Aug 2010 07:45:28 +0000 (+0000) Subject: we were only recovering L/2 Am from LPC, check again X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=09f7ea9b20e64f66ae6f413a92b7c4254a50b2cc;p=freetel-svn-tracking.git we were only recovering L/2 Am from LPC, check again git-svn-id: https://svn.code.sf.net/p/freetel/code@166 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2/src/dump.c b/codec2/src/dump.c index 0f66ae27..4be59940 100644 --- a/codec2/src/dump.c +++ b/codec2/src/dump.c @@ -48,6 +48,7 @@ static FILE *fdec = NULL; static FILE *fsnr = NULL; static FILE *fak = NULL; static FILE *fbg = NULL; +static FILE *fE = NULL; static char prefix[MAX_STR]; @@ -89,6 +90,8 @@ void dump_off(){ fclose(fak); if (fbg != NULL) fclose(fbg); + if (fE != NULL) + fclose(fE); } void dump_Sn(float Sn[]) { @@ -385,6 +388,16 @@ void dump_bg(float e, float bg_est, float percent_uv) { fprintf(fbg,"%f\t%f\t%f\n", e, bg_est, percent_uv); } +void dump_E(float E) { + char s[MAX_STR]; + if (!dumpon) return; + if (fE == NULL) { + sprintf(s,"%s_E.txt", prefix); + fE = fopen(s, "wt"); + assert(fE != NULL); + } + fprintf(fE,"%f\n", 10.0*log10(E)); +} diff --git a/codec2/src/dump.h b/codec2/src/dump.h index 74c20dac..7e815cce 100644 --- a/codec2/src/dump.h +++ b/codec2/src/dump.h @@ -43,6 +43,7 @@ void dump_quantised_model(MODEL *m); void dump_Pw(COMP Pw[]); void dump_lsp(float lsp[]); void dump_ak(float ak[], int order); +void dump_E(float E); /* phase modelling */ diff --git a/codec2/src/fq20.sh b/codec2/src/fq20.sh new file mode 100755 index 00000000..b83784b4 --- /dev/null +++ b/codec2/src/fq20.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# fq20.shsh +# David Rowe 27 July 2010 +# +# Decode a file with fully quantised codec at 20ms frame rate + +../src/sinedec ../raw/$1.raw $1.mdl -o $1_phase0_lsp_20_EWo2.raw --phase 0 --lpc 10 --lsp --postfilter --dec + diff --git a/codec2/src/listen.sh b/codec2/src/listen.sh index 816fd806..5cd226ca 100755 --- a/codec2/src/listen.sh +++ b/codec2/src/listen.sh @@ -9,5 +9,5 @@ # compare to other codecs -../script/menu.sh ../raw/$1.raw $1_phase0_lsp.raw ../raw/$1_g729a.raw ../raw/$1_gsm13k.raw ../raw/$1_speex_8k.raw $2 $3 +../script/menu.sh ../raw/$1.raw $1_phase0_lsp.raw $1_phase0_lsp_20.raw $1_phase0_lsp_20_EWo.raw ../raw/$1_g729a.raw ../raw/$1_gsm13k.raw ../raw/$1_speex_8k.raw $2 $3 diff --git a/codec2/src/listen1.sh b/codec2/src/listen1.sh index e3af29ae..a3b72671 100755 --- a/codec2/src/listen1.sh +++ b/codec2/src/listen1.sh @@ -4,6 +4,12 @@ # # Run menu with common sample file options, headphone version -../script/menu.sh ../raw/$1.raw $1_uq.raw $1_phase0.raw $1_lpc10.raw $1_lsp.raw $1_phase0_lpc10.raw $1_phase0_lsp.raw ../raw/$1_g729a.raw $2 $3 -d /dev/dsp1 +#../script/menu.sh ../raw/$1.raw $1_uq.raw $1_phase0.raw $1_lpc10.raw $1_lsp.raw $1_phase0_lpc10.raw $1_phase0_lsp.raw ../raw/$1_g729a.raw $2 $3 -d /dev/dsp1 + +# compare to other codecs + +#../script/menu.sh ../raw/$1.raw $1_phase0_lsp.raw $1_phase0_lsp_20.raw ../raw/$1_g729a.raw ../raw/$1_gsm13k.raw ../raw/$1_speex_8k.raw $2 $3 -d /dev/dsp1 + +../script/menu.sh ../raw/$1.raw $1_uq.raw $1_phase0.raw $1_test.raw ../raw/$1_g729a.raw $2 $3 -d /dev/dsp1 diff --git a/codec2/src/quantise.c b/codec2/src/quantise.c index 1f1ea094..7a739069 100644 --- a/codec2/src/quantise.c +++ b/codec2/src/quantise.c @@ -427,13 +427,23 @@ float lpc_model_amplitudes( #endif /* used during development: copy remaining LSPs from orig if we haven't quantised all of them */ - for(j=l; j {Am} LPC decode */ #ifdef CLICKY diff --git a/codec2/src/sinedec.c b/codec2/src/sinedec.c index b9d682ee..18433726 100644 --- a/codec2/src/sinedec.c +++ b/codec2/src/sinedec.c @@ -88,7 +88,7 @@ int main(int argc, char *argv[]) int dump; int phase, phase_model; - float ex_phase[1]; + float ex_phase[MAX_AMP+1]; int voiced, voiced_1, voiced_2; int postfilt; @@ -107,6 +107,9 @@ int main(int argc, char *argv[]) model_1.A[i] = 0.0; model_1.phi[i] = 0.0; } + for(i=1; i<=MAX_AMP; i++) { + ex_phase[i] = 0.0; + } model_synth = model_3 = model_2 = model_1; if (argc < 3) { @@ -274,8 +277,8 @@ int main(int argc, char *argv[]) //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); @@ -283,7 +286,6 @@ int main(int argc, char *argv[]) dump_quantised_model(&model); } - /* option decimation to 20ms rate, which enables interpolation routine to synthesise in between frame */ @@ -294,7 +296,6 @@ int main(int argc, char *argv[]) model_synth = model_2; transition = 0; - } else { interp(&model_3, &model_1, &model_synth, &model_a, &model_b, @@ -313,6 +314,14 @@ int main(int argc, char *argv[]) model = model_synth; } + /* + Simulate Wo quantisation noise + model.Wo += 2.0*(PI/8000)*(1.0 - 2.0*(float)rand()/RAND_MAX); + if (model.Wo > TWO_PI/20.0) model.Wo = TWO_PI/20.0; + if (model.Wo < TWO_PI/160.0) model.Wo = TWO_PI/160.0; + model.L = floor(PI/model.Wo); + */ + /* Synthesise speech */ if (fout != NULL) {