From: drowe67 Date: Sun, 9 Aug 2015 05:51:54 +0000 (+0000) Subject: mbest VQ working for 700b, sounds the same as Octave X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=5a51bbf443d028a40a58239cfaf95a2a1da9798e;p=freetel-svn-tracking.git mbest VQ working for 700b, sounds the same as Octave git-svn-id: https://svn.code.sf.net/p/freetel/code@2265 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/octave/melvq.m b/codec2-dev/octave/melvq.m index 1de92b78..4dbc8e03 100644 --- a/codec2-dev/octave/melvq.m +++ b/codec2-dev/octave/melvq.m @@ -152,7 +152,7 @@ function ind = test_run(samplename) fclose(fmel_); end -ind = test_run("cq_ref"); +ind = test_run("vk5qi"); %load "../build_linux/src/all_mel.txt" %vq = trainvq(all_mel, 64, 3); diff --git a/codec2-dev/src/c2sim.c b/codec2-dev/src/c2sim.c index 15e37fc6..1dc5af2c 100644 --- a/codec2-dev/src/c2sim.c +++ b/codec2-dev/src/c2sim.c @@ -140,14 +140,15 @@ int main(int argc, char *argv[]) int bpf_en = 0; int bpfb_en = 0; float bpf_buf[BPF_N+N]; - + float lspmelvq_mse = 0.0; + char* opt_string = "ho:"; struct option long_options[] = { { "lpc", required_argument, &lpc_model, 1 }, { "lspjnd", no_argument, &lspjnd, 1 }, { "lspmel", no_argument, &lspmel, 1 }, { "lspmelread", required_argument, &lspmelread, 1 }, - { "lspmelvq", required_argument, &lspmelvq, 1 }, + { "lspmelvq", no_argument, &lspmelvq, 1 }, { "lsp", no_argument, &lsp, 1 }, { "lspd", no_argument, &lspd, 1 }, { "lspvq", no_argument, &lspvq, 1 }, @@ -649,11 +650,11 @@ int main(int argc, char *argv[]) f = (4000.0/PI)*lsps[i]; mel[i] = floor(2595.0*log10(1.0 + f/700.0) + 0.5); } - + #ifdef DUMP dump_mel(mel, order); #endif - + encode_mels_scalar(mel_indexes, mel, 6); #ifdef DUMP dump_mel_indexes(mel_indexes, 6); @@ -661,18 +662,24 @@ int main(int argc, char *argv[]) //decode_mels_scalar(mel, mel_indexes, 6); /* read in VQed lsp-mels from octave/melvq.m */ - + if (lspmelread) { - int ret = fread(mel, sizeof(float), order, flspmel); + float mel_[order]; + int ret = fread(mel_, sizeof(float), order, flspmel); assert(ret == order); + for(i=0; ientries; i++) { for(j=0; jlist[i].index[j]); - printf(" %f\n", mbest->list[i].error); + fprintf(stderr, " %4d ", mbest->list[i].index[j]); + fprintf(stderr, " %f\n", mbest->list[i].error); } } @@ -693,37 +696,32 @@ static void mbest_search( } -/* 3 stage VQ LSP quantiser. Design and guidance kindly submitted by Anssi, OH3GDD */ +/* 3 stage VQ LSP quantiser useing mbest search. Design and guidance kindly submitted by Anssi, OH3GDD */ -void lspanssi_quantise(float *x, float *xq, int ndim, int mbest_entries) +float lspmelvq_mbest_quantise(float *x, float *xq, int ndim, int mbest_entries) { - int i, j, n1, n2, n3, n4; - float w[LPC_ORD]; - const float *codebook1 = lsp_cbvqanssi[0].cb; - const float *codebook2 = lsp_cbvqanssi[1].cb; - const float *codebook3 = lsp_cbvqanssi[2].cb; - const float *codebook4 = lsp_cbvqanssi[3].cb; - struct MBEST *mbest_stage1, *mbest_stage2, *mbest_stage3, *mbest_stage4; - float target[LPC_ORD]; + int i, j, n1, n2, n3; + const float *codebook1 = lspmelvq_cb[0].cb; + const float *codebook2 = lspmelvq_cb[1].cb; + const float *codebook3 = lspmelvq_cb[2].cb; + struct MBEST *mbest_stage1, *mbest_stage2, *mbest_stage3; + float target[ndim]; + float w[ndim]; int index[MBEST_STAGES]; + float mse, tmp; + for(i=0; ilist[j].index[0]; for(i=0; ilist[j].index[0]; for(i=0; ilist[j].index[2]; - index[2] = n2 = mbest_stage3->list[j].index[1]; - index[1] = n3 = mbest_stage3->list[j].index[0]; - for(i=0; ilist[0].index[2]; + n2 = mbest_stage3->list[0].index[1]; + n3 = mbest_stage3->list[0].index[0]; + mse = 0.0; + for (i=0;ilist[0].index[3]; - n2 = mbest_stage4->list[0].index[2]; - n3 = mbest_stage4->list[0].index[1]; - n4 = mbest_stage4->list[0].index[0]; - for (i=0;i