From: drowe67 Date: Fri, 28 Aug 2009 03:37:19 +0000 (+0000) Subject: first pass at a 37 bits/fr LSP quantiser, sounds OK on hts1a and hts2a X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=029af6f3d181d60ce2f8962920dccc03bdc54949;p=freetel-svn-tracking.git first pass at a 37 bits/fr LSP quantiser, sounds OK on hts1a and hts2a git-svn-id: https://svn.code.sf.net/p/freetel/code@34 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2/TODO.txt b/codec2/TODO.txt index f7c0cbbb..4da876f3 100644 --- a/codec2/TODO.txt +++ b/codec2/TODO.txt @@ -12,3 +12,5 @@ TODO for codec2 Science Lib (GSL) SL FFT as NRC code has restrictive licencing [ ] A way to handle m=1 harmonic for males when LPC modelling [ ] Is BW expansion and Rk noise floor required before LSP quant +[ ] test split VQ to make sure no silly errors + + for example test MSE or index historgram for training data diff --git a/codec2/script/menu.sh b/codec2/script/menu.sh index 78f0fd08..48ec3b33 100755 --- a/codec2/script/menu.sh +++ b/codec2/script/menu.sh @@ -39,7 +39,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. files=0 -items="0 QUIT " +items="Q-Quit " while [ ! -z "$1" ] do case "$1" in @@ -47,7 +47,7 @@ do *) files=`expr 1 + $files`; new_file=$1; file[$files]=$new_file; - items="${items} ${files} ${new_file}";; + items="${items} ${files}-${new_file}";; esac shift done diff --git a/codec2/src/quantise.c b/codec2/src/quantise.c index b4a5b49e..a8ea3d5a 100644 --- a/codec2/src/quantise.c +++ b/codec2/src/quantise.c @@ -25,6 +25,7 @@ */ #include +#include #include "sine.h" #include "quantise.h" #include "lpc.h" @@ -45,6 +46,22 @@ const float lag_window[11] = { 0.83367, 0.79434, 0.75258 }; +/* 10 + 9 + 9 + 9 = 37 bit quantiser (1850 bit/s with 20ms frames) */ + +#define LSP_12_K 2 +#define LSP_12_M 1024 +#define LSP_34_K 2 +#define LSP_34_M 512 +#define LSP_57_K 3 +#define LSP_57_M 512 +#define LSP_810_K 3 +#define LSP_810_M 512 + +static float cb12[LSP_12_K*LSP_12_M]; +static float cb34[LSP_34_K*LSP_34_M]; +static float cb57[LSP_57_K*LSP_57_M]; +static float cb810[LSP_810_K*LSP_810_M]; + /*---------------------------------------------------------------------------*\ quantise_uniform @@ -76,9 +93,9 @@ void quantise_uniform(float *val, float min, float max, int bits) /*---------------------------------------------------------------------------*\ - lsp_quantise + lspd_quantise - Differential lsp quantiser + Simulates differential lsp quantiser \*---------------------------------------------------------------------------*/ @@ -106,6 +123,112 @@ void lsp_quantise( lsp_[i] = lsp_[i-1] + dlsp_[i]; } +/*---------------------------------------------------------------------------*\ + + scan_line() + + This function reads a vector of floats from a line in a text file. + +\*---------------------------------------------------------------------------*/ + +void scan_line(FILE *fp, float f[], int n) +/* FILE *fp; file ptr to text file */ +/* float f[]; array of floats to return */ +/* int n; number of floats in line */ +{ + char s[MAX_STR]; + char *ps,*pe; + int i; + + fgets(s,MAX_STR,fp); + ps = pe = s; + for(i=0; i {Am} LPC decode */ diff --git a/codec2/src/quantise.h b/codec2/src/quantise.h index 5b1a15f0..762c0dfc 100644 --- a/codec2/src/quantise.h +++ b/codec2/src/quantise.h @@ -29,6 +29,7 @@ #include "sine.h" +void quantise_init(); float lpc_model_amplitudes(float Sn[], MODEL *model, int order, int lsp); void aks_to_M2(float ak[], int order, MODEL *model, float E, float *snr); diff --git a/codec2/src/sinedec.c b/codec2/src/sinedec.c index aa4f937a..37c131a6 100644 --- a/codec2/src/sinedec.c +++ b/codec2/src/sinedec.c @@ -149,6 +149,7 @@ int main(int argc, char *argv[]) init_encoder(); Nw = 220; make_window(Nw); + quantise_init(); /* Main loop ------------------------------------------------------------*/ diff --git a/codec2/unittest/extract.c b/codec2/unittest/extract.c index 59c6267a..3b44d369 100644 --- a/codec2/unittest/extract.c +++ b/codec2/unittest/extract.c @@ -94,7 +94,7 @@ int main(int argc, char *argv[]) { FUNCTION....: scan_line() AUTHOR......: David Rowe - DATE CREATED: 20/9/96 + DATE CREATED: 20/2/95 This function reads a vector of floats from a line in a text file. diff --git a/codec2/unittest/vqtrain.c b/codec2/unittest/vqtrain.c index f657f8ab..9084746c 100644 --- a/codec2/unittest/vqtrain.c +++ b/codec2/unittest/vqtrain.c @@ -192,7 +192,7 @@ int main(int argc, char *argv[]) { FUNCTION....: zero() AUTHOR......: David Rowe - DATE CREATED: 27/9/96 + DATE CREATED: 23/2/95 Zeros a vector of length k. @@ -213,7 +213,7 @@ void zero(float v[], int k) FUNCTION....: acc() AUTHOR......: David Rowe - DATE CREATED: 27/9/96 + DATE CREATED: 23/2/95 Adds k dimensional vectors v1 to v2 and stores the result back in v1. @@ -235,7 +235,7 @@ void acc(float v1[], float v2[], int k) FUNCTION....: norm() AUTHOR......: David Rowe - DATE CREATED: 27/9/96 + DATE CREATED: 23/2/95 Divides each element in k dimensional vector v by n. @@ -257,7 +257,7 @@ void norm(float v[], int k, long n) FUNCTION....: quantise() AUTHOR......: David Rowe - DATE CREATED: 27/9/96 + DATE CREATED: 23/2/95 Quantises vec by choosing the nearest vector in codebook cb, and returns the vector index. The squared error of the quantised vector