diff options
author | Tom Rondeau | 2012-04-13 18:36:53 -0400 |
---|---|---|
committer | Tom Rondeau | 2012-04-13 18:36:53 -0400 |
commit | f919f9dcbb54a08e6e26d6c229ce92fb784fa1b2 (patch) | |
tree | 7e846386b9eb1676f9a93fc4a1e55916b9accc97 /gr-vocoder/lib/codec2 | |
parent | 6a1e9783fec6ed827f49db27c171591d30f32933 (diff) | |
download | gnuradio-f919f9dcbb54a08e6e26d6c229ce92fb784fa1b2.tar.gz gnuradio-f919f9dcbb54a08e6e26d6c229ce92fb784fa1b2.tar.bz2 gnuradio-f919f9dcbb54a08e6e26d6c229ce92fb784fa1b2.zip |
Removed whitespace and added dtools/bin/remove-whitespace as a tool to do this in the future.
The sed script was provided by Moritz Fischer.
Diffstat (limited to 'gr-vocoder/lib/codec2')
38 files changed, 658 insertions, 658 deletions
diff --git a/gr-vocoder/lib/codec2/CMakeLists.txt b/gr-vocoder/lib/codec2/CMakeLists.txt index c9839bd96..95e9d256b 100644 --- a/gr-vocoder/lib/codec2/CMakeLists.txt +++ b/gr-vocoder/lib/codec2/CMakeLists.txt @@ -80,7 +80,7 @@ set(CODEBOOKSDVQ ${CMAKE_CURRENT_SOURCE_DIR}/codebook/dlsp2.txt ${CMAKE_CURRENT_SOURCE_DIR}/codebook/dlsp3.txt ${CMAKE_CURRENT_SOURCE_DIR}/codebook/dlsp4.txt - ${CMAKE_CURRENT_SOURCE_DIR}/codebook/dlsp5.txt + ${CMAKE_CURRENT_SOURCE_DIR}/codebook/dlsp5.txt ) add_custom_command( diff --git a/gr-vocoder/lib/codec2/_kiss_fft_guts.h b/gr-vocoder/lib/codec2/_kiss_fft_guts.h index ba6614440..f008a7b50 100644 --- a/gr-vocoder/lib/codec2/_kiss_fft_guts.h +++ b/gr-vocoder/lib/codec2/_kiss_fft_guts.h @@ -20,7 +20,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND #include <limits.h> #define MAXFACTORS 32 -/* e.g. an fft of length 128 has 4 factors +/* e.g. an fft of length 128 has 4 factors as far as kissfft is concerned 4*4*4*2 */ @@ -48,7 +48,7 @@ struct kiss_fft_state{ #define SAMP_MAX 2147483647 #else # define FRACBITS 15 -# define SAMPPROD int32_t +# define SAMPPROD int32_t #define SAMP_MAX 32767 #endif @@ -152,12 +152,12 @@ struct kiss_fft_state{ #ifdef KISS_FFT_USE_ALLOCA // define this to allow use of alloca instead of malloc for temporary buffers -// Temporary buffers are used in two case: +// Temporary buffers are used in two case: // 1. FFT sizes that have "bad" factors. i.e. not 2,3 and 5 // 2. "in-place" FFTs. Notice the quotes, since kissfft does not really do an in-place transform. #include <alloca.h> #define KISS_FFT_TMP_ALLOC(nbytes) alloca(nbytes) -#define KISS_FFT_TMP_FREE(ptr) +#define KISS_FFT_TMP_FREE(ptr) #else #define KISS_FFT_TMP_ALLOC(nbytes) KISS_FFT_MALLOC(nbytes) #define KISS_FFT_TMP_FREE(ptr) KISS_FFT_FREE(ptr) diff --git a/gr-vocoder/lib/codec2/c2dec.c b/gr-vocoder/lib/codec2/c2dec.c index b866d04d6..3123e96fb 100644 --- a/gr-vocoder/lib/codec2/c2dec.c +++ b/gr-vocoder/lib/codec2/c2dec.c @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) //buffering to occur if (fout == stdout) fflush(stdout); if (fin == stdin) fflush(stdin); - + } codec2_destroy(codec2); diff --git a/gr-vocoder/lib/codec2/c2demo.c b/gr-vocoder/lib/codec2/c2demo.c index efa8d6449..b9e17a78e 100644 --- a/gr-vocoder/lib/codec2/c2demo.c +++ b/gr-vocoder/lib/codec2/c2demo.c @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) printf("usage: %s InputRawSpeechFile OutputRawSpeechFile\n", argv[0]); exit(1); } - + if ( (fin = fopen(argv[1],"rb")) == NULL ) { fprintf(stderr, "Error opening input speech file: %s: %s.\n", argv[1], strerror(errno)); @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) codec2 = codec2_create(); - while(fread(buf, sizeof(short), CODEC2_SAMPLES_PER_FRAME, fin) == + while(fread(buf, sizeof(short), CODEC2_SAMPLES_PER_FRAME, fin) == CODEC2_SAMPLES_PER_FRAME) { codec2_encode(codec2, bits, buf); codec2_decode(codec2, buf, bits); diff --git a/gr-vocoder/lib/codec2/c2enc.c b/gr-vocoder/lib/codec2/c2enc.c index 4d1d019df..0e5b26cfd 100644 --- a/gr-vocoder/lib/codec2/c2enc.c +++ b/gr-vocoder/lib/codec2/c2enc.c @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) printf("usage: %s InputRawspeechFile OutputBitFile\n", argv[0]); exit(1); } - + if (strcmp(argv[1], "-") == 0) fin = stdin; else if ( (fin = fopen(argv[1],"rb")) == NULL ) { fprintf(stderr, "Error opening input bit file: %s: %s.\n", diff --git a/gr-vocoder/lib/codec2/c2sim.c b/gr-vocoder/lib/codec2/c2sim.c index bb49c7899..e335078b6 100644 --- a/gr-vocoder/lib/codec2/c2sim.c +++ b/gr-vocoder/lib/codec2/c2sim.c @@ -4,8 +4,8 @@ AUTHOR......: David Rowe DATE CREATED: 20/8/2010 - Codec2 simulation. Combines encoder and decoder and allows switching in - out various algorithms and quantisation steps. + Codec2 simulation. Combines encoder and decoder and allows switching in + out various algorithms and quantisation steps. \*---------------------------------------------------------------------------*/ @@ -45,13 +45,13 @@ #include "interp.h" /*---------------------------------------------------------------------------*\ - - switch_present() - - Searches the command line arguments for a "switch". If the switch is - found, returns the command line argument where it ws found, else returns - NULL. - + + switch_present() + + Searches the command line arguments for a "switch". If the switch is + found, returns the command line argument where it ws found, else returns + NULL. + \*---------------------------------------------------------------------------*/ int switch_present(sw,argc,argv) @@ -71,9 +71,9 @@ register char *argv[]; /* array of command line arguments in string form */ void synth_one_frame(short buf[], MODEL *model, float Sn_[], float Pn[]); /*---------------------------------------------------------------------------*\ - - MAIN - + + MAIN + \*---------------------------------------------------------------------------*/ int main(int argc, char *argv[]) @@ -103,10 +103,10 @@ int main(int argc, char *argv[]) int lsp, lspd, lspdvq, lsp_quantiser; float ak[LPC_MAX]; COMP Sw_[FFT_ENC]; - COMP Ew[FFT_ENC]; - + COMP Ew[FFT_ENC]; + int dump; - + int phase0; float ex_phase[MAX_AMP+1]; @@ -129,7 +129,7 @@ int main(int argc, char *argv[]) float AresdB_prev[MAX_AMP]; for(i=0; i<MAX_AMP; i++) - AresdB_prev[i] = 0.0; + AresdB_prev[i] = 0.0; for(i=0; i<M; i++) Sn[i] = 1.0; @@ -201,12 +201,12 @@ int main(int argc, char *argv[]) if ((order < 4) || (order > 20)) { fprintf(stderr, "Error in lpc order: %d\n", order); exit(1); - } + } } dump = switch_present("--dump",argc,argv); #ifdef DUMP - if (dump) + if (dump) dump_on(argv[dump+1]); #endif @@ -264,7 +264,7 @@ int main(int argc, char *argv[]) //Sn[i+M-N] = hpf((float)buf[i], hpf_states); Sn[i+M-N] = (float)buf[i]; } - + /* Estimate pitch */ nlp(nlp_states,Sn,N,M,P_MIN,P_MAX,&pitch,Sw,&prev_Wo); @@ -272,10 +272,10 @@ int main(int argc, char *argv[]) /* estimate model parameters */ - dft_speech(Sw, Sn, w); + dft_speech(Sw, Sn, w); two_stage_pitch_refinement(&model, Sw); estimate_amplitudes(&model, Sw, W); -#ifdef DUMP +#ifdef DUMP dump_Sn(Sn); dump_Sw(Sw); dump_model(&model); #endif @@ -284,7 +284,7 @@ int main(int argc, char *argv[]) if (phase0) { float Wn[M]; /* windowed speech samples */ float Rk[LPC_MAX+1]; /* autocorrelation coeffs */ - + #ifdef DUMP dump_phase(&model.phi[0], model.L); #endif @@ -299,7 +299,7 @@ int main(int argc, char *argv[]) #ifdef DUMP dump_ak(ak, LPC_ORD); #endif - + /* determine voicing */ snr = est_voicing_mbe(&model, Sw, W, Sw_, Ew, prev_Wo); @@ -313,7 +313,7 @@ int main(int argc, char *argv[]) for(i=0; i<MAX_AMP; i++) model.phi[i] = 0; - + if (hand_voicing) { fscanf(fvoicing,"%d\n",&model.voiced); } @@ -350,7 +350,7 @@ int main(int argc, char *argv[]) e = decode_energy(encode_energy(e)); model.Wo = decode_Wo(encode_Wo(model.Wo)); - aks_to_M2(ak, order, &model, e, &snr, 1); + aks_to_M2(ak, order, &model, e, &snr, 1); apply_lpc_correction(&model); sum_snr += snr; #ifdef DUMP @@ -371,7 +371,7 @@ int main(int argc, char *argv[]) /* option decimation to 20ms rate, which enables interpolation routine to synthesise in between frame */ - + if (decimate) { if (!phase0) { printf("needs --phase0 to resample phase for interpolated Wo\n"); @@ -395,17 +395,17 @@ int main(int argc, char *argv[]) prev_lsps, prev_e, lsps, e, ak_interp); apply_lpc_correction(&interp_model); #endif - + if (phase0) phase_synth_zero_order(&interp_model, ak_interp, ex_phase, - order); + order); if (postfilt) postfilter(&interp_model, &bg_est); synth_one_frame(buf, &interp_model, Sn_, Pn); if (fout != NULL) fwrite(buf,sizeof(short),N,fout); if (phase0) - phase_synth_zero_order(&model, ak, ex_phase, order); + phase_synth_zero_order(&model, ak, ex_phase, order); if (postfilt) postfilter(&model, &bg_est); synth_one_frame(buf, &model, Sn_, Pn); @@ -422,7 +422,7 @@ int main(int argc, char *argv[]) } else { if (phase0) - phase_synth_zero_order(&model, ak, ex_phase, order); + phase_synth_zero_order(&model, ak, ex_phase, order); if (postfilt) postfilter(&model, &bg_est); synth_one_frame(buf, &model, Sn_, Pn); diff --git a/gr-vocoder/lib/codec2/codebook/lsp8910.txt b/gr-vocoder/lib/codec2/codebook/lsp8910.txt index 93cfdd81d..759136bfe 100644 --- a/gr-vocoder/lib/codec2/codebook/lsp8910.txt +++ b/gr-vocoder/lib/codec2/codebook/lsp8910.txt @@ -1,65 +1,65 @@ 3 64 -2.048073 2.534502 2.645915 -2.019670 2.269744 2.605462 -1.961101 2.329646 2.562857 -1.968573 2.532712 2.616918 -2.183480 2.514381 2.629582 -2.259379 2.516615 2.620410 -2.172791 2.462460 2.567064 -2.097666 2.303933 2.421685 -2.052990 2.353242 2.546992 -2.043642 2.232362 2.499262 -2.106151 2.393131 2.488401 -2.099167 2.437862 2.558655 -2.013877 2.422875 2.530071 -2.033848 2.483776 2.584598 -2.114474 2.516856 2.602372 -2.229214 2.584056 2.678855 -2.131151 2.584299 2.674845 -1.472721 2.477091 2.630241 -2.010907 2.598415 2.682989 -2.353653 2.524066 2.619773 -2.419897 2.623938 2.699605 -2.319080 2.602148 2.689044 -1.860342 2.503881 2.616576 -1.910517 2.386693 2.610126 -1.748689 2.371809 2.496542 -1.618495 2.403425 2.554956 -1.844073 2.437026 2.533443 -1.924810 2.388543 2.502698 -1.937227 2.258363 2.501697 -1.687554 2.209123 2.545239 -1.851950 2.278628 2.565632 -1.868154 2.330150 2.444883 -1.874180 2.213118 2.351940 -1.757311 2.030626 2.433836 -1.650306 2.152371 2.243421 -1.612794 1.884686 2.339313 -1.745431 2.278895 2.389449 -1.590923 2.304155 2.408510 -1.475982 2.275548 2.509897 -1.508695 2.045463 2.455520 -1.872054 2.061777 2.246202 -1.983947 2.159155 2.445535 -1.745180 2.483765 2.593698 -1.900116 2.079600 2.407479 -1.841672 2.167042 2.486827 -1.932912 2.148464 2.569850 -2.134174 2.363673 2.584252 -2.106094 2.450645 2.638417 -1.954135 2.460313 2.666512 -1.907634 2.573801 2.674025 -1.625579 2.539569 2.656363 -1.785866 2.572616 2.676082 -1.798447 2.376454 2.624298 -2.020033 2.397244 2.619868 -1.946581 2.468791 2.564185 -2.008920 2.342400 2.469132 -1.983846 2.271044 2.395408 -1.988039 2.154150 2.317920 -2.077197 2.216622 2.389101 -2.117255 2.283907 2.512242 -2.177233 2.334622 2.458268 -2.214655 2.425510 2.620013 -2.199931 2.390272 2.520731 -2.271755 2.448682 2.552649 +2.048073 2.534502 2.645915 +2.019670 2.269744 2.605462 +1.961101 2.329646 2.562857 +1.968573 2.532712 2.616918 +2.183480 2.514381 2.629582 +2.259379 2.516615 2.620410 +2.172791 2.462460 2.567064 +2.097666 2.303933 2.421685 +2.052990 2.353242 2.546992 +2.043642 2.232362 2.499262 +2.106151 2.393131 2.488401 +2.099167 2.437862 2.558655 +2.013877 2.422875 2.530071 +2.033848 2.483776 2.584598 +2.114474 2.516856 2.602372 +2.229214 2.584056 2.678855 +2.131151 2.584299 2.674845 +1.472721 2.477091 2.630241 +2.010907 2.598415 2.682989 +2.353653 2.524066 2.619773 +2.419897 2.623938 2.699605 +2.319080 2.602148 2.689044 +1.860342 2.503881 2.616576 +1.910517 2.386693 2.610126 +1.748689 2.371809 2.496542 +1.618495 2.403425 2.554956 +1.844073 2.437026 2.533443 +1.924810 2.388543 2.502698 +1.937227 2.258363 2.501697 +1.687554 2.209123 2.545239 +1.851950 2.278628 2.565632 +1.868154 2.330150 2.444883 +1.874180 2.213118 2.351940 +1.757311 2.030626 2.433836 +1.650306 2.152371 2.243421 +1.612794 1.884686 2.339313 +1.745431 2.278895 2.389449 +1.590923 2.304155 2.408510 +1.475982 2.275548 2.509897 +1.508695 2.045463 2.455520 +1.872054 2.061777 2.246202 +1.983947 2.159155 2.445535 +1.745180 2.483765 2.593698 +1.900116 2.079600 2.407479 +1.841672 2.167042 2.486827 +1.932912 2.148464 2.569850 +2.134174 2.363673 2.584252 +2.106094 2.450645 2.638417 +1.954135 2.460313 2.666512 +1.907634 2.573801 2.674025 +1.625579 2.539569 2.656363 +1.785866 2.572616 2.676082 +1.798447 2.376454 2.624298 +2.020033 2.397244 2.619868 +1.946581 2.468791 2.564185 +2.008920 2.342400 2.469132 +1.983846 2.271044 2.395408 +1.988039 2.154150 2.317920 +2.077197 2.216622 2.389101 +2.117255 2.283907 2.512242 +2.177233 2.334622 2.458268 +2.214655 2.425510 2.620013 +2.199931 2.390272 2.520731 +2.271755 2.448682 2.552649 diff --git a/gr-vocoder/lib/codec2/codec2.c b/gr-vocoder/lib/codec2/codec2.c index 92708ee32..93ea9208c 100644 --- a/gr-vocoder/lib/codec2/codec2.c +++ b/gr-vocoder/lib/codec2/codec2.c @@ -4,7 +4,7 @@ AUTHOR......: David Rowe DATE CREATED: 21/8/2010 - Codec2 fully quantised encoder and decoder functions. If you want use + Codec2 fully quantised encoder and decoder functions. If you want use codec2, the codec2_xxx functions are for you. \*---------------------------------------------------------------------------*/ @@ -45,16 +45,16 @@ #include "codec2_internal.h" /*---------------------------------------------------------------------------*\ - + FUNCTIONS \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ - - FUNCTION....: codec2_create - AUTHOR......: David Rowe - DATE CREATED: 21/8/2010 + + FUNCTION....: codec2_create + AUTHOR......: David Rowe + DATE CREATED: 21/8/2010 Create and initialise an instance of the codec. Returns a pointer to the codec states or NULL on failure. One set of states is @@ -106,10 +106,10 @@ void *codec2_create() } /*---------------------------------------------------------------------------*\ - - FUNCTION....: codec2_create - AUTHOR......: David Rowe - DATE CREATED: 21/8/2010 + + FUNCTION....: codec2_create + AUTHOR......: David Rowe + DATE CREATED: 21/8/2010 Destroy an instance of the codec. @@ -118,7 +118,7 @@ void *codec2_create() void codec2_destroy(void *codec2_state) { CODEC2 *c2; - + assert(codec2_state != NULL); c2 = (CODEC2*)codec2_state; nlp_destroy(c2->nlp); @@ -126,12 +126,12 @@ void codec2_destroy(void *codec2_state) } /*---------------------------------------------------------------------------*\ - - FUNCTION....: codec2_encode - AUTHOR......: David Rowe - DATE CREATED: 21/8/2010 - Encodes 160 speech samples (20ms of speech) into 51 bits. + FUNCTION....: codec2_encode + AUTHOR......: David Rowe + DATE CREATED: 21/8/2010 + + Encodes 160 speech samples (20ms of speech) into 51 bits. The codec2 algorithm actually operates internally on 10ms (80 sample) frames, so we run the encoding algorithm twice. On the @@ -148,7 +148,7 @@ void codec2_destroy(void *codec2_state) Wo (fundamental frequnecy) 7 Voicing (10ms update) 2 TOTAL 51 - + \*---------------------------------------------------------------------------*/ void codec2_encode(void *codec2_state, unsigned char * bits, short speech[]) @@ -174,13 +174,13 @@ void codec2_encode(void *codec2_state, unsigned char * bits, short speech[]) analyse_one_frame(c2, &model, &speech[N]); voiced2 = model.voiced; - + Wo_index = encode_Wo(model.Wo); - encode_amplitudes(lsp_indexes, + encode_amplitudes(lsp_indexes, &energy_index, - &model, - c2->Sn, - c2->w); + &model, + c2->Sn, + c2->w); memset(bits, '\0', ((CODEC2_BITS_PER_FRAME + 7) / 8)); pack(bits, &nbit, Wo_index, WO_BITS); for(i=0; i<LPC_ORD; i++) { @@ -189,15 +189,15 @@ void codec2_encode(void *codec2_state, unsigned char * bits, short speech[]) pack(bits, &nbit, energy_index, E_BITS); pack(bits, &nbit, voiced1, 1); pack(bits, &nbit, voiced2, 1); - + assert(nbit == CODEC2_BITS_PER_FRAME); } /*---------------------------------------------------------------------------*\ - - FUNCTION....: codec2_decode - AUTHOR......: David Rowe - DATE CREATED: 21/8/2010 + + FUNCTION....: codec2_decode + AUTHOR......: David Rowe + DATE CREATED: 21/8/2010 Decodes frames of 51 bits into 160 samples (20ms) of speech. @@ -239,7 +239,7 @@ void codec2_decode(void *codec2_state, short speech[], model.Wo = decode_Wo(Wo_index); model.L = PI/model.Wo; memset(&model.A, 0, (model.L+1)*sizeof(model.A[0])); - decode_amplitudes(&model, + decode_amplitudes(&model, ak, lsp_indexes, energy_index, @@ -270,10 +270,10 @@ void codec2_decode(void *codec2_state, short speech[], } /*---------------------------------------------------------------------------*\ - - FUNCTION....: synthesise_one_frame() - AUTHOR......: David Rowe - DATE CREATED: 23/8/2010 + + FUNCTION....: synthesise_one_frame() + AUTHOR......: David Rowe + DATE CREATED: 23/8/2010 Synthesise 80 speech samples (10ms) from model parameters. @@ -299,14 +299,14 @@ void synthesise_one_frame(CODEC2 *c2, short speech[], MODEL *model, float ak[]) } /*---------------------------------------------------------------------------*\ - - FUNCTION....: analyse_one_frame() - AUTHOR......: David Rowe - DATE CREATED: 23/8/2010 + + FUNCTION....: analyse_one_frame() + AUTHOR......: David Rowe + DATE CREATED: 23/8/2010 Extract sinusoidal model parameters from 80 speech samples (10ms of speech). - + \*---------------------------------------------------------------------------*/ void analyse_one_frame(CODEC2 *c2, MODEL *model, short speech[]) diff --git a/gr-vocoder/lib/codec2/codec2.h b/gr-vocoder/lib/codec2/codec2.h index 946dedca5..88e68814f 100644 --- a/gr-vocoder/lib/codec2/codec2.h +++ b/gr-vocoder/lib/codec2/codec2.h @@ -4,7 +4,7 @@ AUTHOR......: David Rowe DATE CREATED: 21/8/2010 - Codec2 fully quantised encoder and decoder functions. If you want use + Codec2 fully quantised encoder and decoder functions. If you want use codec2, these are the functions you need to call. \*---------------------------------------------------------------------------*/ diff --git a/gr-vocoder/lib/codec2/codec2_internal.h b/gr-vocoder/lib/codec2/codec2_internal.h index 3943ac29d..3aa5300b1 100644 --- a/gr-vocoder/lib/codec2/codec2_internal.h +++ b/gr-vocoder/lib/codec2/codec2_internal.h @@ -30,7 +30,7 @@ #define __CODEC2_INTERNAL__ /*---------------------------------------------------------------------------*\ - + STATES \*---------------------------------------------------------------------------*/ @@ -52,7 +52,7 @@ typedef struct { } CODEC2; /*---------------------------------------------------------------------------*\ - + FUNCTION HEADERS \*---------------------------------------------------------------------------*/ diff --git a/gr-vocoder/lib/codec2/comp.h b/gr-vocoder/lib/codec2/comp.h index cedcab37f..ffc20c163 100644 --- a/gr-vocoder/lib/codec2/comp.h +++ b/gr-vocoder/lib/codec2/comp.h @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - + FILE........: comp.h - AUTHOR......: David Rowe + AUTHOR......: David Rowe DATE CREATED: 24/08/09 - + Complex number definition. - + \*---------------------------------------------------------------------------*/ /* diff --git a/gr-vocoder/lib/codec2/defines.h b/gr-vocoder/lib/codec2/defines.h index 2dcd527d3..75064fae1 100644 --- a/gr-vocoder/lib/codec2/defines.h +++ b/gr-vocoder/lib/codec2/defines.h @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - FILE........: defines.h - AUTHOR......: David Rowe - DATE CREATED: 23/4/93 - - Defines and structures used throughout the codec. - + FILE........: defines.h + AUTHOR......: David Rowe + DATE CREATED: 23/4/93 + + Defines and structures used throughout the codec. + \*---------------------------------------------------------------------------*/ /* @@ -29,9 +29,9 @@ #define __DEFINES__ /*---------------------------------------------------------------------------*\ - - DEFINES - + + DEFINES + \*---------------------------------------------------------------------------*/ /* General defines */ @@ -58,9 +58,9 @@ #define P_MAX 160 /* maximum pitch */ /*---------------------------------------------------------------------------*\ - - TYPEDEFS - + + TYPEDEFS + \*---------------------------------------------------------------------------*/ /* Structure to hold model parameters for one frame */ diff --git a/gr-vocoder/lib/codec2/dump.c b/gr-vocoder/lib/codec2/dump.c index 73a378e23..1dc34c858 100644 --- a/gr-vocoder/lib/codec2/dump.c +++ b/gr-vocoder/lib/codec2/dump.c @@ -1,9 +1,9 @@ /*---------------------------------------------------------------------------*\ - + FILE........: dump.c - AUTHOR......: David Rowe - DATE CREATED: 25/8/09 - + AUTHOR......: David Rowe + DATE CREATED: 25/8/09 + Routines to dump data to text files for Octave analysis. \*---------------------------------------------------------------------------*/ @@ -123,10 +123,10 @@ void dump_Sn(float Sn[]) { for(i=0; i<M/2; i++) fprintf(fsn,"%f\t",Sn[i]); - fprintf(fsn,"\n"); + fprintf(fsn,"\n"); for(i=M/2; i<M; i++) fprintf(fsn,"%f\t",Sn[i]); - fprintf(fsn,"\n"); + fprintf(fsn,"\n"); } void dump_Sw(COMP Sw[]) { @@ -144,7 +144,7 @@ void dump_Sw(COMP Sw[]) { for(i=0; i<FFT_ENC/2; i++) fprintf(fsw,"%f\t", 10.0*log10(Sw[i].real*Sw[i].real + Sw[i].imag*Sw[i].imag)); - fprintf(fsw,"\n"); + fprintf(fsw,"\n"); } void dump_Sw_(COMP Sw_[]) { @@ -162,7 +162,7 @@ void dump_Sw_(COMP Sw_[]) { for(i=0; i<FFT_ENC/2; i++) fprintf(fsw_,"%f\t", 10.0*log10(Sw_[i].real*Sw_[i].real + Sw_[i].imag*Sw_[i].imag)); - fprintf(fsw_,"\n"); + fprintf(fsw_,"\n"); } void dump_Ew(COMP Ew[]) { @@ -180,7 +180,7 @@ void dump_Ew(COMP Ew[]) { for(i=0; i<FFT_ENC/2; i++) fprintf(few,"%f\t", 10.0*log10(Ew[i].real*Ew[i].real + Ew[i].imag*Ew[i].imag)); - fprintf(few,"\n"); + fprintf(few,"\n"); } void dump_model(MODEL *model) { @@ -195,13 +195,13 @@ void dump_model(MODEL *model) { assert(fmodel != NULL); } - fprintf(fmodel,"%f\t%d\t", model->Wo, model->L); + fprintf(fmodel,"%f\t%d\t", model->Wo, model->L); for(l=1; l<=model->L; l++) fprintf(fmodel,"%f\t",model->A[l]); for(l=model->L+1; l<MAX_AMP; l++) fprintf(fmodel,"0.0\t"); fprintf(fmodel,"%d\t",model->voiced); - fprintf(fmodel,"\n"); + fprintf(fmodel,"\n"); } void dump_quantised_model(MODEL *model) { @@ -216,12 +216,12 @@ void dump_quantised_model(MODEL *model) { assert(fqmodel != NULL); } - fprintf(fqmodel,"%f\t%d\t", model->Wo, model->L); + fprintf(fqmodel,"%f\t%d\t", model->Wo, model->L); for(l=1; l<=model->L; l++) fprintf(fqmodel,"%f\t",model->A[l]); for(l=model->L+1; l<MAX_AMP; l++) fprintf(fqmodel,"0.0\t"); - fprintf(fqmodel,"\n"); + fprintf(fqmodel,"\n"); } void dump_resample(float w[], float A[], int n) { @@ -241,7 +241,7 @@ void dump_resample(float w[], float A[], int n) { fprintf(fres,"%f\t",w[l]); for(l=0; l<n; l++) fprintf(fres,"%f\t",A[l]); - fprintf(fres,"\n"); + fprintf(fres,"\n"); } void dump_phase(float phase[], int L) { @@ -260,7 +260,7 @@ void dump_phase(float phase[], int L) { fprintf(fphase,"%f\t",phase[l]); for(l=L+1; l<MAX_AMP; l++) fprintf(fphase,"%f\t",0.0); - fprintf(fphase,"\n"); + fprintf(fphase,"\n"); } void dump_phase_(float phase_[], int L) { @@ -279,7 +279,7 @@ void dump_phase_(float phase_[], int L) { fprintf(fphase_,"%f\t",phase_[l]); for(l=L+1; l<MAX_AMP; l++) fprintf(fphase_,"%f\t",0.0); - fprintf(fphase_,"\n"); + fprintf(fphase_,"\n"); } void dump_snr(float snr) { @@ -310,7 +310,7 @@ void dump_Pw(COMP Pw[]) { for(i=0; i<FFT_DEC/2; i++) fprintf(fpw,"%f\t",Pw[i].real); - fprintf(fpw,"\n"); + fprintf(fpw,"\n"); } void dump_lsp(float lsp[]) { @@ -327,7 +327,7 @@ void dump_lsp(float lsp[]) { for(i=0; i<10; i++) fprintf(flsp,"%f\t",lsp[i]); - fprintf(flsp,"\n"); + fprintf(flsp,"\n"); } void dump_ak(float ak[], int order) { @@ -344,7 +344,7 @@ void dump_ak(float ak[], int order) { for(i=0; i<=order; i++) fprintf(fak,"%f\t",ak[i]); - fprintf(fak,"\n"); + fprintf(fak,"\n"); } void dump_Fw(COMP Fw[]) { @@ -361,7 +361,7 @@ void dump_Fw(COMP Fw[]) { for(i=0; i<256; i++) fprintf(ffw,"%f\t",Fw[i].real); - fprintf(ffw,"\n"); + fprintf(ffw,"\n"); } void dump_e(float e_hz[]) { @@ -378,10 +378,10 @@ void dump_e(float e_hz[]) { for(i=0; i<500/2; i++) fprintf(fe,"%f\t",e_hz[i]); - fprintf(fe,"\n"); + fprintf(fe,"\n"); for(i=500/2; i<500; i++) fprintf(fe,"%f\t",e_hz[i]); - fprintf(fe,"\n"); + fprintf(fe,"\n"); } void dump_sq(float sq[]) { @@ -398,10 +398,10 @@ void dump_sq(float sq[]) { for(i=0; i<M/2; i++) fprintf(fsq,"%f\t",sq[i]); - fprintf(fsq,"\n"); + fprintf(fsq,"\n"); for(i=M/2; i<M; i++) fprintf(fsq,"%f\t",sq[i]); - fprintf(fsq,"\n"); + fprintf(fsq,"\n"); } void dump_dec(COMP Fw[]) { @@ -418,7 +418,7 @@ void dump_dec(COMP Fw[]) { for(i=0; i<320/5; i++) fprintf(fdec,"%f\t",Fw[i].real); - fprintf(fdec,"\n"); + fprintf(fdec,"\n"); } void dump_bg(float e, float bg_est, float percent_uv) { @@ -432,7 +432,7 @@ void dump_bg(float e, float bg_est, float percent_uv) { assert(fbg != NULL); } - fprintf(fbg,"%f\t%f\t%f\n", e, bg_est, percent_uv); + fprintf(fbg,"%f\t%f\t%f\n", e, bg_est, percent_uv); } void dump_E(float E) { @@ -463,7 +463,7 @@ void dump_Rk(float Rk[]) { for(i=0; i<P_MAX; i++) fprintf(frk,"%f\t",Rk[i]); - fprintf(frk,"\n"); + fprintf(frk,"\n"); } #endif diff --git a/gr-vocoder/lib/codec2/dump.h b/gr-vocoder/lib/codec2/dump.h index eeddd3406..4b92d009d 100644 --- a/gr-vocoder/lib/codec2/dump.h +++ b/gr-vocoder/lib/codec2/dump.h @@ -1,9 +1,9 @@ /*---------------------------------------------------------------------------*\ - + FILE........: dump.h - AUTHOR......: David Rowe - DATE CREATED: 25/8/09 - + AUTHOR......: David Rowe + DATE CREATED: 25/8/09 + Routines to dump data to text files for Octave analysis. \*---------------------------------------------------------------------------*/ diff --git a/gr-vocoder/lib/codec2/fft.c b/gr-vocoder/lib/codec2/fft.c index a3027e4cd..19f3141a8 100644 --- a/gr-vocoder/lib/codec2/fft.c +++ b/gr-vocoder/lib/codec2/fft.c @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - - FILE........: fft.c - AUTHOR......: Bruce Robertson - DATE CREATED: 20/11/2010 - - Bridging function to the kiss_fft package. - + + FILE........: fft.c + AUTHOR......: Bruce Robertson + DATE CREATED: 20/11/2010 + + Bridging function to the kiss_fft package. + \*---------------------------------------------------------------------------*/ /* @@ -29,9 +29,9 @@ #include "kiss_fft.h" /*---------------------------------------------------------------------------*\ - - GLOBALS - + + GLOBALS + \*---------------------------------------------------------------------------*/ kiss_fft_cpx *fin; @@ -40,10 +40,10 @@ kiss_fft_cfg cfg_forward; kiss_fft_cfg cfg_reverse; /*---------------------------------------------------------------------------*\ - - initialize_fft(int n) - - Initialisation function for kiss_fft. This assumes that all calls to fft() + + initialize_fft(int n) + + Initialisation function for kiss_fft. This assumes that all calls to fft() use the same datatypes and are one arrays of the same size. \*---------------------------------------------------------------------------*/ @@ -62,8 +62,8 @@ initialize_fft (int n) } /*---------------------------------------------------------------------------*\ - - fft(float x[], int n, int isign) + + fft(float x[], int n, int isign) Function that calls kiss_fft with the signature of four1 from NRC. \*---------------------------------------------------------------------------*/ diff --git a/gr-vocoder/lib/codec2/fft.h b/gr-vocoder/lib/codec2/fft.h index 84c6737bd..d5f83045e 100644 --- a/gr-vocoder/lib/codec2/fft.h +++ b/gr-vocoder/lib/codec2/fft.h @@ -1,5 +1,5 @@ /*---------------------------------------------------------------------------*\ - + FILE........: fft.h AUTHOR......: Bruce Robertson DATE CREATED: 29/11/2010 diff --git a/gr-vocoder/lib/codec2/fq20.sh b/gr-vocoder/lib/codec2/fq20.sh index b83784b43..9ccf739dc 100755 --- a/gr-vocoder/lib/codec2/fq20.sh +++ b/gr-vocoder/lib/codec2/fq20.sh @@ -1,7 +1,7 @@ #!/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/gr-vocoder/lib/codec2/generate_codebook.c b/gr-vocoder/lib/codec2/generate_codebook.c index 0bea80d85..705f29d38 100644 --- a/gr-vocoder/lib/codec2/generate_codebook.c +++ b/gr-vocoder/lib/codec2/generate_codebook.c @@ -1,9 +1,9 @@ /*---------------------------------------------------------------------------*\ - + FILE........: generate_codebook.c - AUTHOR......: Bruce Perens - DATE CREATED: 29 Sep 2010 - + AUTHOR......: Bruce Perens + DATE CREATED: 29 Sep 2010 + Generate header files containing LSP quantisers, runs at compile time. \*---------------------------------------------------------------------------*/ @@ -92,7 +92,7 @@ get_float(FILE * in, const char * name, char * * cursor, char * buffer, while ( (c = *s) != '\0' && !isdigit(c) && c != '-' && c != '.' ) s++; - + /* Comments start with "#" and continue to the end of the line. */ if ( c != '\0' && c != '#' ) { char * end = 0; diff --git a/gr-vocoder/lib/codec2/globals.c b/gr-vocoder/lib/codec2/globals.c index f2182f79a..da2faf722 100644 --- a/gr-vocoder/lib/codec2/globals.c +++ b/gr-vocoder/lib/codec2/globals.c @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - + FILE........: globals.c - AUTHOR......: David Rowe - DATE CREATED: 11/5/94 - - Globals for sinusoidal speech coder. - + AUTHOR......: David Rowe + DATE CREATED: 11/5/94 + + Globals for sinusoidal speech coder. + \*---------------------------------------------------------------------------*/ /* diff --git a/gr-vocoder/lib/codec2/globals.h b/gr-vocoder/lib/codec2/globals.h index cef720344..d01e7b4e9 100644 --- a/gr-vocoder/lib/codec2/globals.h +++ b/gr-vocoder/lib/codec2/globals.h @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - + FILE........: globals.h AUTHOR......: David Rowe - DATE CREATED: 1/11/94 - - Globals for sinusoidal speech coder. - + DATE CREATED: 1/11/94 + + Globals for sinusoidal speech coder. + \*---------------------------------------------------------------------------*/ /* diff --git a/gr-vocoder/lib/codec2/interp.c b/gr-vocoder/lib/codec2/interp.c index 257c4a81c..64372b050 100644 --- a/gr-vocoder/lib/codec2/interp.c +++ b/gr-vocoder/lib/codec2/interp.c @@ -41,10 +41,10 @@ float sample_log_amp(MODEL *model, float w); /*---------------------------------------------------------------------------*\ - FUNCTION....: interp() - AUTHOR......: David Rowe - DATE CREATED: 22/8/10 - + FUNCTION....: interp() + AUTHOR......: David Rowe + DATE CREATED: 22/8/10 + Given two frames decribed by model parameters 20ms apart, determines the model parameters of the 10ms frame between them. Assumes voicing is available for middle (interpolated) frame. Outputs are @@ -58,7 +58,7 @@ float sample_log_amp(MODEL *model, float w); When this function is used (--dec mode) bg noise appears to be amplitude modulated, and gets louder. The interp_lsp() function below seems to do a better job. - + \*---------------------------------------------------------------------------*/ void interpolate( @@ -97,13 +97,13 @@ void interpolate( /*---------------------------------------------------------------------------*\ FUNCTION....: sample_log_amp() - AUTHOR......: David Rowe - DATE CREATED: 22/8/10 - + AUTHOR......: David Rowe + DATE CREATED: 22/8/10 + Samples the amplitude envelope at an arbitrary frequency w. Uses linear interpolation in the log domain to sample between harmonic amplitudes. - + \*---------------------------------------------------------------------------*/ float sample_log_amp(MODEL *model, float w) @@ -125,9 +125,9 @@ float sample_log_amp(MODEL *model, float w) log_amp = (1.0-f)*log10(model->A[model->L] + 1E-6); } else { - log_amp = (1.0-f)*log10(model->A[m] + 1E-6) + + log_amp = (1.0-f)*log10(model->A[m] + 1E-6) + f*log10(model->A[m+1] + 1E-6); - //printf("m=%d A[m] %f A[m+1] %f x %f %f %f\n", m, model->A[m], + //printf("m=%d A[m] %f A[m+1] %f x %f %f %f\n", m, model->A[m], // model->A[m+1], pow(10.0, log_amp), // (1-f), f); } @@ -138,13 +138,13 @@ float sample_log_amp(MODEL *model, float w) /*---------------------------------------------------------------------------*\ FUNCTION....: sample_log_amp_quad() - AUTHOR......: David Rowe - DATE CREATED: 9 March 2011 - + AUTHOR......: David Rowe + DATE CREATED: 9 March 2011 + Samples the amplitude envelope at an arbitrary frequency w. Uses quadratic interpolation in the log domain to sample between harmonic amplitudes. - + y(x) = ax*x + bx + c We assume three points are x=-1, x=0, x=1, which we map to m-1,m,m+1 @@ -172,7 +172,7 @@ float sample_log_amp_quad(MODEL *model, float w) log_amp = a*x*x + b*x + c; //printf("m=%d A[m-1] %f A[m] %f A[m+1] %f w %f x %f log_amp %f\n", m, - // model->A[m-1], + // model->A[m-1], // model->A[m], model->A[m+1], w, x, pow(10.0, log_amp)); return log_amp; } @@ -180,14 +180,14 @@ float sample_log_amp_quad(MODEL *model, float w) /*---------------------------------------------------------------------------*\ FUNCTION....: sample_log_amp_quad_nl() - AUTHOR......: David Rowe + AUTHOR......: David Rowe DATE CREATED: 10 March 2011 - + Samples the amplitude envelope at an arbitrary frequency w. Uses quadratic interpolation in the log domain to sample between harmonic amplitudes. This version can handle non-linear steps along a freq axis defined by arbitrary steps. - + y(x) = ax*x + bx + c We assume three points are (x_1,y_1), (0,y0) and (x1,y1). @@ -215,9 +215,9 @@ float sample_log_amp_quad_nl( for (i=0; i<np; i++) if (fabs(w[i] - w_sample) < best_dist) { best_dist = fabs(w[i] - w_sample); - m = i; + m = i; } - + /* stay one point away from edge of array */ if (m < 1) m = 1; @@ -234,13 +234,13 @@ float sample_log_amp_quad_nl( a = (y_1*x1 - y1*x_1 + c*x_1 - c*x1)/(x_1*x_1*x1 - x1*x1*x_1); b = (y1 -a*x1*x1 - c)/x1; x = w_sample - w[m]; - + //printf("%f %f %f\n", w[0], w[1], w[2]); //printf("%f %f %f %f %f %f\n", x_1, y_1, 0.0, y0, x1, y1); log_amp = a*x*x + b*x + c; //printf("a %f b %f c %f\n", a, b, c); //printf("m=%d A[m-1] %f A[m] %f A[m+1] %f w_sample %f w[m] %f x %f log_amp %f\n", m, - // A[m-1], + // A[m-1], // A[m], A[m+1], w_sample, w[m], x, log_amp); //exit(0); return log_amp; @@ -254,20 +254,20 @@ float fres[] = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, /*---------------------------------------------------------------------------*\ FUNCTION....: resample_amp_nl() - AUTHOR......: David Rowe + AUTHOR......: David Rowe DATE CREATED: 7 March 2011 - - Converts the current model with L {Am} samples spaced Wo apart to + + Converts the current model with L {Am} samples spaced Wo apart to RES_POINTS samples spaced Wo/RES_POINTS apart. Then subtracts from the previous frames samples to get the delta. \*---------------------------------------------------------------------------*/ -void resample_amp_fixed(MODEL *model, +void resample_amp_fixed(MODEL *model, float w[], float A[], float wres[], float Ares[], - float AresdB_prev[], - float AresdB[], + float AresdB_prev[], + float AresdB[], float deltat[]) { int i; @@ -280,7 +280,7 @@ void resample_amp_fixed(MODEL *model, for(i=0; i<RES_POINTS; i++) { wres[i] = fres[i]*PI/4000.0; } - + for(i=0; i<RES_POINTS; i++) { Ares[i] = pow(10.0,sample_log_amp_quad_nl(w, A, model->L, wres[i])); } @@ -297,13 +297,13 @@ void resample_amp_fixed(MODEL *model, /*---------------------------------------------------------------------------*\ FUNCTION....: resample_amp_nl() - AUTHOR......: David Rowe + AUTHOR......: David Rowe DATE CREATED: 7 March 2011 - + Converts the current model with L {Am} samples spaced Wo apart to M samples spaced Wo/M apart. Then converts back to L {Am} samples. used to prototype constant rate Amplitude encoding ideas. - + Returns the SNR in dB. \*---------------------------------------------------------------------------*/ @@ -346,7 +346,7 @@ float resample_amp_nl(MODEL *model, int m, float AresdB_prev[]) #endif signal = noise = 0.0; - + for(i=1; i<model->L; i++) { new_A = pow(10.0,sample_log_amp_quad_nl(wres, Ares, RES_POINTS, model->Wo*i)); signal += pow(model->A[i], 2.0); @@ -364,13 +364,13 @@ float resample_amp_nl(MODEL *model, int m, float AresdB_prev[]) /*---------------------------------------------------------------------------*\ FUNCTION....: resample_amp() - AUTHOR......: David Rowe + AUTHOR......: David Rowe DATE CREATED: 10 March 2011 - + Converts the current model with L {Am} samples spaced Wo apart to M samples with a non-linear spacing. Then converts back to L {Am} samples. used to prototype constant rate Amplitude encoding ideas. - + Returns the SNR in dB. \*---------------------------------------------------------------------------*/ @@ -394,7 +394,7 @@ float resample_amp(MODEL *model, int m) //dump_resample(&model_m); signal = noise = 0.0; - + for(i=1; i<model->L/4; i++) { new_A = pow(10,sample_log_amp_quad(&model_m, i*model->Wo)); signal += pow(model->A[i], 2.0); @@ -411,10 +411,10 @@ float resample_amp(MODEL *model, int m) /*---------------------------------------------------------------------------*\ - FUNCTION....: interp_lsp() - AUTHOR......: David Rowe + FUNCTION....: interp_lsp() + AUTHOR......: David Rowe DATE CREATED: 10 Nov 2010 - + Given two frames decribed by model parameters 20ms apart, determines the model parameters of the 10ms frame between them. Assumes voicing is available for middle (interpolated) frame. Outputs are @@ -422,7 +422,7 @@ float resample_amp(MODEL *model, int m) This version uses interpolation of LSPs, seems to do a better job with bg noise. - + \*---------------------------------------------------------------------------*/ void interpolate_lsp( @@ -469,5 +469,5 @@ void interpolate_lsp( /* convert back to amplitudes */ lsp_to_lpc(lsps, ak_interp, LPC_ORD); - aks_to_M2(ak_interp, LPC_ORD, interp, e, &snr, 0); + aks_to_M2(ak_interp, LPC_ORD, interp, e, &snr, 0); } diff --git a/gr-vocoder/lib/codec2/interp.h b/gr-vocoder/lib/codec2/interp.h index d41eac3f8..d50972614 100644 --- a/gr-vocoder/lib/codec2/interp.h +++ b/gr-vocoder/lib/codec2/interp.h @@ -31,7 +31,7 @@ #define RES_POINTS 20 void interpolate(MODEL *interp, MODEL *prev, MODEL *next); -void interpolate_lsp(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); diff --git a/gr-vocoder/lib/codec2/kiss_fft.c b/gr-vocoder/lib/codec2/kiss_fft.c index 465d6c97a..17b4e7211 100644 --- a/gr-vocoder/lib/codec2/kiss_fft.c +++ b/gr-vocoder/lib/codec2/kiss_fft.c @@ -250,7 +250,7 @@ void kf_work( const kiss_fft_cpx * Fout_end = Fout + p*m; #ifdef _OPENMP - // use openmp extensions at the + // use openmp extensions at the // top-level (not recursive) if (fstride==1 && p<=5) { @@ -258,15 +258,15 @@ void kf_work( // execute the p different work units in different threads # pragma omp parallel for - for (k=0;k<p;++k) + for (k=0;k<p;++k) kf_work( Fout +k*m, f+ fstride*in_stride*k,fstride*p,in_stride,factors,st); // all threads have joined by this point switch (p) { case 2: kf_bfly2(Fout,fstride,st,m); break; - case 3: kf_bfly3(Fout,fstride,st,m); break; + case 3: kf_bfly3(Fout,fstride,st,m); break; case 4: kf_bfly4(Fout,fstride,st,m); break; - case 5: kf_bfly5(Fout,fstride,st,m); break; + case 5: kf_bfly5(Fout,fstride,st,m); break; default: kf_bfly_generic(Fout,fstride,st,m,p); break; } return; @@ -282,7 +282,7 @@ void kf_work( do{ // recursive call: // DFT of size m*p performed by doing - // p instances of smaller DFTs of size m, + // p instances of smaller DFTs of size m, // each one takes a decimated version of the input kf_work( Fout , f, fstride*p, in_stride, factors,st); f += fstride*in_stride; @@ -291,21 +291,21 @@ void kf_work( Fout=Fout_beg; - // recombine the p smaller DFTs + // recombine the p smaller DFTs switch (p) { case 2: kf_bfly2(Fout,fstride,st,m); break; - case 3: kf_bfly3(Fout,fstride,st,m); break; + case 3: kf_bfly3(Fout,fstride,st,m); break; case 4: kf_bfly4(Fout,fstride,st,m); break; - case 5: kf_bfly5(Fout,fstride,st,m); break; + case 5: kf_bfly5(Fout,fstride,st,m); break; default: kf_bfly_generic(Fout,fstride,st,m,p); break; } } /* facbuf is populated by p1,m1,p2,m2, ... - where + where p[i] * m[i] = m[i-1] m0 = n */ -static +static void kf_factor(int n,int * facbuf) { int p=4; diff --git a/gr-vocoder/lib/codec2/kiss_fft.h b/gr-vocoder/lib/codec2/kiss_fft.h index 64c50f4aa..c01722cad 100644 --- a/gr-vocoder/lib/codec2/kiss_fft.h +++ b/gr-vocoder/lib/codec2/kiss_fft.h @@ -28,17 +28,17 @@ extern "C" { # define kiss_fft_scalar __m128 #define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16) #define KISS_FFT_FREE _mm_free -#else +#else #define KISS_FFT_MALLOC malloc #define KISS_FFT_FREE free -#endif +#endif #ifdef FIXED_POINT -#include <sys/types.h> +#include <sys/types.h> # if (FIXED_POINT == 32) # define kiss_fft_scalar int32_t -# else +# else # define kiss_fft_scalar int16_t # endif #else @@ -55,9 +55,9 @@ typedef struct { typedef struct kiss_fft_state* kiss_fft_cfg; -/* +/* * kiss_fft_alloc - * + * * Initialize a FFT (or IFFT) algorithm's cfg/state buffer. * * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL); @@ -67,18 +67,18 @@ typedef struct kiss_fft_state* kiss_fft_cfg; * * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc. * The returned value should be free()d when done to avoid memory leaks. - * + * * The state can be placed in a user supplied buffer 'mem': * If lenmem is not NULL and mem is not NULL and *lenmem is large enough, * then the function places the cfg in mem and the size used in *lenmem * and returns mem. - * + * * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough), - * then the function returns NULL and places the minimum cfg + * then the function returns NULL and places the minimum cfg * buffer size in *lenmem. * */ -kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); +kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); /* * kiss_fft(cfg,in_out_buf) @@ -97,16 +97,16 @@ void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); * */ void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride); -/* If kiss_fft_alloc allocated a buffer, it is one contiguous +/* If kiss_fft_alloc allocated a buffer, it is one contiguous buffer and can be simply free()d when no longer needed*/ #define kiss_fft_free free /* - Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up + Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up your compiler output to call this before you exit. */ void kiss_fft_cleanup(void); - + /* * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5) @@ -118,7 +118,7 @@ int kiss_fft_next_fast_size(int n); (kiss_fft_next_fast_size( ((n)+1)>>1)<<1) #ifdef __cplusplus -} +} #endif #endif diff --git a/gr-vocoder/lib/codec2/lpc.c b/gr-vocoder/lib/codec2/lpc.c index ba8011377..1784f75ca 100644 --- a/gr-vocoder/lib/codec2/lpc.c +++ b/gr-vocoder/lib/codec2/lpc.c @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - - FILE........: lpc.c - AUTHOR......: David Rowe - DATE CREATED: 30/9/90 - - Linear Prediction functions written in C. - + + FILE........: lpc.c + AUTHOR......: David Rowe + DATE CREATED: 30/9/90 + + Linear Prediction functions written in C. + \*---------------------------------------------------------------------------*/ /* @@ -34,11 +34,11 @@ #include "lpc.h" /*---------------------------------------------------------------------------*\ - - hanning_window() - - Hanning windows a frame of speech samples. - + + hanning_window() + + Hanning windows a frame of speech samples. + \*---------------------------------------------------------------------------*/ void hanning_window( @@ -54,12 +54,12 @@ void hanning_window( } /*---------------------------------------------------------------------------*\ - - autocorrelate() - - Finds the first P autocorrelation values of an array of windowed speech - samples Sn[]. - + + autocorrelate() + + Finds the first P autocorrelation values of an array of windowed speech + samples Sn[]. + \*---------------------------------------------------------------------------*/ void autocorrelate( @@ -79,12 +79,12 @@ void autocorrelate( } /*---------------------------------------------------------------------------*\ - - autocorrelate_freq() - + + autocorrelate_freq() + Finds the first P autocorrelation values from an array of frequency domain - power samples. - + power samples. + \*---------------------------------------------------------------------------*/ void autocorrelate_freq( @@ -106,18 +106,18 @@ void autocorrelate_freq( } /*---------------------------------------------------------------------------*\ - - levinson_durbin() - - Given P+1 autocorrelation coefficients, finds P Linear Prediction Coeff. + + levinson_durbin() + + Given P+1 autocorrelation coefficients, finds P Linear Prediction Coeff. (LPCs) where P is the order of the LPC all-pole model. The Levinson-Durbin - algorithm is used, and is described in: - - J. Makhoul - "Linear prediction, a tutorial review" - Proceedings of the IEEE - Vol-63, No. 4, April 1975 - + algorithm is used, and is described in: + + J. Makhoul + "Linear prediction, a tutorial review" + Proceedings of the IEEE + Vol-63, No. 4, April 1975 + \*---------------------------------------------------------------------------*/ void levinson_durbin( @@ -152,18 +152,18 @@ void levinson_durbin( for(i=1; i<=order; i++) lpcs[i] = a[order][i]; - lpcs[0] = 1.0; + lpcs[0] = 1.0; } /*---------------------------------------------------------------------------*\ - - inverse_filter() - + + inverse_filter() + Inverse Filter, A(z). Produces an array of residual samples from an array - of input samples and linear prediction coefficients. - + of input samples and linear prediction coefficients. + The filter memory is stored in the first order samples of the input array. - + \*---------------------------------------------------------------------------*/ void inverse_filter( @@ -180,26 +180,26 @@ void inverse_filter( res[i] = 0.0; for(j=0; j<=order; j++) res[i] += Sn[i-j]*a[j]; - } + } } /*---------------------------------------------------------------------------*\ - - synthesis_filter() - - C version of the Speech Synthesis Filter, 1/A(z). Given an array of + + synthesis_filter() + + C version of the Speech Synthesis Filter, 1/A(z). Given an array of residual or excitation samples, and the the LP filter coefficients, this function will produce an array of speech samples. This filter structure is - IIR. - - The synthesis filter has memory as well, this is treated in the same way - as the memory for the inverse filter (see inverse_filter() notes above). - The difference is that the memory for the synthesis filter is stored in + IIR. + + The synthesis filter has memory as well, this is treated in the same way + as the memory for the inverse filter (see inverse_filter() notes above). + The difference is that the memory for the synthesis filter is stored in the output array, wheras the memory of the inverse filter is stored in the - input array. - - Note: the calling function must update the filter memory. - + input array. + + Note: the calling function must update the filter memory. + \*---------------------------------------------------------------------------*/ void synthesis_filter( @@ -222,12 +222,12 @@ void synthesis_filter( } /*---------------------------------------------------------------------------*\ - - find_aks() - - This function takes a frame of samples, and determines the linear - prediction coefficients for that frame of samples. - + + find_aks() + + This function takes a frame of samples, and determines the linear + prediction coefficients for that frame of samples. + \*---------------------------------------------------------------------------*/ void find_aks( @@ -257,11 +257,11 @@ void find_aks( } /*---------------------------------------------------------------------------*\ - - weight() - - Weights a vector of LPCs. - + + weight() + + Weights a vector of LPCs. + \*---------------------------------------------------------------------------*/ void weight( @@ -272,8 +272,8 @@ void weight( ) { int i; - + for(i=1; i<=order; i++) akw[i] = ak[i]*pow(gamma,(float)i); } - + diff --git a/gr-vocoder/lib/codec2/lpc.h b/gr-vocoder/lib/codec2/lpc.h index ead05e1ba..9125189d1 100644 --- a/gr-vocoder/lib/codec2/lpc.h +++ b/gr-vocoder/lib/codec2/lpc.h @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - - FILE........: lpc.h - AUTHOR......: David Rowe - DATE CREATED: 24/8/09 - - Linear Prediction functions written in C. - + + FILE........: lpc.h + AUTHOR......: David Rowe + DATE CREATED: 24/8/09 + + Linear Prediction functions written in C. + \*---------------------------------------------------------------------------*/ /* diff --git a/gr-vocoder/lib/codec2/lsp.c b/gr-vocoder/lib/codec2/lsp.c index 47001c1ef..b57507bb4 100644 --- a/gr-vocoder/lib/codec2/lsp.c +++ b/gr-vocoder/lib/codec2/lsp.c @@ -153,7 +153,7 @@ int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta) float Q[LSP_MAX_ORDER + 1]; float P[LSP_MAX_ORDER + 1]; - flag = 1; + flag = 1; m = lpcrdr/2; /* order of P'(z) & Q'(z) polynimials */ /* Allocate memory space for polynomials */ @@ -274,7 +274,7 @@ void lsp_to_lpc(float *lsp, float *ak, int lpcrdr) int m = lpcrdr/2; float freq[LSP_MAX_ORDER]; float Wp[(LSP_MAX_ORDER * 4) + 2]; - + /* convert from radians to the x=cos(w) domain */ for(i=0; i<lpcrdr; i++) diff --git a/gr-vocoder/lib/codec2/nlp.c b/gr-vocoder/lib/codec2/nlp.c index 42ae90919..0d5e530ce 100644 --- a/gr-vocoder/lib/codec2/nlp.c +++ b/gr-vocoder/lib/codec2/nlp.c @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - - FILE........: nlp.c - AUTHOR......: David Rowe - DATE CREATED: 23/3/93 - - Non Linear Pitch (NLP) estimation functions. - + + FILE........: nlp.c + AUTHOR......: David Rowe + DATE CREATED: 23/3/93 + + Non Linear Pitch (NLP) estimation functions. + \*---------------------------------------------------------------------------*/ /* @@ -35,9 +35,9 @@ #include <stdlib.h> /*---------------------------------------------------------------------------*\ - - DEFINES - + + DEFINES + \*---------------------------------------------------------------------------*/ #define PMAX_M 600 /* maximum NLP analysis window size */ @@ -52,9 +52,9 @@ #define NLP_NTAP 48 /* Decimation LPF order */ /*---------------------------------------------------------------------------*\ - - GLOBALS - + + GLOBALS + \*---------------------------------------------------------------------------*/ /* 48 tap 600Hz low pass FIR filter coefficients */ @@ -117,14 +117,14 @@ typedef struct { } NLP; float post_process_mbe(COMP Fw[], int pmin, int pmax, float gmax); -float post_process_sub_multiples(COMP Fw[], +float post_process_sub_multiples(COMP Fw[], int pmin, int pmax, float gmax, int gmax_bin, float *prev_Wo); /*---------------------------------------------------------------------------*\ - - nlp_create() - + + nlp_create() + Initialisation function for NLP pitch estimator. \*---------------------------------------------------------------------------*/ @@ -149,9 +149,9 @@ void *nlp_create() } /*---------------------------------------------------------------------------*\ - + nlp_destory() - + Initialisation function for NLP pitch estimator. \*---------------------------------------------------------------------------*/ @@ -163,9 +163,9 @@ void nlp_destroy(void *nlp_state) } /*---------------------------------------------------------------------------*\ - - nlp() - + + nlp() + Determines the pitch in samples using the Non Linear Pitch (NLP) algorithm [1]. Returns the fundamental in Hz. Note that the actual pitch estimate is for the centre of the M sample Sn[] vector, not @@ -189,11 +189,11 @@ void nlp_destroy(void *nlp_state) References: [1] http://www.itr.unisa.edu.au/~steven/thesis/dgr.pdf Chapter 4 - + \*---------------------------------------------------------------------------*/ float nlp( - void *nlp_state, + void *nlp_state, float Sn[], /* input speech vector */ int n, /* frames shift (no. new samples in Sn[]) */ int m, /* analysis window size */ @@ -271,7 +271,7 @@ float nlp( } } - best_f0 = post_process_sub_multiples(Fw, pmin, pmax, gmax, gmax_bin, + best_f0 = post_process_sub_multiples(Fw, pmin, pmax, gmax, gmax_bin, prev_Wo); /* Shift samples in buffer to make room for new samples */ @@ -282,13 +282,13 @@ float nlp( /* return pitch and F0 estimate */ *pitch = (float)SAMPLE_RATE/best_f0; - return(best_f0); + return(best_f0); } /*---------------------------------------------------------------------------*\ - - post_process_sub_multiples() - + + post_process_sub_multiples() + Given the global maximma of Fw[] we search interger submultiples for local maxima. If local maxima exist and they are above an experimentally derived threshold (OK a magic number I pulled out of @@ -306,7 +306,7 @@ float nlp( \*---------------------------------------------------------------------------*/ -float post_process_sub_multiples(COMP Fw[], +float post_process_sub_multiples(COMP Fw[], int pmin, int pmax, float gmax, int gmax_bin, float *prev_Wo) { @@ -361,4 +361,4 @@ float post_process_sub_multiples(COMP Fw[], return best_f0; } - + diff --git a/gr-vocoder/lib/codec2/nlp.h b/gr-vocoder/lib/codec2/nlp.h index 88a3733dc..5e11f1186 100644 --- a/gr-vocoder/lib/codec2/nlp.h +++ b/gr-vocoder/lib/codec2/nlp.h @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - - FILE........: nlp.c - AUTHOR......: David Rowe - DATE CREATED: 23/3/93 - - Non Linear Pitch (NLP) estimation functions. - + + FILE........: nlp.c + AUTHOR......: David Rowe + DATE CREATED: 23/3/93 + + Non Linear Pitch (NLP) estimation functions. + \*---------------------------------------------------------------------------*/ /* @@ -32,7 +32,7 @@ void *nlp_create(); void nlp_destroy(void *nlp_state); -float nlp(void *nlp_state, float Sn[], int n, int m, int pmin, int pmax, +float nlp(void *nlp_state, 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_[]); diff --git a/gr-vocoder/lib/codec2/pack.c b/gr-vocoder/lib/codec2/pack.c index 31551dfc4..e04c9378c 100644 --- a/gr-vocoder/lib/codec2/pack.c +++ b/gr-vocoder/lib/codec2/pack.c @@ -65,7 +65,7 @@ pack( bitArray[wordIndex] |= ((unsigned char)((field >> (fieldWidth - sliceWidth)) << (bitsLeft - sliceWidth))); - + *bitIndex = bI + sliceWidth; fieldWidth -= sliceWidth; } while ( fieldWidth != 0 ); @@ -91,7 +91,7 @@ unpack( bitsLeft < fieldWidth ? bitsLeft : fieldWidth; field |= (((bitArray[bI >> ShiftRight] >> (bitsLeft - sliceWidth)) & ((1 << sliceWidth) - 1)) << (fieldWidth - sliceWidth)); - + *bitIndex = bI + sliceWidth; fieldWidth -= sliceWidth; } while ( fieldWidth != 0 ); diff --git a/gr-vocoder/lib/codec2/phase.c b/gr-vocoder/lib/codec2/phase.c index 0e1a14a60..69cc6697f 100644 --- a/gr-vocoder/lib/codec2/phase.c +++ b/gr-vocoder/lib/codec2/phase.c @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - - FILE........: phase.c - AUTHOR......: David Rowe - DATE CREATED: 1/2/09 - + + FILE........: phase.c + AUTHOR......: David Rowe + DATE CREATED: 1/2/09 + Functions for modelling and synthesising phase. - + \*---------------------------------------------------------------------------*/ /* @@ -22,7 +22,7 @@ License for more details. You should have received a copy of the GNU Lesser General Public License - along with this program; if not,see <http://www.gnu.org/licenses/>. + along with this program; if not,see <http://www.gnu.org/licenses/>. */ #include "defines.h" @@ -101,14 +101,14 @@ void aks_to_H( phase_synth_zero_order() - Synthesises phases based on SNR and a rule based approach. No phase + Synthesises phases based on SNR and a rule based approach. No phase parameters are required apart from the SNR (which can be reduced to a 1 bit V/UV decision per frame). The phase of each harmonic is modelled as the phase of a LPC synthesis filter excited by an impulse. Unlike the first order model the position of the impulse is not transmitted, so we create - an excitation pulse train using a rule based approach. + an excitation pulse train using a rule based approach. Consider a pulse train with a pulse starting time n=0, with pulses repeated at a rate of Wo, the fundamental frequency. A pulse train @@ -149,10 +149,10 @@ void aks_to_H( This E[m] then gets passed through the LPC synthesis filter to determine the final harmonic phase. - + Comparing to speech synthesised using original phases: - - Through headphones speech synthesised with this model is not as + - Through headphones speech synthesised with this model is not as good. Through a loudspeaker it is very close to original phases. - If there are voicing errors, the speech can sound clicky or @@ -207,21 +207,21 @@ void phase_synth_zero_order( G = 1.0; aks_to_H(model, aks, G, H, order); - /* + /* Update excitation fundamental phase track, this sets the position of each pitch pulse during voiced speech. After much experiment I found that using just this frame's Wo improved quality for UV sounds compared to interpolating two frames Wo like this: - + ex_phase[0] += (*prev_Wo+mode->Wo)*N/2; */ - + ex_phase[0] += (model->Wo)*N; ex_phase[0] -= TWO_PI*floor(ex_phase[0]/TWO_PI + 0.5); r = TWO_PI/GLOTTAL_FFT_SIZE; for(m=1; m<=model->L; m++) { - + /* generate excitation */ if (model->voiced) { @@ -254,7 +254,7 @@ void phase_synth_zero_order( A_[m].imag = H[m].imag*Ex[m].real + H[m].real*Ex[m].imag; /* modify sinusoidal phase */ - + new_phi = atan2(A_[m].imag, A_[m].real+1E-12); model->phi[m] = new_phi; } diff --git a/gr-vocoder/lib/codec2/phase.h b/gr-vocoder/lib/codec2/phase.h index 833bc7cdc..4f1a62089 100644 --- a/gr-vocoder/lib/codec2/phase.h +++ b/gr-vocoder/lib/codec2/phase.h @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - - FILE........: phase.h - AUTHOR......: David Rowe - DATE CREATED: 1/2/09 - + + FILE........: phase.h + AUTHOR......: David Rowe + DATE CREATED: 1/2/09 + Functions for modelling phase. - + \*---------------------------------------------------------------------------*/ /* @@ -28,7 +28,7 @@ #ifndef __PHASE__ #define __PHASE__ -void phase_synth_zero_order(MODEL *model, float aks[], float *ex_phase, +void phase_synth_zero_order(MODEL *model, float aks[], float *ex_phase, int order); #endif diff --git a/gr-vocoder/lib/codec2/postfilter.c b/gr-vocoder/lib/codec2/postfilter.c index 6e17eeb87..05d77c845 100644 --- a/gr-vocoder/lib/codec2/postfilter.c +++ b/gr-vocoder/lib/codec2/postfilter.c @@ -1,13 +1,13 @@ /*---------------------------------------------------------------------------*\ - + FILE........: postfilter.c - AUTHOR......: David Rowe + AUTHOR......: David Rowe DATE CREATED: 13/09/09 - + Postfilter to improve sound quality for speech with high levels of background noise. Unlike mixed-excitation models requires no bits to be transmitted to handle background noise. - + \*---------------------------------------------------------------------------*/ /* @@ -71,7 +71,7 @@ This idea is rather experimental. Some potential problems that may happen: - + 1/ If someone says "aaaaaaaahhhhhhhhh" will background estimator track up to speech level? This would be a bad thing. @@ -88,13 +88,13 @@ 5/ Not sure what happens during long periods of voiced speech e.g. "sshhhhhhh" - + \*---------------------------------------------------------------------------*/ void postfilter( MODEL *model, float *bg_est -) +) { int m, uv; float e; diff --git a/gr-vocoder/lib/codec2/postfilter.h b/gr-vocoder/lib/codec2/postfilter.h index bf080b1b6..156714e54 100644 --- a/gr-vocoder/lib/codec2/postfilter.h +++ b/gr-vocoder/lib/codec2/postfilter.h @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - + FILE........: postfilter.h - AUTHOR......: David Rowe + AUTHOR......: David Rowe DATE CREATED: 13/09/09 - + Postfilter header file. - + \*---------------------------------------------------------------------------*/ /* diff --git a/gr-vocoder/lib/codec2/quantise.c b/gr-vocoder/lib/codec2/quantise.c index ff8d156b5..c09803099 100644 --- a/gr-vocoder/lib/codec2/quantise.c +++ b/gr-vocoder/lib/codec2/quantise.c @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - + FILE........: quantise.c - AUTHOR......: David Rowe - DATE CREATED: 31/5/92 - - Quantisation functions for the sinusoidal coder. - + AUTHOR......: David Rowe + DATE CREATED: 31/5/92 + + Quantisation functions for the sinusoidal coder. + \*---------------------------------------------------------------------------*/ /* @@ -41,16 +41,16 @@ #define LSP_DELTA1 0.01 /* grid spacing for LSP root searches */ /*---------------------------------------------------------------------------*\ - + FUNCTION HEADERS \*---------------------------------------------------------------------------*/ -float speech_to_uq_lsps(float lsp[], float ak[], float Sn[], float w[], +float speech_to_uq_lsps(float lsp[], float ak[], float Sn[], float w[], int order); /*---------------------------------------------------------------------------*\ - + FUNCTIONS \*---------------------------------------------------------------------------*/ @@ -61,7 +61,7 @@ int lsp_bits(int i) { #if VECTOR_QUANTISATION /*---------------------------------------------------------------------------*\ - + quantise_uniform Simulates uniform quantising of a float. @@ -146,7 +146,7 @@ long quantise(const float * cb, float vec[], float w[], int k, int m, float *se) } /*---------------------------------------------------------------------------*\ - + lspd_quantise Scalar lsp difference quantiser. @@ -154,10 +154,10 @@ long quantise(const float * cb, float vec[], float w[], int k, int m, float *se) \*---------------------------------------------------------------------------*/ void lspd_quantise( - float lsp[], + float lsp[], float lsp_[], int order -) +) { int i,k,m; float lsp_hz[LPC_MAX]; @@ -183,8 +183,8 @@ void lspd_quantise( wt[0] = 1.0; for(i=0; i<order; i++) { - if (i) - dlsp[i] = lsp_hz[i] - lsp__hz[i-1]; + if (i) + dlsp[i] = lsp_hz[i] - lsp__hz[i-1]; else dlsp[0] = lsp_hz[0]; @@ -194,14 +194,14 @@ void lspd_quantise( indexes[i] = quantise(cb, &dlsp[i], wt, k, m, &se); dlsp_[i] = cb[indexes[i]*k]; - if (i) + if (i) lsp__hz[i] = lsp__hz[i-1] + dlsp_[i]; else lsp__hz[0] = dlsp_[0]; } for(; i<order; i++) lsp__hz[i] = lsp__hz[i-1] + dlsp[i]; - + /* convert back to radians */ for(i=0; i<order; i++) @@ -209,7 +209,7 @@ void lspd_quantise( } /*---------------------------------------------------------------------------*\ - + lspd_vq_quantise Vector lsp difference quantiser. @@ -217,10 +217,10 @@ void lspd_quantise( \*---------------------------------------------------------------------------*/ void lspdvq_quantise( - float lsp[], + float lsp[], float lsp_[], int order -) +) { int i,k,m,ncb, nlsp; float dlsp[LPC_MAX]; @@ -243,8 +243,8 @@ void lspdvq_quantise( /* scalar quantise dLSPs 1,2,3,4,5 */ for(i=0; i<5; i++) { - if (i) - dlsp[i] = (lsp[i] - lsp_[i-1])*4000.0/PI; + if (i) + dlsp[i] = (lsp[i] - lsp_[i-1])*4000.0/PI; else dlsp[0] = lsp[0]*4000.0/PI; @@ -253,8 +253,8 @@ void lspdvq_quantise( cb = lsp_cbdvq[i].cb; index = quantise(cb, &dlsp[i], wt, k, m, &se); dlsp_[i] = cb[index*k]*PI/4000.0; - - if (i) + + if (i) lsp_[i] = lsp_[i-1] + dlsp_[i]; else lsp_[0] = dlsp_[0]; @@ -330,7 +330,7 @@ void force_min_lsp_dist(float lsp[], int lpc_order) } /*---------------------------------------------------------------------------*\ - + lpc_model_amplitudes Derive a LPC model for amplitude samples then estimate amplitude samples @@ -342,7 +342,7 @@ void force_min_lsp_dist(float lsp[], int lpc_order) float lpc_model_amplitudes( float Sn[], /* Input frame of speech samples */ - float w[], + float w[], MODEL *model, /* sinusoidal model parameters */ int order, /* LPC model order */ int lsp_quant, /* optional LSP quantisation if non-zero */ @@ -353,7 +353,7 @@ float lpc_model_amplitudes( float R[LPC_MAX+1]; float E; int i,j; - float snr; + float snr; float lsp[LPC_MAX]; float lsp_hz[LPC_MAX]; float lsp_[LPC_MAX]; @@ -368,11 +368,11 @@ float lpc_model_amplitudes( Wn[i] = Sn[i]*w[i]; autocorrelate(Wn,R,M,order); levinson_durbin(R,ak,order); - + E = 0.0; for(i=0; i<=order; i++) E += ak[i]*R[i]; - + for(i=0; i<order; i++) wt[i] = 1.0; @@ -386,7 +386,7 @@ float lpc_model_amplitudes( for(i=0; i<order; i++) lsp_hz[i] = (4000.0/PI)*lsp[i]; - + /* simple uniform scalar quantisers */ for(i=0; i<10; i++) { @@ -396,7 +396,7 @@ float lpc_model_amplitudes( index = quantise(cb, &lsp_hz[i], wt, k, m, &se); lsp_hz[i] = cb[index*k]; } - + /* experiment: simulating uniform quantisation error for(i=0; i<order; i++) lsp[i] += PI*(12.5/4000.0)*(1.0 - 2.0*(float)rand()/RAND_MAX); @@ -428,7 +428,7 @@ float lpc_model_amplitudes( lsp[i] = lsp[i-1] + PI*(75.0/4000.0); } - for(j=0; j<order; j++) + for(j=0; j<order; j++) lsp_[j] = lsp[j]; lsp_to_lpc(lsp_, ak, order); @@ -455,13 +455,13 @@ float lpc_model_amplitudes( } /*---------------------------------------------------------------------------*\ - - aks_to_M2() - - Transforms the linear prediction coefficients to spectral amplitude - samples. This function determines A(m) from the average energy per - band using an FFT. - + + aks_to_M2() + + Transforms the linear prediction coefficients to spectral amplitude + samples. This function determines A(m) from the average energy per + band using an FFT. + \*---------------------------------------------------------------------------*/ void aks_to_M2( @@ -487,7 +487,7 @@ void aks_to_M2( for(i=0; i<FFT_DEC; i++) { Pw[i].real = 0.0; - Pw[i].imag = 0.0; + Pw[i].imag = 0.0; } for(i=0; i<=order; i++) @@ -499,7 +499,7 @@ void aks_to_M2( for(i=0; i<FFT_DEC/2; i++) Pw[i].real = E/(Pw[i].real*Pw[i].real + Pw[i].imag*Pw[i].imag); #ifdef DUMP - if (dump) + if (dump) dump_Pw(Pw); #endif @@ -523,10 +523,10 @@ void aks_to_M2( } /*---------------------------------------------------------------------------*\ - - FUNCTION....: encode_Wo() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 + + FUNCTION....: encode_Wo() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 Encodes Wo using a WO_LEVELS quantiser. @@ -548,10 +548,10 @@ int encode_Wo(float Wo) } /*---------------------------------------------------------------------------*\ - - FUNCTION....: decode_Wo() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 + + FUNCTION....: decode_Wo() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 Decodes Wo using a WO_LEVELS quantiser. @@ -571,10 +571,10 @@ float decode_Wo(int index) } /*---------------------------------------------------------------------------*\ - - FUNCTION....: speech_to_uq_lsps() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 + + FUNCTION....: speech_to_uq_lsps() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 Analyse a windowed frame of time domain speech to determine LPCs which are the converted to LSPs for quantisation and transmission @@ -584,7 +584,7 @@ float decode_Wo(int index) float speech_to_uq_lsps(float lsp[], float ak[], - float Sn[], + float Sn[], float w[], int order ) @@ -598,19 +598,19 @@ float speech_to_uq_lsps(float lsp[], Wn[i] = Sn[i]*w[i]; autocorrelate(Wn, R, M, order); levinson_durbin(R, ak, order); - + E = 0.0; for(i=0; i<=order; i++) E += ak[i]*R[i]; - + roots = lpc_to_lsp(ak, order, lsp, 5, LSP_DELTA1); if (roots != order) { /* for some reason LSP roots could not be found */ /* some alpha testers are reporting this condition */ fprintf(stderr, "LSP roots not found!\nroots = %d\n", roots); for(i=0; i<=order; i++) - fprintf(stderr, "a[%d] = %f\n", i, ak[i]); - + fprintf(stderr, "a[%d] = %f\n", i, ak[i]); + /* some benign LSP values we can use instead */ for(i=0; i<order; i++) lsp[i] = (PI/order)*(float)i; @@ -620,10 +620,10 @@ float speech_to_uq_lsps(float lsp[], } /*---------------------------------------------------------------------------*\ - - FUNCTION....: encode_lsps() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 + + FUNCTION....: encode_lsps() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 From a vector of unquantised (floating point) LSPs finds the quantised LSP indexes. @@ -643,7 +643,7 @@ void encode_lsps(int indexes[], float lsp[], int order) for(i=0; i<order; i++) lsp_hz[i] = (4000.0/PI)*lsp[i]; - + /* simple uniform scalar quantisers */ wt[0] = 1.0; @@ -656,10 +656,10 @@ void encode_lsps(int indexes[], float lsp[], int order) } /*---------------------------------------------------------------------------*\ - - FUNCTION....: decode_lsps() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 + + FUNCTION....: decode_lsps() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 From a vector of quantised LSP indexes, returns the quantised (floating point) LSPs. @@ -685,10 +685,10 @@ void decode_lsps(float lsp[], int indexes[], int order) } /*---------------------------------------------------------------------------*\ - - FUNCTION....: bw_expand_lsps() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 + + FUNCTION....: bw_expand_lsps() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 Applies Bandwidth Expansion (BW) to a vector of LSPs. Prevents any two LSPs getting too close together after quantisation. We know @@ -724,10 +724,10 @@ void bw_expand_lsps(float lsp[], } /*---------------------------------------------------------------------------*\ - - FUNCTION....: apply_lpc_correction() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 + + FUNCTION....: apply_lpc_correction() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 Apply first harmonic LPC correction at decoder. This helps improve low pitch males after LPC modelling, like hts1a and morig. @@ -742,10 +742,10 @@ void apply_lpc_correction(MODEL *model) } /*---------------------------------------------------------------------------*\ - - FUNCTION....: encode_energy() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 + + FUNCTION....: encode_energy() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 Encodes LPC energy using an E_LEVELS quantiser. @@ -768,10 +768,10 @@ int encode_energy(float e) } /*---------------------------------------------------------------------------*\ - - FUNCTION....: decode_energy() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 + + FUNCTION....: decode_energy() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 Decodes energy using a WO_BITS quantiser. @@ -792,10 +792,10 @@ float decode_energy(int index) } /*---------------------------------------------------------------------------*\ - - FUNCTION....: encode_amplitudes() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 + + FUNCTION....: encode_amplitudes() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 Time domain LPC is used model the amplitudes which are then converted to LSPs and quantised. So we don't actually encode the @@ -804,10 +804,10 @@ float decode_energy(int index) \*---------------------------------------------------------------------------*/ -void encode_amplitudes(int lsp_indexes[], +void encode_amplitudes(int lsp_indexes[], int *energy_index, - MODEL *model, - float Sn[], + MODEL *model, + float Sn[], float w[]) { float lsps[LPC_ORD]; @@ -820,19 +820,19 @@ void encode_amplitudes(int lsp_indexes[], } /*---------------------------------------------------------------------------*\ - - FUNCTION....: decode_amplitudes() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 + + FUNCTION....: decode_amplitudes() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 Given the amplitude quantiser indexes recovers the harmonic amplitudes. \*---------------------------------------------------------------------------*/ -float decode_amplitudes(MODEL *model, +float decode_amplitudes(MODEL *model, float ak[], - int lsp_indexes[], + int lsp_indexes[], int energy_index, float lsps[], float *e @@ -844,7 +844,7 @@ float decode_amplitudes(MODEL *model, bw_expand_lsps(lsps, LPC_ORD); lsp_to_lpc(lsps, ak, LPC_ORD); *e = decode_energy(energy_index); - aks_to_M2(ak, LPC_ORD, model, *e, &snr, 1); + aks_to_M2(ak, LPC_ORD, model, *e, &snr, 1); apply_lpc_correction(model); return snr; diff --git a/gr-vocoder/lib/codec2/quantise.h b/gr-vocoder/lib/codec2/quantise.h index 90a3661ff..42b05f43b 100644 --- a/gr-vocoder/lib/codec2/quantise.h +++ b/gr-vocoder/lib/codec2/quantise.h @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - + FILE........: quantise.h - AUTHOR......: David Rowe - DATE CREATED: 31/5/92 - - Quantisation functions for the sinusoidal coder. - + AUTHOR......: David Rowe + DATE CREATED: 31/5/92 + + Quantisation functions for the sinusoidal coder. + \*---------------------------------------------------------------------------*/ /* @@ -36,7 +36,7 @@ void quantise_init(); float lpc_model_amplitudes(float Sn[], float w[], MODEL *model, int order, int lsp,float ak[]); -void aks_to_M2(float ak[], int order, MODEL *model, float E, float *snr, +void aks_to_M2(float ak[], int order, MODEL *model, float E, float *snr, int dump); int encode_Wo(float Wo); @@ -45,15 +45,15 @@ float decode_Wo(int index); void encode_lsps(int indexes[], float lsp[], int order); void decode_lsps(float lsp[], int indexes[], int order); void lspd_quantise(float lsp[], float lsp_[], int order); -void lspdvq_quantise(float lsp[], float lsp_[], int order); +void lspdvq_quantise(float lsp[], float lsp_[], int order); int encode_energy(float e); float decode_energy(int index); -void encode_amplitudes(int lsp_indexes[], +void encode_amplitudes(int lsp_indexes[], int *energy_index, - MODEL *model, - float Sn[], + MODEL *model, + float Sn[], float w[]); float decode_amplitudes(MODEL *model, @@ -71,7 +71,7 @@ int lsp_bits(int i); void apply_lpc_correction(MODEL *model); float speech_to_uq_lsps(float lsp[], float ak[], - float Sn[], + float Sn[], float w[], int order ); diff --git a/gr-vocoder/lib/codec2/sine.c b/gr-vocoder/lib/codec2/sine.c index 45cc9de71..b30f9abad 100644 --- a/gr-vocoder/lib/codec2/sine.c +++ b/gr-vocoder/lib/codec2/sine.c @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - + FILE........: sine.c - AUTHOR......: David Rowe + AUTHOR......: David Rowe DATE CREATED: 19/8/2010 - + Sinusoidal analysis and synthesis functions. - + \*---------------------------------------------------------------------------*/ /* @@ -26,9 +26,9 @@ */ /*---------------------------------------------------------------------------*\ - - INCLUDES - + + INCLUDES + \*---------------------------------------------------------------------------*/ #include <stdlib.h> @@ -42,25 +42,25 @@ #define HPF_BETA 0.125 /*---------------------------------------------------------------------------*\ - - HEADERS - + + HEADERS + \*---------------------------------------------------------------------------*/ -void hs_pitch_refinement(MODEL *model, COMP Sw[], float pmin, float pmax, +void hs_pitch_refinement(MODEL *model, COMP Sw[], float pmin, float pmax, float pstep); /*---------------------------------------------------------------------------*\ - - FUNCTIONS - + + FUNCTIONS + \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ - - FUNCTION....: make_analysis_window - AUTHOR......: David Rowe - DATE CREATED: 11/5/94 + + FUNCTION....: make_analysis_window + AUTHOR......: David Rowe + DATE CREATED: 11/5/94 Init function that generates the time domain analysis window and it's DFT. @@ -72,15 +72,15 @@ void make_analysis_window(float w[],COMP W[]) COMP temp; int i,j; - /* + /* Generate Hamming window centered on M-sample pitch analysis window - + 0 M/2 M-1 |-------------|-------------| |-------|-------| NW samples - All our analysis/synthsis is centred on the M/2 sample. + All our analysis/synthsis is centred on the M/2 sample. */ m = 0.0; @@ -92,7 +92,7 @@ void make_analysis_window(float w[],COMP W[]) } for(i=M/2+NW/2; i<M; i++) w[i] = 0.0; - + /* Normalise - makes freq domain amplitude estimation straight forward */ @@ -101,7 +101,7 @@ void make_analysis_window(float w[],COMP W[]) w[i] *= m; } - /* + /* Generate DFT of analysis window, used for later processing. Note we modulo FFT_ENC shift the time domain window w[], this makes the imaginary part of the DFT W[] equal to zero as the shifted w[] is @@ -112,13 +112,13 @@ void make_analysis_window(float w[],COMP W[]) |-------------------------| ----\ /---- - \ / + \ / \ / <- shifted version of window w[n] \ / \ / ------- - |---------| |---------| + |---------| |---------| NW/2 NW/2 */ @@ -133,8 +133,8 @@ void make_analysis_window(float w[],COMP W[]) fft(&W[0].real,FFT_ENC,-1); /* "Numerical Recipes in C" FFT */ - /* - Re-arrange W[] to be symmetrical about FFT_ENC/2. Makes later + /* + Re-arrange W[] to be symmetrical about FFT_ENC/2. Makes later analysis convenient. Before: @@ -142,21 +142,21 @@ void make_analysis_window(float w[],COMP W[]) 0 FFT_ENC-1 |----------|---------| - __ _ - \ / - \_______________/ + __ _ + \ / + \_______________/ After: 0 FFT_ENC-1 |----------|---------| - ___ - / \ - ________/ \_______ + ___ + / \ + ________/ \_______ */ - - + + for(i=0; i<FFT_ENC/2; i++) { temp.real = W[i].real; temp.imag = W[i].imag; @@ -169,15 +169,15 @@ void make_analysis_window(float w[],COMP W[]) } /*---------------------------------------------------------------------------*\ - - FUNCTION....: hpf - AUTHOR......: David Rowe + + FUNCTION....: hpf + AUTHOR......: David Rowe DATE CREATED: 16 Nov 2010 High pass filter with a -3dB point of about 160Hz. y(n) = -HPF_BETA*y(n-1) + x(n) - x(n-1) - + \*---------------------------------------------------------------------------*/ float hpf(float x, float states[]) @@ -189,10 +189,10 @@ float hpf(float x, float states[]) } /*---------------------------------------------------------------------------*\ - - FUNCTION....: dft_speech - AUTHOR......: David Rowe - DATE CREATED: 27/5/94 + + FUNCTION....: dft_speech + AUTHOR......: David Rowe + DATE CREATED: 27/5/94 Finds the DFT of the current speech input speech frame. @@ -201,7 +201,7 @@ float hpf(float x, float states[]) void dft_speech(COMP Sw[], float Sn[], float w[]) { int i; - + for(i=0; i<FFT_ENC; i++) { Sw[i].real = 0.0; Sw[i].imag = 0.0; @@ -209,7 +209,7 @@ void dft_speech(COMP Sw[], float Sn[], float w[]) /* Centre analysis window on time axis, we need to arrange input to FFT this way to make FFT phases correct */ - + /* move 2nd half to start of FFT input vector */ for(i=0; i<NW/2; i++) @@ -224,10 +224,10 @@ void dft_speech(COMP Sw[], float Sn[], float w[]) } /*---------------------------------------------------------------------------*\ - - FUNCTION....: two_stage_pitch_refinement + + FUNCTION....: two_stage_pitch_refinement AUTHOR......: David Rowe - DATE CREATED: 27/5/94 + DATE CREATED: 27/5/94 Refines the current pitch estimate using the harmonic sum pitch estimation technique. @@ -236,7 +236,7 @@ void dft_speech(COMP Sw[], float Sn[], float w[]) void two_stage_pitch_refinement(MODEL *model, COMP Sw[]) { - float pmin,pmax,pstep; /* pitch refinment minimum, maximum and step */ + float pmin,pmax,pstep; /* pitch refinment minimum, maximum and step */ /* Coarse refinement */ @@ -244,16 +244,16 @@ void two_stage_pitch_refinement(MODEL *model, COMP Sw[]) pmin = TWO_PI/model->Wo - 5; pstep = 1.0; hs_pitch_refinement(model,Sw,pmin,pmax,pstep); - + /* Fine refinement */ - + pmax = TWO_PI/model->Wo + 1; pmin = TWO_PI/model->Wo - 1; pstep = 0.25; hs_pitch_refinement(model,Sw,pmin,pmax,pstep); - + /* Limit range */ - + if (model->Wo < TWO_PI/P_MAX) model->Wo = TWO_PI/P_MAX; if (model->Wo > TWO_PI/P_MIN) @@ -263,20 +263,20 @@ void two_stage_pitch_refinement(MODEL *model, COMP Sw[]) } /*---------------------------------------------------------------------------*\ - - FUNCTION....: hs_pitch_refinement - AUTHOR......: David Rowe - DATE CREATED: 27/5/94 - - Harmonic sum pitch refinement function. - - pmin pitch search range minimum - pmax pitch search range maximum - step pitch search step size - model current pitch estimate in model.Wo - - model refined pitch estimate in model.Wo - + + FUNCTION....: hs_pitch_refinement + AUTHOR......: David Rowe + DATE CREATED: 27/5/94 + + Harmonic sum pitch refinement function. + + pmin pitch search range minimum + pmax pitch search range maximum + step pitch search step size + model current pitch estimate in model.Wo + + model refined pitch estimate in model.Wo + \*---------------------------------------------------------------------------*/ void hs_pitch_refinement(MODEL *model, COMP Sw[], float pmin, float pmax, float pstep) @@ -289,14 +289,14 @@ void hs_pitch_refinement(MODEL *model, COMP Sw[], float pmin, float pmax, float float Em; /* mamimum energy */ float r; /* number of rads/bin */ float p; /* current pitch */ - + /* Initialisation */ - + model->L = PI/model->Wo; /* use initial pitch est. for L */ Wom = model->Wo; Em = 0.0; r = TWO_PI/FFT_ENC; - + /* Determine harmonic sum for a range of Wo values */ for(p=pmin; p<=pmax; p+=pstep) { @@ -308,10 +308,10 @@ void hs_pitch_refinement(MODEL *model, COMP Sw[], float pmin, float pmax, float for(m=1; m<=model->L; m++) { b = floor(m*Wo/r + 0.5); E += Sw[b].real*Sw[b].real + Sw[b].imag*Sw[b].imag; - } + } /* Compare to see if this is a maximum */ - + if (E > Em) { Em = E; Wom = Wo; @@ -322,13 +322,13 @@ void hs_pitch_refinement(MODEL *model, COMP Sw[], float pmin, float pmax, float } /*---------------------------------------------------------------------------*\ - - FUNCTION....: estimate_amplitudes - AUTHOR......: David Rowe - DATE CREATED: 27/5/94 - - Estimates the complex amplitudes of the harmonics. - + + FUNCTION....: estimate_amplitudes + AUTHOR......: David Rowe + DATE CREATED: 27/5/94 + + Estimates the complex amplitudes of the harmonics. + \*---------------------------------------------------------------------------*/ void estimate_amplitudes(MODEL *model, COMP Sw[], COMP W[]) @@ -369,14 +369,14 @@ void estimate_amplitudes(MODEL *model, COMP Sw[], COMP W[]) } /*---------------------------------------------------------------------------*\ - - est_voicing_mbe() - + + est_voicing_mbe() + Returns the error of the MBE cost function for a fiven F0. Note: I think a lot of the operations below can be simplified as W[].imag = 0 and has been normalised such that den always equals 1. - + \*---------------------------------------------------------------------------*/ float est_voicing_mbe( @@ -393,7 +393,7 @@ float est_voicing_mbe( int offset; /* centers Hw[] about current harmonic */ float den; /* denominator of Am expression */ float error; /* accumulated error between original and synthesised */ - float Wo; + float Wo; float sig, snr; float elow, ehigh, eratio; float dF0, sixty; @@ -445,16 +445,16 @@ float est_voicing_mbe( error += Ew[m].imag*Ew[m].imag; } } - + snr = 10.0*log10(sig/error); if (snr > V_THRESH) model->voiced = 1; else model->voiced = 0; - + /* post processing, helps clean up some voicing errors ------------------*/ - /* + /* Determine the ratio of low freancy to high frequency energy, voiced speech tends to be dominated by low frequency energy, unvoiced by high frequency. This measure can be used to @@ -488,7 +488,7 @@ float est_voicing_mbe( /* If pitch is jumping about it's likely this is UV */ dF0 = (model->Wo - prev_Wo)*FS/TWO_PI; - if (fabs(dF0) > 15.0) + if (fabs(dF0) > 15.0) model->voiced = 0; /* A common source of Type 2 errors is the pitch estimator @@ -507,10 +507,10 @@ float est_voicing_mbe( } /*---------------------------------------------------------------------------*\ - - FUNCTION....: make_synthesis_window - AUTHOR......: David Rowe - DATE CREATED: 11/5/94 + + FUNCTION....: make_synthesis_window + AUTHOR......: David Rowe + DATE CREATED: 11/5/94 Init function that generates the trapezoidal (Parzen) sythesis window. @@ -539,15 +539,15 @@ void make_synthesis_window(float Pn[]) } /*---------------------------------------------------------------------------*\ - - FUNCTION....: synthesise - AUTHOR......: David Rowe - DATE CREATED: 20/2/95 - + + FUNCTION....: synthesise + AUTHOR......: David Rowe + DATE CREATED: 20/2/95 + Synthesise a speech signal in the frequency domain from the sinusodal model parameters. Uses overlap-add with a trapezoidal window to smoothly interpolate betwen frames. - + \*---------------------------------------------------------------------------*/ void synthesise( @@ -579,7 +579,7 @@ void synthesise( gives better results for synthesis frames greater than 10ms. Inverse FFT synthesis using a 512 pt FFT works well for 10ms window. I think (but am not sure) that the problem is realted to the quantisation of - the harmonic frequencies to the FFT bin size, e.g. there is a + the harmonic frequencies to the FFT bin size, e.g. there is a 8000/512 Hz step between FFT bins. For some reason this makes the speech from longer frame > 10ms sound poor. The effect can also be seen when synthesising test signals like single sine waves, some @@ -619,7 +619,7 @@ void synthesise( } for(i=N-1,j=0; i<2*N; i++,j++) Sw_[j].real += 2.0*model->A[l]*cos(j*model->Wo*l + model->phi[l]); - } + } #endif /* Overlap add to previous samples */ diff --git a/gr-vocoder/lib/codec2/sine.h b/gr-vocoder/lib/codec2/sine.h index ae578bf70..f223e2afc 100644 --- a/gr-vocoder/lib/codec2/sine.h +++ b/gr-vocoder/lib/codec2/sine.h @@ -1,11 +1,11 @@ /*---------------------------------------------------------------------------*\ - + FILE........: sine.h - AUTHOR......: David Rowe + AUTHOR......: David Rowe DATE CREATED: 1/11/94 - + Header file for sinusoidal analysis and synthesis functions. - + \*---------------------------------------------------------------------------*/ /* @@ -36,7 +36,7 @@ float hpf(float x, float states[]); void dft_speech(COMP Sw[], float Sn[], float w[]); void two_stage_pitch_refinement(MODEL *model, COMP Sw[]); void estimate_amplitudes(MODEL *model, COMP Sw[], COMP W[]); -float est_voicing_mbe(MODEL *model, COMP Sw[], COMP W[], COMP Sw_[],COMP Ew[], +float est_voicing_mbe(MODEL *model, COMP Sw[], COMP W[], COMP Sw_[],COMP Ew[], float prev_Wo); void make_synthesis_window(float Pn[]); void synthesise(float Sn_[], MODEL *model, float Pn[], int shift); |