From: drowe67 Date: Mon, 13 Feb 2012 01:12:22 +0000 (+0000) Subject: experimental VQ from Jean-Marc in c2sim, c2sim and c2enc, c2dec match for 1400 mode... X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=178554476f05e6eaf92af4dd79974d6d2ffc03d5;p=freetel-svn-tracking.git experimental VQ from Jean-Marc in c2sim, c2sim and c2enc, c2dec match for 1400 mode but using 36 bit scalar LSP at 1500 bits/s git-svn-id: https://svn.code.sf.net/p/freetel/code@313 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/src/Makefile.am b/codec2-dev/src/Makefile.am index 8bc7e448..7974b910 100644 --- a/codec2-dev/src/Makefile.am +++ b/codec2-dev/src/Makefile.am @@ -46,8 +46,13 @@ CODEBOOKSJND= \ CODEBOOKSDT= \ $D/lspdt1-4.txt \ - $D/lspdt5-10.txt + $D/lspdt5-10.txt \ + $D/lspdt1-10.txt +CODEBOOKSJVM= \ + $D/lspjvm1.txt \ + $D/lspjvm2.txt \ + $D/lspjvm3.txt noinst_PROGRAMS = generate_codebook genlspdtcb @@ -55,6 +60,7 @@ codebook.$(OBJEXT): codebook.c codebookd.$(OBJEXT): codebookd.c codebookvq.$(OBJEXT): codebookvq.c codebookjnd.$(OBJEXT): codebookjnd.c +codebookjvm.$(OBJEXT): codebookjvm.c $(CODEBOOKSDT): genlspdtcb ./genlspdtcb @@ -76,8 +82,11 @@ codebookjnd.c: generate_codebook $(CODEBOOKSJND) codebookdt.c: generate_codebook $(CODEBOOKSDT) ./generate_codebook lsp_cbdt $(CODEBOOKSDT) > codebookdt.c +codebookjvm.c: generate_codebook $(CODEBOOKSJVM) + ./generate_codebook lsp_cbjvm $(CODEBOOKSJVM) > codebookjvm.c + clean-local: - -rm -f codebook.c codebookd.c codebookdvq.c codebookjnd.c codebookdt.c + -rm -f codebook.c codebookd.c codebookdvq.c codebookjnd.c codebookdt.c codebookjvm.c lib_LTLIBRARIES = libcodec2.la libcodec2_la_SOURCES = dump.c \ @@ -97,6 +106,7 @@ codebook.c \ codebookd.c \ codebookvq.c \ codebookjnd.c \ +codebookjvm.c \ codebookdt.c libcodec2_la_CFLAGS = $(AM_CFLAGS) diff --git a/codec2-dev/src/Makefile.in b/codec2-dev/src/Makefile.in index c07ba517..8cfd3c90 100644 --- a/codec2-dev/src/Makefile.in +++ b/codec2-dev/src/Makefile.in @@ -69,7 +69,8 @@ am_libcodec2_la_OBJECTS = libcodec2_la-dump.lo libcodec2_la-lpc.lo \ libcodec2_la-phase.lo libcodec2_la-quantise.lo \ libcodec2_la-pack.lo libcodec2_la-codebook.lo \ libcodec2_la-codebookd.lo libcodec2_la-codebookvq.lo \ - libcodec2_la-codebookjnd.lo libcodec2_la-codebookdt.lo + libcodec2_la-codebookjnd.lo libcodec2_la-codebookjvm.lo \ + libcodec2_la-codebookdt.lo libcodec2_la_OBJECTS = $(am_libcodec2_la_OBJECTS) binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) @@ -264,7 +265,13 @@ CODEBOOKSJND = \ CODEBOOKSDT = \ $D/lspdt1-4.txt \ - $D/lspdt5-10.txt + $D/lspdt5-10.txt \ + $D/lspdt1-10.txt + +CODEBOOKSJVM = \ + $D/lspjvm1.txt \ + $D/lspjvm2.txt \ + $D/lspjvm3.txt lib_LTLIBRARIES = libcodec2.la libcodec2_la_SOURCES = dump.c \ @@ -284,6 +291,7 @@ codebook.c \ codebookd.c \ codebookvq.c \ codebookjnd.c \ +codebookjvm.c \ codebookdt.c libcodec2_la_CFLAGS = $(AM_CFLAGS) @@ -449,6 +457,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcodec2_la-codebookd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcodec2_la-codebookdt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcodec2_la-codebookjnd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcodec2_la-codebookjvm.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcodec2_la-codebookvq.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcodec2_la-codec2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcodec2_la-dump.Plo@am__quote@ @@ -604,6 +613,13 @@ libcodec2_la-codebookjnd.lo: codebookjnd.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcodec2_la_CFLAGS) $(CFLAGS) -c -o libcodec2_la-codebookjnd.lo `test -f 'codebookjnd.c' || echo '$(srcdir)/'`codebookjnd.c +libcodec2_la-codebookjvm.lo: codebookjvm.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcodec2_la_CFLAGS) $(CFLAGS) -MT libcodec2_la-codebookjvm.lo -MD -MP -MF "$(DEPDIR)/libcodec2_la-codebookjvm.Tpo" -c -o libcodec2_la-codebookjvm.lo `test -f 'codebookjvm.c' || echo '$(srcdir)/'`codebookjvm.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcodec2_la-codebookjvm.Tpo" "$(DEPDIR)/libcodec2_la-codebookjvm.Plo"; else rm -f "$(DEPDIR)/libcodec2_la-codebookjvm.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='codebookjvm.c' object='libcodec2_la-codebookjvm.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcodec2_la_CFLAGS) $(CFLAGS) -c -o libcodec2_la-codebookjvm.lo `test -f 'codebookjvm.c' || echo '$(srcdir)/'`codebookjvm.c + libcodec2_la-codebookdt.lo: codebookdt.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcodec2_la_CFLAGS) $(CFLAGS) -MT libcodec2_la-codebookdt.lo -MD -MP -MF "$(DEPDIR)/libcodec2_la-codebookdt.Tpo" -c -o libcodec2_la-codebookdt.lo `test -f 'codebookdt.c' || echo '$(srcdir)/'`codebookdt.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcodec2_la-codebookdt.Tpo" "$(DEPDIR)/libcodec2_la-codebookdt.Plo"; else rm -f "$(DEPDIR)/libcodec2_la-codebookdt.Tpo"; exit 1; fi @@ -818,6 +834,7 @@ codebook.$(OBJEXT): codebook.c codebookd.$(OBJEXT): codebookd.c codebookvq.$(OBJEXT): codebookvq.c codebookjnd.$(OBJEXT): codebookjnd.c +codebookjvm.$(OBJEXT): codebookjvm.c $(CODEBOOKSDT): genlspdtcb ./genlspdtcb @@ -839,8 +856,11 @@ codebookjnd.c: generate_codebook $(CODEBOOKSJND) codebookdt.c: generate_codebook $(CODEBOOKSDT) ./generate_codebook lsp_cbdt $(CODEBOOKSDT) > codebookdt.c +codebookjvm.c: generate_codebook $(CODEBOOKSJVM) + ./generate_codebook lsp_cbjvm $(CODEBOOKSJVM) > codebookjvm.c + clean-local: - -rm -f codebook.c codebookd.c codebookdvq.c codebookjnd.c codebookdt.c + -rm -f codebook.c codebookd.c codebookdvq.c codebookjnd.c codebookdt.c codebookjvm.c # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/codec2-dev/src/c2dec.c b/codec2-dev/src/c2dec.c index fed4c3e3..7d0dbcd7 100644 --- a/codec2-dev/src/c2dec.c +++ b/codec2-dev/src/c2dec.c @@ -32,8 +32,6 @@ #include #include -#define BITS_SIZE ((CODEC2_BITS_PER_FRAME + 7) / 8) - int main(int argc, char *argv[]) { int mode; @@ -62,14 +60,14 @@ int main(int argc, char *argv[]) if (strcmp(argv[2], "-") == 0) fin = stdin; else if ( (fin = fopen(argv[2],"rb")) == NULL ) { fprintf(stderr, "Error opening input bit file: %s: %s.\n", - argv[1], strerror(errno)); + argv[2], strerror(errno)); exit(1); } if (strcmp(argv[3], "-") == 0) fout = stdout; else if ( (fout = fopen(argv[3],"wb")) == NULL ) { fprintf(stderr, "Error opening output speech file: %s: %s.\n", - argv[2], strerror(errno)); + argv[3], strerror(errno)); exit(1); } @@ -79,8 +77,8 @@ int main(int argc, char *argv[]) buf = (short*)malloc(nsam*sizeof(short)); nbyte = (nbit + 7) / 8; bits = (unsigned char*)malloc(nbyte*sizeof(char)); - - while(fread(bits, sizeof(char), nbit, fin) == nbit) { + + while(fread(bits, sizeof(char), nbyte, fin) == nbyte) { codec2_decode(codec2, buf, bits); fwrite(buf, sizeof(short), nsam, fout); //if this is in a pipeline, we probably don't want the usual diff --git a/codec2-dev/src/c2enc.c b/codec2-dev/src/c2enc.c index f78fca94..8e56cfc6 100644 --- a/codec2-dev/src/c2enc.c +++ b/codec2-dev/src/c2enc.c @@ -33,8 +33,6 @@ #include #include -#define BITS_SIZE ((CODEC2_BITS_PER_FRAME + 7) / 8) - int main(int argc, char *argv[]) { int mode; @@ -63,14 +61,14 @@ int main(int argc, char *argv[]) if (strcmp(argv[2], "-") == 0) fin = stdin; else if ( (fin = fopen(argv[2],"rb")) == NULL ) { fprintf(stderr, "Error opening input bit file: %s: %s.\n", - argv[1], strerror(errno)); + argv[2], strerror(errno)); exit(1); } if (strcmp(argv[3], "-") == 0) fout = stdout; else if ( (fout = fopen(argv[3],"wb")) == NULL ) { fprintf(stderr, "Error opening output speech file: %s: %s.\n", - argv[2], strerror(errno)); + argv[3], strerror(errno)); exit(1); } @@ -79,11 +77,12 @@ int main(int argc, char *argv[]) nbit = codec2_bits_per_frame(codec2); buf = (short*)malloc(nsam*sizeof(short)); nbyte = (nbit + 7) / 8; - bits = (unsigned char*)malloc(nbyte*sizeof(char)); + bits = (unsigned char*)malloc(nbyte*sizeof(char)); + while(fread(buf, sizeof(short), nsam, fin) == nsam) { codec2_encode(codec2, bits, buf); - fwrite(bits, sizeof(char), nbit, fout); + fwrite(bits, sizeof(char), nbyte, fout); //if this is in a pipeline, we probably don't want the usual //buffering to occur if (fout == stdout) fflush(stdout); diff --git a/codec2-dev/src/c2sim.c b/codec2-dev/src/c2sim.c index 2e3a0425..f1e9f374 100644 --- a/codec2-dev/src/c2sim.c +++ b/codec2-dev/src/c2sim.c @@ -71,14 +71,13 @@ int main(int argc, char *argv[]) float prev_Wo, prev__Wo, uq_Wo, prev_uq_Wo; float pitch; int voiced1 = 0; - char out_file[MAX_STR]; int arg; float snr; float sum_snr; int lpc_model, order = LPC_ORD; - int lsp, lspd, lspvq, lsp_quantiser, lspres, lspdt, lspdt_mode, dt; + int lsp, lspd, lspvq, lsp_quantiser, lspres, lspdt, lspdt_mode, dt, lspjvm; int lspjnd; float ak[LPC_MAX]; COMP Sw_[FFT_ENC]; @@ -92,13 +91,13 @@ int main(int argc, char *argv[]) int postfilt; float bg_est; - int hand_voicing; + int hand_voicing, phasetest; FILE *fvoicing = 0; MODEL prev_model, interp_model; int decimate; float lsps[LPC_ORD]; - float prev_lsps[LPC_ORD]; + float prev_lsps[LPC_ORD], prev_lsps_[LPC_ORD]; float lsps__prev[LPC_ORD]; float lsps__prev2[LPC_ORD]; float e, prev_e; @@ -108,7 +107,7 @@ int main(int argc, char *argv[]) void *nlp_states; float hpf_states[2]; - + for(i=0; imode == CODEC2_MODE_2500) return 50; if (c2->mode == CODEC2_MODE_1400) - return 56; + return 60; return 0; /* shouldn't get here */ } @@ -311,6 +311,7 @@ void codec2_decode_2500(struct CODEC2 *c2, short speech[], const unsigned char * int Wo_index; float ak[LPC_ORD+1]; float ak_interp[LPC_ORD+1]; + float lsps_interp[LPC_ORD]; int i; unsigned int nbit = 0; MODEL model_interp; @@ -366,7 +367,8 @@ void codec2_decode_2500(struct CODEC2 *c2, short speech[], const unsigned char * memset(&model_interp.A, 0, MAX_AMP*sizeof(model_interp.A[0])); interpolate_lsp(&model_interp, &c2->prev_model, &model, - c2->prev_lsps_, c2->prev_energy, lsps_, energy, ak_interp); + c2->prev_lsps_, c2->prev_energy, lsps_, energy, ak_interp, + lsps_interp); apply_lpc_correction(&model_interp); printf("Wo: %1.5f L: %d prev_e: %3.2f v1: %d pv: %d\n", model_interp.Wo, model_interp.L, c2->prev_energy, voiced1, @@ -415,18 +417,18 @@ void codec2_decode_2500(struct CODEC2 *c2, short speech[], const unsigned char * Parameter frame 2 frame 4 Total ------------------------------------------------------- - Harmonic magnitudes (LSPs) 25 7 32 + Harmonic magnitudes (LSPs) 36 0 36 Energy 5 5 10 Wo (fundamental frequnecy) 7 3 10 Voicing (10ms update) 2 2 4 - TOTAL 39 17 56 + TOTAL 50 10 60 \*---------------------------------------------------------------------------*/ void codec2_encode_1400(struct CODEC2 *c2, unsigned char * bits, short speech[]) { MODEL model; - float lsps[LPC_ORD], prev_lsps_[LPC_ORD]; + float lsps[LPC_ORD], lsps_[LPC_ORD]; float ak[LPC_ORD+1]; float e; int voiced1, voiced2, voiced3, voiced4; @@ -435,64 +437,90 @@ void codec2_encode_1400(struct CODEC2 *c2, unsigned char * bits, short speech[]) int Wo_index, delta_Wo_index; int i; unsigned int nbit = 0; + unsigned int nbit_tmp; float prev_Wo; + //static int frames; assert(c2 != NULL); - memset(bits, '\0', codec2_bits_per_frame(c2)/8); + memset(bits, '\0', ((codec2_bits_per_frame(c2) + 7) / 8)); /* frame 1: - we just want voicing -------------------------------- */ + //printf("frame: %d\n", ++frames); analyse_one_frame(c2, &model, speech); voiced1 = model.voiced; /* frame 2: - full LSP and Wo ------------------------------------- */ + //printf("frame: %d\n", ++frames); analyse_one_frame(c2, &model, &speech[N]); voiced2 = model.voiced; Wo_index = encode_Wo(model.Wo); e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); - encode_lsps_diff_freq_vq(lsp_indexes, lsps, LPC_ORD); + encode_lsps_scalar(lsp_indexes, lsps, LPC_ORD); energy_index = encode_energy(e); pack(bits, &nbit, Wo_index, WO_BITS); - for(i=0; iSn, c2->w, LPC_ORD); - encode_lsps_diff_time_vq(lsp_indexes, lsps, prev_lsps_, LPC_ORD); + + //encode_lsps_diff_time_vq(lsp_indexes, lsps, prev_lsps_, LPC_ORD); energy_index = encode_energy(e); + //printf(" e: %f code: %d dec: %f \n", e, energy_index, decode_energy(energy_index)); pack(bits, &nbit, delta_Wo_index, WO_DT_BITS); - pack(bits, &nbit, *lsp_indexes, LSP_DIFF_TIME_BITS); + nbit_tmp = nbit; pack(bits, &nbit, energy_index, E_BITS); pack(bits, &nbit, voiced3, 1); pack(bits, &nbit, voiced4, 1); - + //printf(" 00 16 24 32 40 48 56\n"); + //printf("nbit = %d %02x %02x %02x %02x %02x %02x %02x %02x\n", nbit, + // bits[0], bits[1], bits[2], bits[3], + // bits[4], bits[5], bits[6], bits[7]); + + //printf(" nbit_tmp: %d ", nbit_tmp); + energy_index = unpack(bits, &nbit_tmp, E_BITS); + // printf("energy_index after: %d\n", energy_index); + assert(nbit == codec2_bits_per_frame(c2)); + //if (frames == 36) + //exit(0); } @@ -518,17 +546,20 @@ void codec2_decode_1400(struct CODEC2 *c2, short speech[], const unsigned char * int Wo_index, delta_Wo_index; float ak[LPC_ORD+1]; float ak_interp[LPC_ORD+1]; + float lsps_interp[LPC_ORD]; int i; unsigned int nbit = 0; MODEL model_interp; + static int frames; + float prev__Wo; assert(c2 != NULL); /* unpack frame 1 & 2 bit stream to integer codes */ Wo_index = unpack(bits, &nbit, WO_BITS); - for(i=0; iprev_model, &model, - c2->prev_lsps_, c2->prev_energy, lsps_, energy, ak_interp); + c2->prev_lsps_, c2->prev_energy, lsps_, energy, ak_interp, + lsps_interp); apply_lpc_correction(&model_interp); + frames += 2; + /* used for comparing to c2sim version + printf("frame: %d\n", frames); + printf(" Wo: %1.5f L: %d v1: %d prev_e: %f\n", + model_interp.Wo, model_interp.L, model_interp.voiced, c2->prev_energy); + printf(" lsps_interp: "); + for(i=0; iprev_model, &model, sizeof(MODEL)); memcpy(c2->prev_lsps_, lsps_, sizeof(lsps_)); c2->prev_energy = energy; + prev__Wo = model.Wo; /*--------------------------------------------------------------------*/ /* unpack frame 3 & 4 bit stream to integer codes */ delta_Wo_index = unpack(bits, &nbit, WO_DT_BITS); - *lsp_indexes = unpack(bits, &nbit, LSP_DIFF_TIME_BITS); energy_index = unpack(bits, &nbit, E_BITS); voiced3 = unpack(bits, &nbit, 1); voiced4 = unpack(bits, &nbit, 1); assert(nbit == codec2_bits_per_frame(c2)); - /* decode frame 4 LSPs and model amplitudes */ + /* decode integer codes to model parameters */ - decode_lsps_diff_time_vq(lsps_, lsp_indexes, c2->prev_lsps_, LPC_ORD); - bw_expand_lsps(lsps_, LPC_ORD); - lsp_to_lpc(lsps_, ak, LPC_ORD); + model.Wo = decode_Wo_dt(delta_Wo_index, prev__Wo); + model.L = PI/model.Wo; + memset(&model.A, 0, (model.L+1)*sizeof(model.A[0])); energy = decode_energy(energy_index); + + /* decode frame 4 */ + aks_to_M2(ak, LPC_ORD, &model, energy, &snr, 1); apply_lpc_correction(&model); @@ -599,13 +659,44 @@ void codec2_decode_1400(struct CODEC2 *c2, short speech[], const unsigned char * memset(&model_interp.A, 0, MAX_AMP*sizeof(model_interp.A[0])); interpolate_lsp(&model_interp, &c2->prev_model, &model, - c2->prev_lsps_, c2->prev_energy, lsps_, energy, ak_interp); + c2->prev_lsps_, c2->prev_energy, lsps_, energy, ak_interp, + lsps_interp); apply_lpc_correction(&model_interp); + frames +=2; + /* used for comparing to c2sim version: + printf("frame: %d\n", frames); + + printf(" Wo: %1.5f L: %d v1: %d prev_e: %f\n", + model_interp.Wo, model_interp.L, model_interp.voiced, c2->prev_energy); + printf(" lsps_interp: "); + for(i=0; iW); snr = est_voicing_mbe(model, Sw, c2->W, Sw_, Ew, c2->prev_Wo); - printf("snr %3.2f v: %d Wo: %f prev_Wo: %f\n", - snr, model->voiced, model->Wo, c2->prev_Wo); + //printf("snr %3.2f v: %d Wo: %f prev_Wo: %f\n", + // snr, model->voiced, model->Wo, c2->prev_Wo); c2->prev_Wo = model->Wo; } diff --git a/codec2-dev/src/defines.h b/codec2-dev/src/defines.h index 943704e8..abdd0db8 100644 --- a/codec2-dev/src/defines.h +++ b/codec2-dev/src/defines.h @@ -87,5 +87,6 @@ extern const struct lsp_codebook lsp_cbd[]; extern const struct lsp_codebook lsp_cbvq[]; extern const struct lsp_codebook lsp_cbjnd[]; extern const struct lsp_codebook lsp_cbdt[]; +extern const struct lsp_codebook lsp_cbjvm[]; #endif diff --git a/codec2-dev/src/interp.c b/codec2-dev/src/interp.c index 8b2c70ce..9e59244e 100644 --- a/codec2-dev/src/interp.c +++ b/codec2-dev/src/interp.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "defines.h" #include "interp.h" @@ -152,11 +153,12 @@ void interpolate_lsp( float prev_e, /* previous frames LPC energy */ float *next_lsps, /* next frames LSPs */ float next_e, /* next frames LPC energy */ - float *ak_interp /* interpolated aks for this frame */ - ) + float *ak_interp, /* interpolated aks for this frame */ + float *lsps_interp/* interpolated lsps for this frame */ +) { int l,i; - float lsps[LPC_ORD],e; + float e; float snr; /* trap corner case where V est is probably wrong */ @@ -180,22 +182,24 @@ void interpolate_lsp( } interp->L = PI/interp->Wo; - //printf("interp: prev_v: %d next_v: %d prev_Wo: %f next_Wo: %f\n", + //printf(" interp: prev_v: %d next_v: %d prev_Wo: %f next_Wo: %f\n", // prev->voiced, next->voiced, prev->Wo, next->Wo); - //printf("interp: Wo: %1.5f L: %d\n", interp->Wo, interp->L); + //printf(" interp: Wo: %1.5f L: %d\n", interp->Wo, interp->L); /* interpolate LSPs */ for(i=0; iA[1]); } diff --git a/codec2-dev/src/interp.h b/codec2-dev/src/interp.h index 3dd5f837..64c59d51 100644 --- a/codec2-dev/src/interp.h +++ b/codec2-dev/src/interp.h @@ -30,8 +30,8 @@ void interpolate(MODEL *interp, MODEL *prev, MODEL *next); void interpolate_lsp(MODEL *interp, MODEL *prev, MODEL *next, - float *prev_lsps, float prev_e, - float *next_lsps, float next_e, - float *ak_interp); + float *prev_lsps, float prev_e, + float *next_lsps, float next_e, + float *ak_interp, float *lsps_interp); #endif diff --git a/codec2-dev/src/quantise.c b/codec2-dev/src/quantise.c index 551a7dec..c6dbcc95 100644 --- a/codec2-dev/src/quantise.c +++ b/codec2-dev/src/quantise.c @@ -178,7 +178,7 @@ void lspd_quantise( lsp__hz[i] = lsp__hz[i-1] + dlsp_[i]; else lsp__hz[0] = dlsp_[0]; - lsp_[i] = (PI/4000.0)*lsp_hz[i]; + lsp_[i] = (PI/4000.0)*lsp__hz[i]; } //#define PREV_VQ @@ -249,6 +249,7 @@ void lspvq_quantise( for(i=0; i DLSP_LIMIT) + lsps_dt[i] = DLSP_LIMIT; + if (lsps_dt[i] < -DLSP_LIMIT) + lsps_dt[i] = -DLSP_LIMIT; + */ + //lsps_[i] += (PI/4000)*lsps_dt[i]; + } + k = lsp_cbdt[2].k; + m = lsp_cbdt[2].m; + cb = lsp_cbdt[2].cb; + index = quantise(cb, lsps_dt, wt, k, m, &se); + printf("k %d m %d\n", k, m); + for(i=0; ivoiced = 0; /* If pitch is jumping about it's likely this is UV */ + + /* 13 Feb 2012 - this seems to add some V errors so comment out for now. Maybe + double check on bg noise files - dF0 = (model->Wo - prev_Wo)*FS/TWO_PI; - if (fabs(dF0) > 15.0) - model->voiced = 0; + dF0 = (model->Wo - prev_Wo)*FS/TWO_PI; + if (fabs(dF0) > 15.0) + model->voiced = 0; + */ /* A common source of Type 2 errors is the pitch estimator gives a low (50Hz) estimate for UV speech, which gives a good match with noise due to the close harmoonic spacing. - These errors are much more common than people with 50Hz + These errors are much more common than people with 50Hz3 pitch, so we have just a small eratio threshold. */ sixty = 60.0*TWO_PI/FS; @@ -592,6 +596,8 @@ void synthesise( #ifdef FFT_SYNTHESIS /* Now set up frequency domain synthesised speech */ for(l=1; l<=model->L; l++) { + //for(l=model->L/2; l<=model->L; l++) { + //for(l=1; l<=model->L/4; l++) { b = floor(l*model->Wo*FFT_DEC/TWO_PI + 0.5); if (b > ((FFT_DEC/2)-1)) { b = (FFT_DEC/2)-1;