mirror of
https://github.com/n5ac/smartsdr-dsp.git
synced 2026-03-18 18:04:40 +01:00
Remove CODEC2_FREEDV folder and files
This commit is contained in:
parent
880581d4ea
commit
5b5947dd06
|
|
@ -1,164 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2003-2010, Mark Borgerding
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* kiss_fft.h
|
||||
defines kiss_fft_scalar as either short or a float type
|
||||
and defines
|
||||
typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */
|
||||
#include "kiss_fft.h"
|
||||
#include <limits.h>
|
||||
|
||||
#define MAXFACTORS 32
|
||||
/* e.g. an fft of length 128 has 4 factors
|
||||
as far as kissfft is concerned
|
||||
4*4*4*2
|
||||
*/
|
||||
|
||||
struct kiss_fft_state{
|
||||
int nfft;
|
||||
int inverse;
|
||||
int factors[2*MAXFACTORS];
|
||||
kiss_fft_cpx twiddles[1];
|
||||
};
|
||||
|
||||
/*
|
||||
Explanation of macros dealing with complex math:
|
||||
|
||||
C_MUL(m,a,b) : m = a*b
|
||||
C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise
|
||||
C_SUB( res, a,b) : res = a - b
|
||||
C_SUBFROM( res , a) : res -= a
|
||||
C_ADDTO( res , a) : res += a
|
||||
* */
|
||||
#ifdef FIXED_POINT
|
||||
#if (FIXED_POINT==32)
|
||||
# define FRACBITS 31
|
||||
# define SAMPPROD int64_t
|
||||
#define SAMP_MAX 2147483647
|
||||
#else
|
||||
# define FRACBITS 15
|
||||
# define SAMPPROD int32_t
|
||||
#define SAMP_MAX 32767
|
||||
#endif
|
||||
|
||||
#define SAMP_MIN -SAMP_MAX
|
||||
|
||||
#if defined(CHECK_OVERFLOW)
|
||||
# define CHECK_OVERFLOW_OP(a,op,b) \
|
||||
if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \
|
||||
fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); }
|
||||
#endif
|
||||
|
||||
|
||||
# define smul(a,b) ( (SAMPPROD)(a)*(b) )
|
||||
# define sround( x ) (kiss_fft_scalar)( ( (x) + (1<<(FRACBITS-1)) ) >> FRACBITS )
|
||||
|
||||
# define S_MUL(a,b) sround( smul(a,b) )
|
||||
|
||||
# define C_MUL(m,a,b) \
|
||||
do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \
|
||||
(m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0)
|
||||
|
||||
# define DIVSCALAR(x,k) \
|
||||
(x) = sround( smul( x, SAMP_MAX/k ) )
|
||||
|
||||
# define C_FIXDIV(c,div) \
|
||||
do { DIVSCALAR( (c).r , div); \
|
||||
DIVSCALAR( (c).i , div); }while (0)
|
||||
|
||||
# define C_MULBYSCALAR( c, s ) \
|
||||
do{ (c).r = sround( smul( (c).r , s ) ) ;\
|
||||
(c).i = sround( smul( (c).i , s ) ) ; }while(0)
|
||||
|
||||
#else /* not FIXED_POINT*/
|
||||
|
||||
# define S_MUL(a,b) ( (a)*(b) )
|
||||
#define C_MUL(m,a,b) \
|
||||
do{ (m).r = (a).r*(b).r - (a).i*(b).i;\
|
||||
(m).i = (a).r*(b).i + (a).i*(b).r; }while(0)
|
||||
# define C_FIXDIV(c,div) /* NOOP */
|
||||
# define C_MULBYSCALAR( c, s ) \
|
||||
do{ (c).r *= (s);\
|
||||
(c).i *= (s); }while(0)
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_OVERFLOW_OP
|
||||
# define CHECK_OVERFLOW_OP(a,op,b) /* noop */
|
||||
#endif
|
||||
|
||||
#define C_ADD( res, a,b)\
|
||||
do { \
|
||||
CHECK_OVERFLOW_OP((a).r,+,(b).r)\
|
||||
CHECK_OVERFLOW_OP((a).i,+,(b).i)\
|
||||
(res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \
|
||||
}while(0)
|
||||
#define C_SUB( res, a,b)\
|
||||
do { \
|
||||
CHECK_OVERFLOW_OP((a).r,-,(b).r)\
|
||||
CHECK_OVERFLOW_OP((a).i,-,(b).i)\
|
||||
(res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \
|
||||
}while(0)
|
||||
#define C_ADDTO( res , a)\
|
||||
do { \
|
||||
CHECK_OVERFLOW_OP((res).r,+,(a).r)\
|
||||
CHECK_OVERFLOW_OP((res).i,+,(a).i)\
|
||||
(res).r += (a).r; (res).i += (a).i;\
|
||||
}while(0)
|
||||
|
||||
#define C_SUBFROM( res , a)\
|
||||
do {\
|
||||
CHECK_OVERFLOW_OP((res).r,-,(a).r)\
|
||||
CHECK_OVERFLOW_OP((res).i,-,(a).i)\
|
||||
(res).r -= (a).r; (res).i -= (a).i; \
|
||||
}while(0)
|
||||
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
# define KISS_FFT_COS(phase) floor(.5+SAMP_MAX * cos (phase))
|
||||
# define KISS_FFT_SIN(phase) floor(.5+SAMP_MAX * sin (phase))
|
||||
# define HALF_OF(x) ((x)>>1)
|
||||
#elif defined(USE_SIMD)
|
||||
# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) )
|
||||
# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) )
|
||||
# define HALF_OF(x) ((x)*_mm_set1_ps(.5))
|
||||
#else
|
||||
# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase)
|
||||
# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase)
|
||||
# define HALF_OF(x) ((x)*.5)
|
||||
#endif
|
||||
|
||||
#define kf_cexp(x,phase) \
|
||||
do{ \
|
||||
(x)->r = KISS_FFT_COS(phase);\
|
||||
(x)->i = KISS_FFT_SIN(phase);\
|
||||
}while(0)
|
||||
|
||||
|
||||
/* a debugging function */
|
||||
#define pcpx(c)\
|
||||
fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) )
|
||||
|
||||
|
||||
#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:
|
||||
// 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)
|
||||
#else
|
||||
#define KISS_FFT_TMP_ALLOC(nbytes) KISS_FFT_MALLOC(nbytes)
|
||||
#define KISS_FFT_TMP_FREE(ptr) KISS_FFT_FREE(ptr)
|
||||
#endif
|
||||
|
|
@ -1,245 +0,0 @@
|
|||
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
|
||||
|
||||
/*
|
||||
* This intermediary file and the files that used to create it are under
|
||||
* The LGPL. See the file COPYING.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
/* codebook/lsp1.txt */
|
||||
static const float codes0[] = {
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600
|
||||
};
|
||||
/* codebook/lsp2.txt */
|
||||
static const float codes1[] = {
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700
|
||||
};
|
||||
/* codebook/lsp3.txt */
|
||||
static const float codes2[] = {
|
||||
500,
|
||||
550,
|
||||
600,
|
||||
650,
|
||||
700,
|
||||
750,
|
||||
800,
|
||||
850,
|
||||
900,
|
||||
950,
|
||||
1000,
|
||||
1050,
|
||||
1100,
|
||||
1150,
|
||||
1200,
|
||||
1250
|
||||
};
|
||||
/* codebook/lsp4.txt */
|
||||
static const float codes3[] = {
|
||||
700,
|
||||
800,
|
||||
900,
|
||||
1000,
|
||||
1100,
|
||||
1200,
|
||||
1300,
|
||||
1400,
|
||||
1500,
|
||||
1600,
|
||||
1700,
|
||||
1800,
|
||||
1900,
|
||||
2000,
|
||||
2100,
|
||||
2200
|
||||
};
|
||||
/* codebook/lsp5.txt */
|
||||
static const float codes4[] = {
|
||||
950,
|
||||
1050,
|
||||
1150,
|
||||
1250,
|
||||
1350,
|
||||
1450,
|
||||
1550,
|
||||
1650,
|
||||
1750,
|
||||
1850,
|
||||
1950,
|
||||
2050,
|
||||
2150,
|
||||
2250,
|
||||
2350,
|
||||
2450
|
||||
};
|
||||
/* codebook/lsp6.txt */
|
||||
static const float codes5[] = {
|
||||
1100,
|
||||
1200,
|
||||
1300,
|
||||
1400,
|
||||
1500,
|
||||
1600,
|
||||
1700,
|
||||
1800,
|
||||
1900,
|
||||
2000,
|
||||
2100,
|
||||
2200,
|
||||
2300,
|
||||
2400,
|
||||
2500,
|
||||
2600
|
||||
};
|
||||
/* codebook/lsp7.txt */
|
||||
static const float codes6[] = {
|
||||
1500,
|
||||
1600,
|
||||
1700,
|
||||
1800,
|
||||
1900,
|
||||
2000,
|
||||
2100,
|
||||
2200,
|
||||
2300,
|
||||
2400,
|
||||
2500,
|
||||
2600,
|
||||
2700,
|
||||
2800,
|
||||
2900,
|
||||
3000
|
||||
};
|
||||
/* codebook/lsp8.txt */
|
||||
static const float codes7[] = {
|
||||
2300,
|
||||
2400,
|
||||
2500,
|
||||
2600,
|
||||
2700,
|
||||
2800,
|
||||
2900,
|
||||
3000
|
||||
};
|
||||
/* codebook/lsp9.txt */
|
||||
static const float codes8[] = {
|
||||
2500,
|
||||
2600,
|
||||
2700,
|
||||
2800,
|
||||
2900,
|
||||
3000,
|
||||
3100,
|
||||
3200
|
||||
};
|
||||
/* codebook/lsp10.txt */
|
||||
static const float codes9[] = {
|
||||
2900,
|
||||
3100,
|
||||
3300,
|
||||
3500
|
||||
};
|
||||
|
||||
const struct lsp_codebook lsp_cb[] = {
|
||||
/* codebook/lsp1.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes0
|
||||
},
|
||||
/* codebook/lsp2.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes1
|
||||
},
|
||||
/* codebook/lsp3.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes2
|
||||
},
|
||||
/* codebook/lsp4.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes3
|
||||
},
|
||||
/* codebook/lsp5.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes4
|
||||
},
|
||||
/* codebook/lsp6.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes5
|
||||
},
|
||||
/* codebook/lsp7.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes6
|
||||
},
|
||||
/* codebook/lsp8.txt */
|
||||
{
|
||||
1,
|
||||
3,
|
||||
8,
|
||||
codes7
|
||||
},
|
||||
/* codebook/lsp9.txt */
|
||||
{
|
||||
1,
|
||||
3,
|
||||
8,
|
||||
codes8
|
||||
},
|
||||
/* codebook/lsp10.txt */
|
||||
{
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
codes9
|
||||
},
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
|
@ -1,433 +0,0 @@
|
|||
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
|
||||
|
||||
/*
|
||||
* This intermediary file and the files that used to create it are under
|
||||
* The LGPL. See the file COPYING.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
/* codebook/dlsp1.txt */
|
||||
static const float codes0[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700,
|
||||
725,
|
||||
750,
|
||||
775,
|
||||
800
|
||||
};
|
||||
/* codebook/dlsp2.txt */
|
||||
static const float codes1[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700,
|
||||
725,
|
||||
750,
|
||||
775,
|
||||
800
|
||||
};
|
||||
/* codebook/dlsp3.txt */
|
||||
static const float codes2[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700,
|
||||
725,
|
||||
750,
|
||||
775,
|
||||
800
|
||||
};
|
||||
/* codebook/dlsp4.txt */
|
||||
static const float codes3[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
250,
|
||||
300,
|
||||
350,
|
||||
400,
|
||||
450,
|
||||
500,
|
||||
550,
|
||||
600,
|
||||
650,
|
||||
700,
|
||||
750,
|
||||
800,
|
||||
850,
|
||||
900,
|
||||
950,
|
||||
1000,
|
||||
1050,
|
||||
1100,
|
||||
1150,
|
||||
1200,
|
||||
1250,
|
||||
1300,
|
||||
1350,
|
||||
1400
|
||||
};
|
||||
/* codebook/dlsp5.txt */
|
||||
static const float codes4[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
250,
|
||||
300,
|
||||
350,
|
||||
400,
|
||||
450,
|
||||
500,
|
||||
550,
|
||||
600,
|
||||
650,
|
||||
700,
|
||||
750,
|
||||
800,
|
||||
850,
|
||||
900,
|
||||
950,
|
||||
1000,
|
||||
1050,
|
||||
1100,
|
||||
1150,
|
||||
1200,
|
||||
1250,
|
||||
1300,
|
||||
1350,
|
||||
1400
|
||||
};
|
||||
/* codebook/dlsp6.txt */
|
||||
static const float codes5[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
250,
|
||||
300,
|
||||
350,
|
||||
400,
|
||||
450,
|
||||
500,
|
||||
550,
|
||||
600,
|
||||
650,
|
||||
700,
|
||||
750,
|
||||
800,
|
||||
850,
|
||||
900,
|
||||
950,
|
||||
1000,
|
||||
1050,
|
||||
1100,
|
||||
1150,
|
||||
1200,
|
||||
1250,
|
||||
1300,
|
||||
1350,
|
||||
1400
|
||||
};
|
||||
/* codebook/dlsp7.txt */
|
||||
static const float codes6[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700,
|
||||
725,
|
||||
750,
|
||||
775,
|
||||
800
|
||||
};
|
||||
/* codebook/dlsp8.txt */
|
||||
static const float codes7[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700,
|
||||
725,
|
||||
750,
|
||||
775,
|
||||
800
|
||||
};
|
||||
/* codebook/dlsp9.txt */
|
||||
static const float codes8[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700,
|
||||
725,
|
||||
750,
|
||||
775,
|
||||
800
|
||||
};
|
||||
/* codebook/dlsp10.txt */
|
||||
static const float codes9[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700,
|
||||
725,
|
||||
750,
|
||||
775,
|
||||
800
|
||||
};
|
||||
|
||||
const struct lsp_codebook lsp_cbd[] = {
|
||||
/* codebook/dlsp1.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes0
|
||||
},
|
||||
/* codebook/dlsp2.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes1
|
||||
},
|
||||
/* codebook/dlsp3.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes2
|
||||
},
|
||||
/* codebook/dlsp4.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes3
|
||||
},
|
||||
/* codebook/dlsp5.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes4
|
||||
},
|
||||
/* codebook/dlsp6.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes5
|
||||
},
|
||||
/* codebook/dlsp7.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes6
|
||||
},
|
||||
/* codebook/dlsp8.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes7
|
||||
},
|
||||
/* codebook/dlsp9.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes8
|
||||
},
|
||||
/* codebook/dlsp10.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes9
|
||||
},
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
|
||||
|
||||
/*
|
||||
* This intermediary file and the files that used to create it are under
|
||||
* The LGPL. See the file COPYING.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
/* codebook/lspdt1.txt */
|
||||
static const float codes0[] = {
|
||||
-75,
|
||||
-50,
|
||||
-25,
|
||||
0,
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100
|
||||
};
|
||||
/* codebook/lspdt2.txt */
|
||||
static const float codes1[] = {
|
||||
-75,
|
||||
-50,
|
||||
-25,
|
||||
0,
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100
|
||||
};
|
||||
/* codebook/lspdt3.txt */
|
||||
static const float codes2[] = {
|
||||
-50,
|
||||
0,
|
||||
50,
|
||||
100
|
||||
};
|
||||
/* codebook/lspdt4.txt */
|
||||
static const float codes3[] = {
|
||||
-50,
|
||||
0,
|
||||
50,
|
||||
100
|
||||
};
|
||||
/* codebook/lspdt5.txt */
|
||||
static const float codes4[] = {
|
||||
-50,
|
||||
0,
|
||||
50,
|
||||
100
|
||||
};
|
||||
/* codebook/lspdt6.txt */
|
||||
static const float codes5[] = {
|
||||
-50,
|
||||
0,
|
||||
50,
|
||||
100
|
||||
};
|
||||
/* codebook/lspdt7.txt */
|
||||
static const float codes6[] = {
|
||||
-50,
|
||||
50
|
||||
};
|
||||
/* codebook/lspdt8.txt */
|
||||
static const float codes7[] = {
|
||||
-50,
|
||||
50
|
||||
};
|
||||
/* codebook/lspdt9.txt */
|
||||
static const float codes8[] = {
|
||||
-50,
|
||||
50
|
||||
};
|
||||
/* codebook/lspdt10.txt */
|
||||
static const float codes9[] = {
|
||||
-50,
|
||||
50
|
||||
};
|
||||
|
||||
const struct lsp_codebook lsp_cbdt[] = {
|
||||
/* codebook/lspdt1.txt */
|
||||
{
|
||||
1,
|
||||
3,
|
||||
8,
|
||||
codes0
|
||||
},
|
||||
/* codebook/lspdt2.txt */
|
||||
{
|
||||
1,
|
||||
3,
|
||||
8,
|
||||
codes1
|
||||
},
|
||||
/* codebook/lspdt3.txt */
|
||||
{
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
codes2
|
||||
},
|
||||
/* codebook/lspdt4.txt */
|
||||
{
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
codes3
|
||||
},
|
||||
/* codebook/lspdt5.txt */
|
||||
{
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
codes4
|
||||
},
|
||||
/* codebook/lspdt6.txt */
|
||||
{
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
codes5
|
||||
},
|
||||
/* codebook/lspdt7.txt */
|
||||
{
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
codes6
|
||||
},
|
||||
/* codebook/lspdt8.txt */
|
||||
{
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
codes7
|
||||
},
|
||||
/* codebook/lspdt9.txt */
|
||||
{
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
codes8
|
||||
},
|
||||
/* codebook/lspdt10.txt */
|
||||
{
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
codes9
|
||||
},
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
|
@ -1,279 +0,0 @@
|
|||
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
|
||||
|
||||
/*
|
||||
* This intermediary file and the files that used to create it are under
|
||||
* The LGPL. See the file COPYING.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
/* codebook/gecb.txt */
|
||||
static const float codes0[] = {
|
||||
2.71, 12.0184,
|
||||
0.04675, -2.73881,
|
||||
0.120993, 8.38895,
|
||||
-1.58028, -0.892307,
|
||||
1.19307, -1.91561,
|
||||
0.187101, -3.27679,
|
||||
0.332251, -7.66455,
|
||||
-1.47944, 31.2461,
|
||||
1.52761, 27.7095,
|
||||
-0.524379, 5.25012,
|
||||
0.55333, 7.4388,
|
||||
-0.843451, -1.95299,
|
||||
2.26389, 8.61029,
|
||||
0.143143, 2.36549,
|
||||
0.616506, 1.28427,
|
||||
-1.71133, 22.0967,
|
||||
1.00813, 17.3965,
|
||||
-0.106718, 1.41891,
|
||||
-0.136246, 14.2736,
|
||||
-1.70909, -20.5319,
|
||||
1.65787, -3.39107,
|
||||
0.138049, -4.95785,
|
||||
0.536729, -1.94375,
|
||||
0.196307, 36.8519,
|
||||
1.27248, 22.5565,
|
||||
-0.670219, -1.90604,
|
||||
0.382092, 6.40113,
|
||||
-0.756911, -4.90102,
|
||||
1.82931, 4.6138,
|
||||
0.318794, 0.73683,
|
||||
0.612815, -2.07505,
|
||||
-0.410151, 24.7871,
|
||||
1.77602, 13.1909,
|
||||
0.106457, -0.104492,
|
||||
0.192206, 10.1838,
|
||||
-1.82442, -7.71565,
|
||||
0.931346, 4.34835,
|
||||
0.308813, -4.086,
|
||||
0.397143, -11.8089,
|
||||
-0.048715, 41.2273,
|
||||
0.877342, 35.8503,
|
||||
-0.759794, 0.476634,
|
||||
0.978593, 7.67467,
|
||||
-1.19506, 3.03883,
|
||||
2.63989, -3.41106,
|
||||
0.191127, 3.60351,
|
||||
0.402932, 1.0843,
|
||||
-2.15202, 18.1076,
|
||||
1.5468, 8.32271,
|
||||
-0.143089, -4.07592,
|
||||
-0.150142, 5.86674,
|
||||
-1.40844, -3.2507,
|
||||
1.56615, -10.4132,
|
||||
0.178171, -10.2267,
|
||||
0.362164, -0.028556,
|
||||
-0.070125, 24.3907,
|
||||
0.594752, 17.4828,
|
||||
-0.28698, -6.90407,
|
||||
0.464818, 10.2055,
|
||||
-1.00684, -14.3572,
|
||||
2.32957, -3.69161,
|
||||
0.335745, 2.40714,
|
||||
1.01966, -3.15565,
|
||||
-1.25945, 7.9919,
|
||||
2.38369, 19.6806,
|
||||
-0.094947, -2.41374,
|
||||
0.20933, 6.66477,
|
||||
-2.22103, 1.37986,
|
||||
1.29239, 2.04633,
|
||||
0.243626, -0.890741,
|
||||
0.428773, -7.19366,
|
||||
-1.11374, 41.3414,
|
||||
2.6098, 31.1405,
|
||||
-0.446468, 2.53419,
|
||||
0.490104, 4.62757,
|
||||
-1.11723, -3.24174,
|
||||
1.79156, 8.41493,
|
||||
0.156012, 0.183336,
|
||||
0.532447, 3.15455,
|
||||
-0.764484, 18.514,
|
||||
0.952395, 11.7713,
|
||||
-0.332567, 0.346987,
|
||||
0.202165, 14.7168,
|
||||
-2.12924, -15.559,
|
||||
1.35358, -1.92679,
|
||||
-0.010963, -16.3364,
|
||||
0.399053, -2.79057,
|
||||
0.750657, 31.1483,
|
||||
0.655743, 24.4819,
|
||||
-0.45321, -0.735879,
|
||||
0.2869, 6.5467,
|
||||
-0.715673, -12.3578,
|
||||
1.54849, 3.87217,
|
||||
0.271874, 0.802339,
|
||||
0.502073, -4.85485,
|
||||
-0.497037, 17.7619,
|
||||
1.19116, 13.9544,
|
||||
0.01563, 1.33157,
|
||||
0.341867, 8.93537,
|
||||
-2.31601, -5.39506,
|
||||
0.75861, 1.9645,
|
||||
0.24132, -3.23769,
|
||||
0.267151, -11.2344,
|
||||
-0.273126, 32.6248,
|
||||
1.75352, 40.432,
|
||||
-0.784011, 3.04576,
|
||||
0.705987, 5.66118,
|
||||
-1.3864, 1.35356,
|
||||
2.37646, 1.67485,
|
||||
0.242973, 4.73218,
|
||||
0.491227, 0.354061,
|
||||
-1.60676, 8.65895,
|
||||
1.16711, 5.9871,
|
||||
-0.137601, -12.0417,
|
||||
-0.251375, 10.3972,
|
||||
-1.43151, -8.90411,
|
||||
0.98828, -13.209,
|
||||
0.261484, -6.35497,
|
||||
0.395932, -0.702529,
|
||||
0.283704, 26.8996,
|
||||
0.420959, 15.4418,
|
||||
-0.355804, -13.7278,
|
||||
0.527372, 12.3985,
|
||||
-1.16956, -15.9985,
|
||||
1.90669, -5.81605,
|
||||
0.354492, 3.85157,
|
||||
0.82576, -4.16264,
|
||||
-0.49019, 13.0572,
|
||||
2.25577, 13.5264,
|
||||
-0.004956, -3.23713,
|
||||
0.026709, 7.86645,
|
||||
-1.81037, -0.451183,
|
||||
1.08383, -0.18362,
|
||||
0.135836, -2.26658,
|
||||
0.375812, -5.51225,
|
||||
-1.96644, 38.6829,
|
||||
1.97799, 24.5655,
|
||||
-0.704656, 6.35881,
|
||||
0.480786, 7.05175,
|
||||
-0.976417, -2.42273,
|
||||
2.50215, 6.75935,
|
||||
0.083588, 3.2588,
|
||||
0.543629, 0.910013,
|
||||
-1.23196, 23.0915,
|
||||
0.785492, 14.807,
|
||||
-0.213554, 1.688,
|
||||
0.004748, 18.1718,
|
||||
-1.54719, -16.1168,
|
||||
1.50104, -3.28114,
|
||||
0.080133, -4.63472,
|
||||
0.476592, -2.18093,
|
||||
0.44247, 40.304,
|
||||
1.07277, 27.592,
|
||||
-0.594738, -4.16681,
|
||||
0.42248, 7.61609,
|
||||
-0.927521, -7.27441,
|
||||
1.99162, 1.29636,
|
||||
0.291307, 2.39878,
|
||||
0.721081, -1.95062,
|
||||
-0.804256, 24.9295,
|
||||
1.64839, 19.1197,
|
||||
0.060852, -0.590639,
|
||||
0.266085, 9.10325,
|
||||
-1.9574, -2.88461,
|
||||
1.11693, 2.6724,
|
||||
0.35458, -2.74854,
|
||||
0.330733, -14.1561,
|
||||
-0.527851, 39.5756,
|
||||
0.991152, 43.195,
|
||||
-0.589619, 1.26919,
|
||||
0.787401, 8.73071,
|
||||
-1.0138, 1.02507,
|
||||
2.8254, 1.89538,
|
||||
0.24089, 2.74557,
|
||||
0.427195, 2.54446,
|
||||
-1.95311, 12.244,
|
||||
1.44862, 12.0607,
|
||||
-0.210492, -3.37906,
|
||||
-0.056713, 10.204,
|
||||
-1.65237, -5.10274,
|
||||
1.29475, -12.2708,
|
||||
0.111608, -8.67592,
|
||||
0.326634, -1.16763,
|
||||
0.021781, 31.1258,
|
||||
0.455335, 21.4684,
|
||||
-0.37544, -3.37121,
|
||||
0.39362, 11.302,
|
||||
-0.851456, -19.4149,
|
||||
2.10703, -2.22886,
|
||||
0.373233, 1.92406,
|
||||
0.884438, -1.72058,
|
||||
-0.975127, 9.84013,
|
||||
2.0033, 17.3954,
|
||||
-0.036915, -1.11137,
|
||||
0.148456, 5.39997,
|
||||
-1.91441, 4.77382,
|
||||
1.44791, 0.537122,
|
||||
0.194979, -1.03818,
|
||||
0.495771, -9.95502,
|
||||
-1.05899, 32.9471,
|
||||
2.01122, 32.4544,
|
||||
-0.30965, 4.71911,
|
||||
0.436082, 4.63552,
|
||||
-1.23711, -1.25428,
|
||||
2.02274, 9.42834,
|
||||
0.190342, 1.46077,
|
||||
0.479017, 2.48479,
|
||||
-1.07848, 16.2217,
|
||||
1.20764, 9.65421,
|
||||
-0.258087, -1.67236,
|
||||
0.071852, 13.416,
|
||||
-1.87723, -16.072,
|
||||
1.28957, -4.87118,
|
||||
0.067713, -13.4427,
|
||||
0.435551, -4.1655,
|
||||
0.46614, 30.5895,
|
||||
0.904895, 21.598,
|
||||
-0.518369, -2.53205,
|
||||
0.337363, 5.63726,
|
||||
-0.554975, -17.4005,
|
||||
1.69188, 1.14574,
|
||||
0.227934, 0.889297,
|
||||
0.587303, -5.72973,
|
||||
-0.262133, 18.6666,
|
||||
1.39505, 17.0029,
|
||||
-0.01909, 4.30838,
|
||||
0.304235, 12.6699,
|
||||
-2.07406, -6.46084,
|
||||
0.920546, 1.21296,
|
||||
0.284927, -1.78547,
|
||||
0.209724, -16.024,
|
||||
-0.636067, 31.5768,
|
||||
1.34989, 34.6775,
|
||||
-0.971625, 5.30086,
|
||||
0.590249, 4.44971,
|
||||
-1.56787, 3.60239,
|
||||
2.1455, 4.51666,
|
||||
0.296022, 4.12017,
|
||||
0.445299, 0.868772,
|
||||
-1.44193, 14.1284,
|
||||
1.35575, 6.0074,
|
||||
-0.012814, -7.49657,
|
||||
-0.43, 8.50012,
|
||||
-1.20469, -7.11326,
|
||||
1.10102, -6.83682,
|
||||
0.196463, -6.234,
|
||||
0.436747, -1.12979,
|
||||
0.141052, 22.8549,
|
||||
0.290821, 18.8114,
|
||||
-0.529536, -7.73251,
|
||||
0.63428, 10.7898,
|
||||
-1.33472, -20.3258,
|
||||
1.81564, -1.90332,
|
||||
0.394778, 3.79758,
|
||||
0.732682, -8.18382,
|
||||
-0.741244, 11.7683
|
||||
};
|
||||
|
||||
const struct lsp_codebook ge_cb[] = {
|
||||
/* codebook/gecb.txt */
|
||||
{
|
||||
2,
|
||||
8,
|
||||
256,
|
||||
codes0
|
||||
},
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,565 +0,0 @@
|
|||
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
|
||||
|
||||
/*
|
||||
* This intermediary file and the files that used to create it are under
|
||||
* The LGPL. See the file COPYING.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
/* codebook/lspvqanssi1.txt */
|
||||
static const float codes0[] = {
|
||||
0.5862, 0.7213, 0.9146, 1.0909, 1.291, 1.4954, 1.837, 2.084, 2.3771, 2.5518,
|
||||
0.0871, 0.2049, 0.5849, 0.8552, 1.2096, 1.4686, 1.821, 2.0926, 2.4508, 2.7389,
|
||||
0.2274, 0.3126, 0.6088, 0.8338, 1.1824, 1.5948, 1.8228, 1.9856, 2.1832, 2.4793,
|
||||
0.1827, 0.2706, 0.5842, 0.7761, 1.0301, 1.2462, 1.6313, 1.9786, 2.3479, 2.679,
|
||||
0.3055, 0.3863, 0.7194, 1.1609, 1.3303, 1.5017, 1.7265, 1.9412, 2.4659, 2.6315,
|
||||
0.1794, 0.2522, 0.5477, 0.7892, 1.3887, 1.7101, 1.9471, 2.1667, 2.4361, 2.631,
|
||||
0.1825, 0.2729, 0.4185, 0.6024, 1.2531, 1.7291, 1.9937, 2.1849, 2.5865, 2.7748,
|
||||
0.3219, 0.4045, 0.7357, 1.2708, 1.4626, 1.6439, 1.9388, 2.1212, 2.5005, 2.6749,
|
||||
0.2234, 0.3496, 0.5054, 0.6981, 0.8672, 1.0431, 1.7091, 2.069, 2.329, 2.6195,
|
||||
0.3009, 0.3957, 0.7576, 0.9751, 1.1955, 1.7727, 2.0383, 2.2474, 2.5612, 2.7188,
|
||||
0.3841, 0.5544, 0.9209, 1.1811, 1.5441, 1.8126, 2.1175, 2.3192, 2.5486, 2.6935,
|
||||
0.2153, 0.3105, 0.5597, 0.8313, 1.2168, 1.4512, 1.7012, 1.8962, 2.3893, 2.5852,
|
||||
0.3196, 0.4814, 0.7629, 1.0869, 1.5517, 1.778, 2.0462, 2.2547, 2.5023, 2.6706,
|
||||
0.1964, 0.3055, 0.4307, 0.7178, 1.426, 1.624, 1.8392, 2.0576, 2.2976, 2.5492,
|
||||
0.426, 0.6888, 1.2019, 1.4194, 1.6437, 1.8221, 2.0469, 2.2508, 2.5142, 2.6795,
|
||||
0.3004, 0.3944, 0.5847, 1.005, 1.1812, 1.3559, 1.5479, 1.7847, 2.4924, 2.6703,
|
||||
0.1595, 0.2398, 0.4336, 0.9228, 1.2602, 1.5064, 1.7915, 1.984, 2.232, 2.5692,
|
||||
0.1832, 0.2985, 0.4205, 0.598, 0.762, 0.9894, 1.7499, 2.1151, 2.4814, 2.7214,
|
||||
0.2234, 0.3207, 0.5457, 0.9799, 1.2074, 1.7079, 1.9734, 2.1742, 2.4575, 2.6366,
|
||||
0.3598, 0.4819, 0.6385, 0.8878, 1.3226, 1.491, 1.7257, 1.9456, 2.2061, 2.4579,
|
||||
0.4671, 0.5911, 0.8513, 1.0923, 1.5104, 1.7043, 1.9727, 2.1839, 2.4484, 2.6111,
|
||||
0.2418, 0.3937, 0.542, 0.8971, 1.1152, 1.3054, 1.7928, 1.9796, 2.5441, 2.7572,
|
||||
0.3541, 0.473, 0.6546, 0.9063, 1.0792, 1.2743, 1.8545, 2.0555, 2.3083, 2.5404,
|
||||
0.3121, 0.4016, 0.7137, 0.8835, 1.0736, 1.5907, 1.8624, 2.0857, 2.5075, 2.6668,
|
||||
0.2232, 0.3631, 0.5273, 0.7438, 1.0492, 1.2235, 1.5449, 2.2198, 2.516, 2.6852,
|
||||
0.2557, 0.3528, 0.5051, 0.6528, 0.8351, 1.5688, 1.8838, 2.1056, 2.4401, 2.6111,
|
||||
0.4342, 0.5318, 0.9234, 1.1146, 1.3015, 1.5198, 1.8211, 2.034, 2.3694, 2.5506,
|
||||
0.431, 0.5269, 0.7431, 0.9018, 1.0734, 1.5196, 1.8267, 2.0244, 2.4508, 2.6177,
|
||||
0.215, 0.3249, 0.4966, 0.9434, 1.1627, 1.3497, 1.8003, 2.0045, 2.3567, 2.5909,
|
||||
0.2798, 0.4111, 0.5786, 0.7971, 1.0414, 1.2142, 1.6947, 2.0866, 2.3351, 2.5545,
|
||||
0.1688, 0.2693, 0.4004, 0.6337, 1.3058, 1.5064, 1.7535, 1.9689, 2.5542, 2.7424,
|
||||
0.4419, 0.6209, 1.0127, 1.2135, 1.4104, 1.6111, 1.882, 2.1005, 2.4238, 2.5966,
|
||||
0.3645, 0.512, 0.8977, 1.2209, 1.5286, 1.7204, 1.9787, 2.1779, 2.439, 2.6114,
|
||||
0.2897, 0.4136, 0.5504, 0.8515, 1.2641, 1.4334, 1.8079, 2.0656, 2.3509, 2.7593,
|
||||
0.1611, 0.4723, 0.742, 1.0071, 1.2571, 1.5891, 1.9224, 2.2345, 2.5647, 2.7991,
|
||||
0.2528, 0.4178, 0.8909, 1.3117, 1.6622, 1.8641, 2.1017, 2.2974, 2.5299, 2.6982,
|
||||
0.1749, 0.27, 0.4116, 0.6036, 1.143, 1.7776, 2.0394, 2.222, 2.4667, 2.6598,
|
||||
0.3451, 0.4325, 0.6194, 0.7406, 0.9176, 1.554, 1.8426, 2.0479, 2.4401, 2.5965,
|
||||
0.3672, 0.5164, 0.6558, 0.8441, 1.2332, 1.4114, 1.6955, 2.0875, 2.3674, 2.5471,
|
||||
0.2194, 0.3467, 0.7384, 1.1079, 1.5398, 1.8437, 2.1212, 2.3296, 2.58, 2.7403,
|
||||
0.1525, 0.2343, 0.3915, 0.6843, 1.0517, 1.502, 1.7905, 1.9667, 2.2027, 2.6725,
|
||||
0.3531, 0.5908, 0.7462, 0.9441, 1.2774, 1.4743, 1.8268, 2.1059, 2.4478, 2.6484,
|
||||
0.3611, 0.4981, 0.7598, 0.9676, 1.4024, 1.633, 1.9094, 2.1433, 2.4408, 2.613,
|
||||
0.2153, 0.3366, 0.4974, 0.6693, 1.1944, 1.6791, 1.9002, 2.1105, 2.41, 2.5922,
|
||||
0.2421, 0.3392, 0.5123, 0.9818, 1.5411, 1.7092, 1.9989, 2.1981, 2.5659, 2.7656,
|
||||
0.2116, 0.325, 0.4845, 0.8021, 1.0088, 1.2158, 1.8038, 2.0223, 2.2975, 2.581,
|
||||
0.1902, 0.2942, 0.8003, 1.1086, 1.3606, 1.6008, 1.8956, 2.1328, 2.4481, 2.6405,
|
||||
0.2772, 0.3914, 0.5826, 0.7654, 0.9495, 1.124, 1.3949, 2.0411, 2.3891, 2.5959,
|
||||
0.2678, 0.522, 0.763, 1.1, 1.3747, 1.6432, 1.9391, 2.2237, 2.5511, 2.7893,
|
||||
0.32, 0.4245, 0.6174, 0.9904, 1.1662, 1.3882, 1.7601, 1.9524, 2.3998, 2.5819,
|
||||
0.1702, 0.4871, 0.837, 1.0989, 1.3593, 1.583, 1.875, 2.1277, 2.4666, 2.6885,
|
||||
0.228, 0.3748, 0.6554, 0.9113, 1.2081, 1.4619, 1.8181, 2.0541, 2.3791, 2.5701,
|
||||
0.1752, 0.4363, 0.6454, 0.8798, 1.1079, 1.5367, 1.8667, 2.1716, 2.4804, 2.7249,
|
||||
0.3804, 0.47, 0.8224, 1.0099, 1.1892, 1.5906, 1.8879, 2.0907, 2.4544, 2.6238,
|
||||
0.1808, 0.291, 0.4683, 0.7059, 0.898, 1.4031, 1.7063, 1.9444, 2.4658, 2.6776,
|
||||
0.2418, 0.3803, 0.5443, 0.7589, 1.1496, 1.3185, 1.5451, 1.7433, 2.131, 2.6523,
|
||||
0.2698, 0.369, 0.5362, 1.0732, 1.2921, 1.4696, 1.744, 1.947, 2.5051, 2.6841,
|
||||
0.4099, 0.5102, 0.6983, 1.0468, 1.2459, 1.4185, 1.8851, 2.0815, 2.3464, 2.5605,
|
||||
0.0669, 0.1354, 0.3764, 0.8433, 1.1719, 1.4834, 1.8181, 2.1312, 2.4626, 2.8044,
|
||||
0.1614, 0.2372, 0.3878, 0.5708, 1.2759, 1.495, 1.8052, 2.0807, 2.3485, 2.6293,
|
||||
0.1688, 0.2875, 0.4301, 0.9059, 1.2361, 1.4054, 1.8057, 1.9924, 2.5589, 2.7495,
|
||||
0.2864, 0.3783, 0.7032, 1.0817, 1.2382, 1.5741, 1.8619, 2.0656, 2.5139, 2.6848,
|
||||
0.3829, 0.4781, 0.6766, 0.834, 1.0056, 1.4147, 1.665, 1.884, 2.3922, 2.5619,
|
||||
0.3259, 0.4187, 0.6139, 0.7338, 1.1831, 1.6497, 1.9, 2.1278, 2.4322, 2.593,
|
||||
0.2569, 0.379, 0.5426, 0.839, 0.9871, 1.485, 1.8652, 2.0732, 2.4314, 2.6005,
|
||||
0.1408, 0.2283, 0.4024, 0.8784, 1.1485, 1.4003, 1.7004, 1.9205, 2.3723, 2.6522,
|
||||
0.2971, 0.5039, 0.8005, 1.1212, 1.4232, 1.7801, 2.1255, 2.3907, 2.6795, 2.8487,
|
||||
0.1515, 0.2344, 0.4684, 0.804, 1.0401, 1.3774, 1.8329, 2.1235, 2.5555, 2.777,
|
||||
0.5778, 0.7157, 0.891, 1.0966, 1.4235, 1.6482, 1.9551, 2.1831, 2.4572, 2.6234,
|
||||
0.3017, 0.4161, 0.8088, 0.9971, 1.2, 1.4419, 1.7867, 2.0224, 2.3473, 2.54,
|
||||
0.1208, 0.2814, 0.6564, 0.9448, 1.2377, 1.5663, 1.9084, 2.2112, 2.5583, 2.8155,
|
||||
0.2127, 0.3127, 0.4635, 0.6416, 0.8449, 1.6652, 2.0577, 2.2656, 2.5811, 2.7434,
|
||||
0.1942, 0.3011, 0.4212, 0.6901, 1.5369, 1.7639, 1.9608, 2.1766, 2.4435, 2.6663,
|
||||
0.351, 0.4345, 0.7146, 0.9086, 1.0678, 1.2579, 1.4425, 2.0265, 2.4574, 2.6252,
|
||||
0.3225, 0.4323, 0.6168, 0.858, 1.5388, 1.791, 1.9927, 2.2013, 2.4494, 2.616,
|
||||
0.2271, 0.4488, 0.6287, 0.7857, 1.2086, 1.383, 1.6194, 2.1955, 2.5236, 2.6945,
|
||||
0.2568, 0.351, 0.5613, 1.05, 1.2521, 1.4359, 1.6995, 1.9187, 2.2148, 2.4275,
|
||||
0.2933, 0.3941, 0.6128, 0.8899, 1.072, 1.2862, 1.5331, 1.8301, 2.1553, 2.3865,
|
||||
0.348, 0.4626, 0.6009, 0.763, 0.9044, 1.1225, 1.8539, 2.1845, 2.5035, 2.7091,
|
||||
0.1337, 0.4722, 0.8099, 1.1273, 1.4252, 1.699, 2.0188, 2.2922, 2.6018, 2.8168,
|
||||
0.1138, 0.3263, 0.8059, 1.0473, 1.3262, 1.6202, 1.9439, 2.2007, 2.5347, 2.7702,
|
||||
0.1979, 0.313, 0.4635, 0.8504, 1.1143, 1.3221, 2.0371, 2.2421, 2.5406, 2.7491,
|
||||
0.3321, 0.4194, 0.8239, 1.0458, 1.1981, 1.3733, 1.5661, 1.9985, 2.3747, 2.5416,
|
||||
0.3729, 0.5958, 0.9551, 1.265, 1.5484, 1.9255, 2.2256, 2.4809, 2.7276, 2.8935,
|
||||
0.1664, 0.2516, 0.5347, 0.7545, 1.1971, 1.4089, 1.74, 2.0871, 2.4098, 2.6795,
|
||||
0.237, 0.3178, 0.6123, 1.3315, 1.547, 1.7257, 2.0063, 2.1977, 2.5449, 2.7252,
|
||||
0.203, 0.3328, 0.4766, 0.7357, 1.278, 1.4439, 1.7229, 1.9405, 2.2278, 2.6816,
|
||||
0.1702, 0.2919, 0.4598, 0.7123, 0.9077, 1.145, 1.8632, 2.0806, 2.499, 2.71,
|
||||
0.2421, 0.3578, 0.54, 0.7217, 0.8971, 1.4898, 1.8518, 2.1205, 2.6077, 2.7894,
|
||||
0.303, 0.3935, 0.5812, 0.7404, 0.9425, 1.8342, 2.0887, 2.2811, 2.5596, 2.7118,
|
||||
0.1322, 0.1997, 0.3466, 0.6981, 1.1811, 1.4849, 1.8594, 2.1114, 2.4708, 2.7804,
|
||||
0.2317, 0.3069, 0.686, 1.4306, 1.7121, 1.8671, 2.1249, 2.2995, 2.5705, 2.7456,
|
||||
0.3778, 0.4863, 0.6639, 0.9163, 1.156, 1.3186, 1.5389, 1.7169, 2.1603, 2.5797,
|
||||
0.2118, 0.3499, 0.5259, 0.72, 1.1348, 1.314, 1.5657, 2.0241, 2.2873, 2.5184,
|
||||
0.2902, 0.4368, 0.6331, 0.8971, 1.3102, 1.5219, 1.8674, 2.1512, 2.4708, 2.6809,
|
||||
0.1418, 0.3988, 0.6251, 0.8544, 1.1268, 1.3964, 1.7585, 2.0322, 2.3964, 2.6928,
|
||||
0.2314, 0.3462, 0.7282, 0.9211, 1.1766, 1.4941, 1.7368, 1.9546, 2.517, 2.7066,
|
||||
0.2076, 0.3251, 0.7423, 0.959, 1.1936, 1.5329, 1.8887, 2.1588, 2.4667, 2.6709,
|
||||
0.2058, 0.4139, 0.5745, 0.7832, 0.9595, 1.1688, 1.7561, 1.9562, 2.484, 2.7001,
|
||||
0.1834, 0.2971, 0.4643, 0.6625, 0.8802, 1.1137, 1.5183, 1.8417, 2.3842, 2.7042,
|
||||
0.1688, 0.4218, 0.707, 1.0465, 1.4496, 1.6953, 1.956, 2.2174, 2.5172, 2.7404,
|
||||
0.2323, 0.3981, 0.5489, 0.7227, 1.2886, 1.5221, 1.7158, 2.1184, 2.4066, 2.5898,
|
||||
0.347, 0.5265, 0.814, 1.0152, 1.3206, 1.5411, 1.849, 2.0588, 2.3556, 2.5393,
|
||||
0.1707, 0.2595, 0.6762, 0.9037, 1.2781, 1.4903, 1.7946, 2.061, 2.3741, 2.5771,
|
||||
0.1457, 0.2318, 0.6039, 1.0078, 1.3461, 1.5908, 1.8818, 2.1248, 2.4432, 2.6714,
|
||||
0.6574, 0.8086, 1.0243, 1.2183, 1.4837, 1.7129, 2.0197, 2.2464, 2.5059, 2.6716,
|
||||
0.2546, 0.4983, 0.8674, 1.2536, 1.6704, 1.9529, 2.2134, 2.4319, 2.6532, 2.8109,
|
||||
0.2455, 0.3379, 0.4632, 0.8635, 1.5286, 1.8047, 1.9909, 2.1806, 2.4031, 2.5729,
|
||||
0.4772, 0.6742, 1, 1.2474, 1.5288, 1.7415, 2.0102, 2.2168, 2.477, 2.6449,
|
||||
0.3357, 0.4382, 0.6033, 1.1317, 1.3681, 1.5576, 1.9251, 2.1119, 2.5548, 2.7395,
|
||||
0.2588, 0.7015, 0.8953, 1.083, 1.2828, 1.516, 1.8965, 2.1921, 2.515, 2.7258,
|
||||
0.2466, 0.3512, 0.5047, 0.6646, 0.8161, 1.2577, 1.8046, 2.0214, 2.4447, 2.6491,
|
||||
0.1631, 0.2283, 0.407, 0.5955, 1.1126, 1.3894, 1.8978, 2.1849, 2.5384, 2.7382,
|
||||
0.3424, 0.4748, 0.6222, 0.802, 0.9706, 1.1568, 1.7044, 1.9297, 2.2127, 2.5627,
|
||||
0.2088, 0.5143, 0.74, 0.9277, 1.1032, 1.3561, 1.8841, 2.2004, 2.5882, 2.7993,
|
||||
0.2016, 0.3488, 0.5894, 0.7419, 1.1488, 1.3626, 1.5566, 1.9694, 2.5488, 2.7209,
|
||||
0.2558, 0.3914, 0.536, 0.7521, 1.433, 1.6955, 1.8886, 2.1428, 2.419, 2.5966,
|
||||
0.4021, 0.5034, 0.6653, 0.8123, 0.9586, 1.2825, 1.9184, 2.112, 2.409, 2.597,
|
||||
0.2343, 0.48, 0.6934, 0.8523, 1.2786, 1.4763, 1.7235, 2.04, 2.3602, 2.5562,
|
||||
0.246, 0.3687, 0.5325, 0.7044, 1.1488, 1.3608, 1.8112, 2.0757, 2.4183, 2.663,
|
||||
0.1616, 0.3644, 0.5725, 0.9166, 1.2481, 1.4938, 1.8388, 2.1175, 2.4712, 2.7464,
|
||||
0.376, 0.4841, 0.635, 1.0082, 1.211, 1.4003, 1.8127, 2.0018, 2.5199, 2.7238,
|
||||
0.1988, 0.2824, 0.6553, 1.0337, 1.5413, 1.7369, 1.9751, 2.1751, 2.4372, 2.6265,
|
||||
0.2728, 0.4094, 0.7498, 1.0645, 1.3516, 1.5946, 1.991, 2.2172, 2.483, 2.6614,
|
||||
0.1657, 0.5327, 0.7281, 0.9966, 1.2385, 1.4629, 1.8119, 2.0973, 2.4469, 2.6979,
|
||||
0.1413, 0.2098, 0.354, 0.5492, 0.8486, 1.1288, 1.632, 1.9056, 2.2805, 2.5438,
|
||||
0.2856, 0.3666, 0.6259, 1.1424, 1.6605, 1.8197, 2.0147, 2.1986, 2.4121, 2.5919,
|
||||
0.2725, 0.4829, 0.765, 1.0119, 1.2977, 1.5488, 1.8755, 2.1155, 2.4383, 2.6377,
|
||||
0.2736, 0.3804, 0.5537, 1.0258, 1.2269, 1.4186, 1.9718, 2.1468, 2.5665, 2.7689,
|
||||
0.2341, 0.5953, 1.103, 1.4549, 1.7361, 1.9758, 2.2126, 2.4213, 2.6405, 2.8181,
|
||||
0.2273, 0.4638, 0.6228, 0.85, 1.1016, 1.2823, 1.7094, 1.9523, 2.2669, 2.7029,
|
||||
0.2438, 0.3798, 0.7299, 0.96, 1.3765, 1.6104, 1.8644, 2.1161, 2.5073, 2.7137,
|
||||
0.1551, 0.4869, 0.8676, 1.2274, 1.5069, 1.8857, 2.1868, 2.4411, 2.7106, 2.8767,
|
||||
0.2746, 0.5454, 0.7589, 0.9458, 1.1597, 1.3349, 1.6653, 2.1142, 2.4356, 2.6239,
|
||||
0.1793, 0.2646, 0.4344, 0.7482, 1.1502, 1.3733, 1.8558, 2.0817, 2.3248, 2.5171,
|
||||
0.2698, 0.4202, 0.5765, 0.8301, 1.0073, 1.2101, 1.9714, 2.2051, 2.5138, 2.7395,
|
||||
0.1929, 0.3091, 0.446, 0.6266, 1.1805, 1.3672, 1.599, 2.1514, 2.4729, 2.6468,
|
||||
0.1901, 0.3047, 0.4607, 1.1019, 1.3168, 1.5343, 1.9234, 2.1365, 2.5924, 2.7807,
|
||||
0.3139, 0.5009, 0.67, 0.8268, 1.0117, 1.181, 1.6539, 2.1984, 2.4828, 2.6576,
|
||||
0.1403, 0.2173, 0.4117, 0.7302, 1.0038, 1.2732, 1.7392, 2.0337, 2.3809, 2.7386,
|
||||
0.4166, 0.5101, 0.7449, 1.1663, 1.3492, 1.5543, 1.9, 2.0941, 2.4588, 2.6365,
|
||||
0.3342, 0.4335, 0.616, 0.8559, 1.0112, 1.2097, 1.4029, 1.6361, 2.4129, 2.6324,
|
||||
0.4543, 0.6159, 0.7932, 0.9843, 1.2562, 1.4308, 1.7116, 1.9919, 2.2671, 2.4631,
|
||||
0.2153, 0.3609, 0.5302, 0.7089, 0.8756, 1.0376, 1.6496, 2.2826, 2.568, 2.7441,
|
||||
0.438, 0.6439, 0.8282, 1.0651, 1.365, 1.5829, 1.8838, 2.1005, 2.4006, 2.5771,
|
||||
0.2523, 0.3636, 0.5879, 1.1628, 1.3542, 1.6756, 2.0488, 2.2543, 2.6093, 2.7953,
|
||||
0.4179, 0.5426, 0.7065, 0.8996, 1.0684, 1.3146, 1.9705, 2.2021, 2.5051, 2.7061,
|
||||
0.1659, 0.286, 0.6693, 0.9229, 1.3959, 1.6544, 1.9709, 2.2257, 2.5236, 2.746,
|
||||
0.254, 0.4356, 0.5946, 0.7627, 1.2274, 1.4222, 1.6573, 1.9601, 2.2514, 2.4711,
|
||||
0.1633, 0.2337, 0.3698, 0.5421, 1.1757, 1.5916, 2.1561, 2.3371, 2.5534, 2.7737,
|
||||
0.1953, 0.273, 0.4521, 1.2005, 1.7062, 1.8627, 2.1313, 2.3266, 2.5906, 2.7667,
|
||||
0.3053, 0.4054, 0.5651, 0.747, 0.891, 1.172, 1.8864, 2.1074, 2.3705, 2.5744,
|
||||
0.1761, 0.3033, 0.6501, 0.8268, 1.0369, 1.2687, 1.8534, 2.1889, 2.5074, 2.7339,
|
||||
0.2265, 0.399, 1.1359, 1.4137, 1.6839, 1.8912, 2.0948, 2.3042, 2.5489, 2.7234,
|
||||
0.3326, 0.54, 0.8711, 1.0948, 1.3752, 1.6155, 1.936, 2.1537, 2.4451, 2.6133,
|
||||
0.2162, 0.3522, 0.5309, 0.747, 0.9677, 1.1747, 1.5056, 1.7942, 2.1615, 2.48,
|
||||
0.1872, 0.2761, 0.4053, 0.7469, 1.5858, 1.8945, 2.1198, 2.3197, 2.5819, 2.7758,
|
||||
0.5381, 0.8651, 1.2695, 1.4918, 1.7774, 1.9696, 2.1865, 2.3687, 2.5739, 2.7158,
|
||||
0.2663, 0.3422, 0.6098, 1.212, 1.4516, 1.6092, 1.8506, 2.0376, 2.2929, 2.5088,
|
||||
0.1904, 0.3051, 0.5663, 0.7391, 1.1589, 1.5705, 1.8756, 2.1653, 2.5518, 2.7693,
|
||||
0.1543, 0.3519, 0.6976, 1.0664, 1.3696, 1.7817, 2.1308, 2.4259, 2.707, 2.8753,
|
||||
0.3304, 0.4283, 0.5942, 0.7425, 0.8906, 1.4067, 2.0676, 2.246, 2.5394, 2.7006,
|
||||
0.208, 0.3215, 0.6278, 0.7882, 1.3123, 1.5592, 1.8048, 2.0831, 2.4303, 2.6266,
|
||||
0.1188, 0.2481, 0.827, 1.242, 1.5824, 1.8976, 2.1816, 2.4248, 2.6645, 2.8459,
|
||||
0.0635, 0.1528, 0.5973, 0.9377, 1.2653, 1.5465, 1.8818, 2.1681, 2.5089, 2.7924,
|
||||
0.3249, 0.5179, 0.9143, 1.2973, 1.4966, 1.755, 2.0715, 2.3166, 2.65, 2.8305,
|
||||
0.1918, 0.3107, 0.4506, 0.6994, 1.3463, 1.5348, 1.8447, 2.1903, 2.448, 2.6877,
|
||||
0.3405, 0.4644, 0.7232, 0.9199, 1.2611, 1.5175, 1.8446, 2.0652, 2.3915, 2.5781,
|
||||
0.3289, 0.5152, 0.6602, 1.0213, 1.1886, 1.5496, 1.9553, 2.1883, 2.5394, 2.7362,
|
||||
0.3, 0.4097, 0.8372, 1.0793, 1.3095, 1.5684, 1.8746, 2.0783, 2.3643, 2.549,
|
||||
0.2421, 0.328, 0.5288, 0.9261, 1.6911, 1.8959, 2.1013, 2.2823, 2.5238, 2.696,
|
||||
0.107, 0.3131, 0.6226, 0.8881, 1.1808, 1.4867, 1.8146, 2.1088, 2.4594, 2.7186,
|
||||
0.44, 0.5533, 0.7025, 0.9206, 1.4089, 1.582, 1.808, 2.0832, 2.3577, 2.53,
|
||||
0.225, 0.3434, 0.4808, 0.6721, 0.8198, 1.1446, 2.0201, 2.2625, 2.552, 2.7604,
|
||||
0.1671, 0.2551, 0.4603, 0.6777, 0.9661, 1.5579, 1.8659, 2.1196, 2.4425, 2.6551,
|
||||
0.391, 0.5877, 1.0287, 1.3547, 1.6899, 1.9166, 2.1451, 2.3337, 2.5519, 2.7071,
|
||||
0.1435, 0.2165, 0.3968, 0.8376, 1.2572, 1.5298, 1.8791, 2.1352, 2.4636, 2.7011,
|
||||
0.1756, 0.2799, 0.412, 0.5808, 0.7573, 1.334, 1.8235, 2.12, 2.4993, 2.7365,
|
||||
0.1332, 0.2174, 0.4716, 0.9483, 1.2723, 1.6028, 1.9272, 2.219, 2.5588, 2.799,
|
||||
0.2122, 0.3143, 0.7042, 0.8849, 1.1312, 1.3711, 1.6832, 1.9633, 2.2685, 2.5156,
|
||||
0.2089, 0.3339, 0.4817, 0.8526, 1.0657, 1.2741, 1.5747, 1.8, 2.486, 2.6843,
|
||||
0.1636, 0.2617, 0.44, 0.7357, 1.0355, 1.2638, 1.5672, 1.8504, 2.1904, 2.6588,
|
||||
0.1945, 0.2934, 0.4869, 0.8567, 1.1262, 1.3604, 1.6898, 1.9143, 2.1475, 2.3503,
|
||||
0.1606, 0.2442, 0.3931, 0.9237, 1.5811, 1.7529, 2.0133, 2.2272, 2.525, 2.7265,
|
||||
0.4866, 0.7045, 1.0593, 1.2795, 1.5326, 1.8221, 2.1461, 2.3665, 2.6041, 2.7599,
|
||||
0.4012, 0.4911, 0.7103, 0.8585, 1.0495, 1.7244, 2.0116, 2.2041, 2.5189, 2.6643,
|
||||
0.4365, 0.6694, 0.8644, 1.133, 1.451, 1.7627, 2.1032, 2.369, 2.628, 2.8306,
|
||||
0.2072, 0.4018, 0.6227, 0.8913, 1.3038, 1.6056, 1.9704, 2.2816, 2.6135, 2.8182,
|
||||
0.3302, 0.4968, 0.8713, 1.0761, 1.2576, 1.4654, 1.8152, 2.14, 2.5404, 2.7493,
|
||||
0.1385, 0.2292, 0.353, 0.6006, 1.4699, 1.6571, 1.9438, 2.1663, 2.5027, 2.7308,
|
||||
0.1894, 0.2915, 0.4345, 0.6341, 1.0024, 1.1896, 1.6896, 2.0966, 2.4086, 2.6768,
|
||||
0.3841, 0.5197, 0.8889, 1.148, 1.4383, 1.6285, 1.8642, 2.0669, 2.3466, 2.5325,
|
||||
0.2008, 0.3097, 0.4664, 0.6638, 1.2798, 1.494, 1.727, 2.0264, 2.2915, 2.475,
|
||||
0.1864, 0.2857, 0.4481, 1.1025, 1.3096, 1.5035, 1.7614, 1.9891, 2.4255, 2.6031,
|
||||
0.4081, 0.6134, 0.9514, 1.1818, 1.3943, 1.6361, 1.9891, 2.2395, 2.5547, 2.7287,
|
||||
0.2964, 0.3876, 0.945, 1.2247, 1.3906, 1.5882, 1.8241, 2.0589, 2.4188, 2.5871,
|
||||
0.3127, 0.4038, 0.6168, 1.081, 1.3067, 1.4759, 1.8817, 2.0781, 2.3394, 2.5539,
|
||||
0.2066, 0.3059, 0.4989, 0.7132, 0.9066, 1.446, 1.7584, 1.9755, 2.221, 2.4741,
|
||||
0.2634, 0.3956, 0.5667, 0.8777, 1.0517, 1.6029, 2.059, 2.2607, 2.6064, 2.7647,
|
||||
0.4331, 0.5315, 0.7764, 1.0444, 1.2269, 1.4311, 1.7093, 1.9187, 2.4337, 2.6149,
|
||||
0.2161, 0.4429, 0.6851, 0.8336, 1.1037, 1.2966, 1.5283, 2.0299, 2.3407, 2.5384,
|
||||
0.2814, 0.3637, 0.5416, 0.9475, 1.5137, 1.6945, 1.8892, 2.1017, 2.319, 2.5007,
|
||||
0.4454, 0.6883, 1.1402, 1.4098, 1.7435, 2.0014, 2.2521, 2.4457, 2.6495, 2.7985,
|
||||
0.1641, 0.4083, 0.6426, 1.0592, 1.3258, 1.5754, 1.8666, 2.1381, 2.4572, 2.7177,
|
||||
0.3391, 0.4607, 0.6072, 0.8463, 1.4207, 1.6062, 1.8303, 2.0887, 2.3615, 2.5348,
|
||||
0.2414, 0.3396, 0.51, 0.747, 1.3329, 1.8618, 2.0751, 2.2564, 2.5147, 2.6874,
|
||||
0.1694, 0.2535, 0.4156, 0.8302, 1.2853, 1.5838, 2.0907, 2.3085, 2.5929, 2.7951,
|
||||
0.2047, 0.3652, 0.65, 0.8068, 1.0178, 1.1865, 1.4889, 2.0671, 2.5966, 2.7634,
|
||||
0.2425, 0.3247, 0.602, 1.2226, 1.4272, 1.5996, 1.8377, 2.0413, 2.5333, 2.7021,
|
||||
0.3842, 0.503, 0.6541, 0.8771, 1.0576, 1.2612, 1.6744, 1.8735, 2.4781, 2.6803,
|
||||
0.2042, 0.328, 0.7283, 0.8985, 1.1444, 1.3299, 1.6032, 2.1539, 2.4739, 2.6547,
|
||||
0.1268, 0.1924, 0.3208, 0.5153, 1.1304, 1.4443, 1.8047, 2.0552, 2.4385, 2.7572,
|
||||
0.2713, 0.3659, 0.5395, 1.0705, 1.4228, 1.5836, 1.9763, 2.1641, 2.4459, 2.6301,
|
||||
0.3047, 0.4043, 0.5727, 0.7368, 0.8997, 1.3242, 1.6473, 1.8879, 2.433, 2.6295,
|
||||
0.1224, 0.3948, 0.6903, 0.9199, 1.2852, 1.5516, 1.8645, 2.1231, 2.4657, 2.7044,
|
||||
0.2157, 0.3281, 0.5036, 0.9272, 1.0975, 1.5285, 1.808, 2.0569, 2.5448, 2.7221,
|
||||
0.167, 0.249, 0.3696, 0.5921, 1.3019, 1.8398, 2.2165, 2.3725, 2.6142, 2.8338,
|
||||
0.3899, 0.5573, 0.81, 1.0732, 1.3966, 1.6598, 2.0001, 2.2517, 2.5548, 2.7403,
|
||||
0.4905, 0.6064, 0.8222, 0.9966, 1.1912, 1.5714, 1.9628, 2.1727, 2.53, 2.7055,
|
||||
0.1309, 0.2342, 0.6232, 0.8795, 1.1283, 1.3655, 1.7371, 2.0251, 2.3992, 2.6885,
|
||||
0.1805, 0.2672, 0.4297, 1.244, 1.4967, 1.6796, 1.9592, 2.1784, 2.5439, 2.7289,
|
||||
0.228, 0.5429, 0.6967, 0.8732, 1.4074, 1.6074, 1.9516, 2.2124, 2.5486, 2.7722,
|
||||
0.2339, 0.3379, 0.4924, 0.9061, 1.3074, 1.4719, 1.8884, 2.111, 2.3618, 2.5545,
|
||||
0.1384, 0.2291, 0.5127, 1.045, 1.4017, 1.7884, 2.1134, 2.3664, 2.6588, 2.8435,
|
||||
0.2196, 0.6359, 0.91, 1.2007, 1.4589, 1.7053, 2.0128, 2.2722, 2.552, 2.7643,
|
||||
0.1698, 0.2615, 0.381, 0.5706, 1.4297, 1.8686, 2.0728, 2.2559, 2.486, 2.6701,
|
||||
0.1445, 0.2158, 0.3658, 0.5451, 0.9389, 1.3669, 1.79, 2.0846, 2.3924, 2.7161,
|
||||
0.2789, 0.3816, 0.5277, 0.8487, 1.3751, 1.5461, 1.7832, 2.0264, 2.2695, 2.4665,
|
||||
0.1733, 0.3023, 0.9216, 1.2368, 1.4776, 1.7229, 1.9952, 2.2471, 2.539, 2.7265,
|
||||
0.3374, 0.5033, 1.0951, 1.3262, 1.5284, 1.7336, 1.9733, 2.2009, 2.4992, 2.6751,
|
||||
0.1293, 0.2743, 0.7533, 1.0166, 1.2416, 1.4444, 1.7962, 2.0851, 2.477, 2.7204,
|
||||
0.3106, 0.4176, 0.6358, 0.9434, 1.1419, 1.3458, 1.9638, 2.1678, 2.439, 2.6235,
|
||||
0.4533, 0.576, 0.7392, 0.9136, 1.0829, 1.2759, 1.7903, 2.036, 2.3124, 2.5325,
|
||||
0.3702, 0.5218, 0.6977, 0.8776, 1.1096, 1.2855, 1.5612, 1.948, 2.217, 2.4361,
|
||||
0.1637, 0.2647, 0.4185, 0.6666, 1.1584, 1.327, 1.7829, 1.9821, 2.4361, 2.7094,
|
||||
0.1769, 0.2767, 0.3942, 0.5746, 1.3595, 1.711, 1.9176, 2.1405, 2.3722, 2.5705,
|
||||
0.2712, 0.382, 0.6524, 0.8317, 1.0341, 1.3972, 1.7312, 1.9918, 2.3854, 2.5886,
|
||||
0.1003, 0.2046, 0.7261, 1.1004, 1.4057, 1.6697, 1.9903, 2.2603, 2.5813, 2.8009,
|
||||
0.2534, 0.3752, 0.7192, 0.9323, 1.3698, 1.5955, 1.8653, 2.0656, 2.3368, 2.534,
|
||||
0.3589, 0.4508, 0.6631, 1.0521, 1.5065, 1.6697, 1.8929, 2.1074, 2.3466, 2.5242,
|
||||
0.1955, 0.2862, 0.6111, 0.8053, 1.0501, 1.5218, 1.7996, 2.0303, 2.3788, 2.5973,
|
||||
0.2982, 0.4033, 0.566, 0.8924, 1.1933, 1.3465, 1.7895, 2.0173, 2.2606, 2.5069,
|
||||
0.3356, 0.4711, 0.631, 0.8491, 1.0049, 1.4364, 1.8176, 2.0292, 2.571, 2.7525,
|
||||
0.2016, 0.2912, 0.4363, 0.98, 1.4897, 1.6494, 1.8862, 2.0819, 2.3636, 2.6091,
|
||||
0.4549, 0.6491, 0.845, 1.0209, 1.1747, 1.3745, 1.8824, 2.113, 2.376, 2.5768,
|
||||
0.251, 0.3524, 0.5171, 0.8931, 1.4094, 1.571, 1.8536, 2.0478, 2.4766, 2.732,
|
||||
0.1576, 0.2547, 0.3891, 0.8551, 1.4282, 1.588, 1.8583, 2.0521, 2.5359, 2.734,
|
||||
0.3481, 0.4382, 0.772, 1.1289, 1.3203, 1.5019, 1.7665, 1.957, 2.2231, 2.4465,
|
||||
0.3116, 0.4068, 0.6991, 0.8894, 1.0912, 1.5356, 1.8084, 2.0006, 2.2323, 2.4367,
|
||||
0.2706, 0.4033, 0.8272, 1.0851, 1.482, 1.6927, 1.9292, 2.1267, 2.4049, 2.5857,
|
||||
0.2745, 0.355, 0.8663, 1.3742, 1.5545, 1.7324, 1.9664, 2.1538, 2.4581, 2.6245,
|
||||
0.1736, 0.2553, 0.5357, 0.9009, 1.1888, 1.5132, 1.8579, 2.1181, 2.4273, 2.6847,
|
||||
0.3026, 0.4148, 0.9044, 1.1695, 1.3657, 1.7036, 1.9891, 2.2226, 2.5441, 2.7085,
|
||||
0.3998, 0.5108, 0.7205, 0.9848, 1.1828, 1.3716, 1.7154, 1.9191, 2.1875, 2.4257,
|
||||
0.2141, 0.3095, 0.7428, 1.0426, 1.2851, 1.5571, 1.7901, 1.9804, 2.2462, 2.5265,
|
||||
0.1574, 0.229, 0.3869, 0.5735, 1.0925, 1.3383, 1.6598, 1.9364, 2.2095, 2.4195
|
||||
};
|
||||
/* codebook/lspvqanssi2.txt */
|
||||
static const float codes1[] = {
|
||||
0.012, 0.0022, 0.0068, -0.0112, -0.0508, -0.049, 0.2249, 0.1476, 0.0133, -0.0379,
|
||||
0.0598, 0.0477, 0.038, 0.066, 0.0517, 0.015, 0.0617, 0.0081, -0.0768, -0.1007,
|
||||
-0.0087, -0.044, 0.0873, 0.0882, 0.0391, -0.006, 0.11, 0.0569, -0.0241, -0.0468,
|
||||
0.0146, -0.0005, 0.0322, -0.065, -0.0778, -0.078, -0.0255, -0.0527, -0.0301, -0.0401,
|
||||
-0.024, -0.056, -0.0374, 0.0274, 0.0484, -0.0227, 0.0328, 0.1135, 0.0117, -0.03,
|
||||
-0.0324, -0.0574, 0.0302, 0.0137, -0.0603, -0.1194, -0.0105, -0.0513, 0.0698, 0.0538,
|
||||
0.0635, 0.0382, 0.0531, 0.0897, 0.0495, 0.0039, -0.0421, -0.0919, 0.0407, 0.0167,
|
||||
0.0954, 0.0854, 0.036, -0.0025, -0.0252, -0.0528, -0.0435, -0.0561, -0.0405, -0.0432,
|
||||
0.011, -0.001, -0.0433, -0.0167, 0.1402, 0.0738, 0.0423, -0.0024, -0.092, -0.1099,
|
||||
0.0179, 0.0184, -0.0041, -0.064, 0.1004, 0.0608, -0.0023, -0.0357, 0.1509, 0.1262,
|
||||
-0.0145, -0.024, -0.0595, -0.1063, 0.0597, -0.004, -0.0886, 0.1184, 0.038, 0.0126,
|
||||
-0.0072, 0.0172, 0.0076, 0.0288, 0.081, 0.0278, 0.0709, 0.0051, 0.0214, -0.0301,
|
||||
0.0127, -0.0126, -0.0434, 0.161, 0.1178, 0.0704, 0.0257, -0.0073, -0.0425, -0.061,
|
||||
-0.0165, -0.0369, -0.0785, 0.1007, 0.0309, -0.0651, 0.0142, -0.0614, 0.0426, 0.0289,
|
||||
-0.0374, -0.0712, 0.0049, -0.0382, 0.0472, 0.0095, -0.0268, -0.0747, -0.0457, -0.0758,
|
||||
-0.0211, -0.0432, -0.0547, -0.0446, -0.1078, 0.009, -0.0565, -0.1298, 0.0721, 0.0351,
|
||||
-0.0014, -0.0072, -0.0283, -0.0324, -0.0208, -0.0703, 0.0979, 0.0865, -0.0007, 0.1881,
|
||||
-0.0077, -0.0302, 0.1231, 0.0905, 0.0786, 0.0432, -0.0286, -0.0661, -0.0055, -0.0275,
|
||||
0.001, 0.0043, 0.0044, 0.038, -0.1201, -0.0098, -0.0166, 0.0105, 0.0153, 0.0134,
|
||||
0.0843, 0.0636, 0.0416, -0.0004, -0.057, -0.0592, 0.1158, 0.059, 0.0126, 0.0034,
|
||||
0.0346, 0.029, -0.0037, -0.0026, -0.0457, 0.1824, 0.1469, 0.087, 0.0291, -0.0074,
|
||||
0.0066, 0.0682, -0.0148, 0.0287, 0.0095, -0.0563, 0.1296, 0.0426, 0.1215, 0.0886,
|
||||
-0.0132, -0.0399, 0.096, 0.0474, 0.014, 0.0306, -0.0192, -0.0703, -0.1559, -0.1556,
|
||||
-0.06, 0.0482, 0.1257, 0.0521, 0.0229, -0.0031, 0.0817, 0.0571, -0.0138, -0.0277,
|
||||
0.0013, -0.0103, -0.047, -0.0687, -0.1444, 0.0181, 0.135, 0.0559, -0.0177, -0.0598,
|
||||
-0.0215, -0.0318, -0.0689, -0.0268, 0.0917, 0.0307, 0.0135, -0.0184, -0.0857, 0.1231,
|
||||
0.0137, -0.0152, 0.0199, -0.0291, -0.0685, 0.0438, -0.1137, 0.0231, -0.0632, -0.0802,
|
||||
-0.0011, 0.0314, 0.0535, -0.0135, -0.0291, -0.0579, -0.1049, 0.0288, -0.0628, 0.1355,
|
||||
-0.0901, 0.0041, -0.017, 0.0351, 0.0144, -0.0505, 0.0396, 0.0638, -0.0145, 0.0141,
|
||||
-0.04, -0.0603, -0.0714, 0.0329, -0.0049, -0.0529, -0.1251, 0.0022, -0.0449, -0.0778,
|
||||
0.0247, 0.0296, 0.0239, 0.0122, -0.0348, -0.1224, -0.0033, 0.1237, -0.0016, -0.0436,
|
||||
0.0246, 0.005, 0.0322, 0.0818, 0.0203, 0.0846, 0.0022, 0.0876, 0.0149, -0.0184,
|
||||
-0.0204, -0.0228, 0.0365, -0.0164, 0.1087, 0.0374, -0.055, 0.033, -0.0582, -0.0736,
|
||||
-0.0305, -0.0485, -0.0572, 0.0275, -0.0271, -0.0436, 0.1217, 0.07, 0.1253, 0.099,
|
||||
-0.0079, -0.0204, -0.0325, 0.0491, 0.0158, -0.0365, -0.1309, -0.1812, 0.1428, 0.1148,
|
||||
0.068, 0.0547, 0.0309, 0.0079, -0.0332, 0.0391, -0.0287, 0.1258, 0.1123, 0.1016,
|
||||
-0.0264, -0.0409, -0.0538, -0.0192, -0.0393, -0.0713, -0.0618, -0.1078, -0.185, 0.0532,
|
||||
0.0081, -0.0115, -0.009, 0.1201, -0.0413, -0.0995, 0.0445, -0.0032, -0.0286, -0.0497,
|
||||
-0.0023, -0.0184, -0.0358, 0.1279, 0.0847, 0.053, 0.023, -0.0212, 0.1245, 0.0965,
|
||||
0.0111, 0.1038, 0.0597, 0.0413, 0.0533, 0.0011, 0.0031, 0.0705, 0.0242, 0.0198,
|
||||
0.002, -0.0071, -0.0262, -0.0496, -0.075, -0.1273, -0.1785, 0.0606, -0.0223, -0.0583,
|
||||
-0.0202, 0.0669, 0.0081, 0.0335, -0.0218, -0.1073, -0.0146, -0.0673, 0.049, 0.021,
|
||||
-0.0108, -0.023, -0.0614, -0.0986, 0.0629, 0.0006, 0.1496, 0.1099, 0.0316, 0.0098,
|
||||
-0.0368, -0.0685, 0.0138, -0.0213, -0.0009, 0.0344, -0.0249, 0.0311, 0.0803, 0.0759,
|
||||
0.0038, -0.0158, 0.0142, 0.0254, 0.097, 0.0021, -0.1029, 0.0006, 0.0576, 0.0261,
|
||||
-0.0083, 0.0698, 0.0406, -0.0348, 0.02, 0.0833, 0.0186, -0.0145, -0.0725, -0.0872,
|
||||
-0.0506, -0.0673, 0.0776, -0.0172, -0.0444, -0.0531, -0.0799, 0.0005, -0.0359, -0.0446,
|
||||
0.0368, 0.0376, -0.0407, -0.019, 0.0987, 0.0212, -0.0349, -0.0951, -0.0084, -0.0342,
|
||||
-0.0309, -0.0561, 0.095, -0.0125, -0.1028, -0.0133, 0.092, 0.0965, 0.0668, 0.0409,
|
||||
-0.0898, 0.0036, -0.0353, -0.0024, -0.0365, -0.0259, -0.0485, -0.0843, -0.0063, -0.0167,
|
||||
-0.0255, -0.0407, -0.0456, -0.0931, -0.0892, -0.0293, -0.051, 0.0183, -0.0104, 0.0472,
|
||||
-0.0172, -0.0399, -0.0731, 0.0546, 0.032, -0.0283, 0.0415, -0.0107, -0.1237, -0.1102,
|
||||
0.021, 0.0294, -0.0038, -0.009, -0.0551, -0.0922, 0.0261, -0.0334, -0.1181, -0.1536,
|
||||
0.0092, 0.0032, -0.0162, 0.0398, 0.0205, 0.1266, -0.0107, -0.0858, 0.0392, 0.0032,
|
||||
-0.0038, -0.0269, -0.0737, 0.1138, 0.0263, -0.0031, -0.1188, 0.1621, 0.0831, 0.0526,
|
||||
0.0023, -0.0149, -0.0497, 0.0898, 0.0456, -0.0145, -0.0928, -0.1507, -0.0611, -0.0938,
|
||||
0.012, 0.0124, -0.0286, -0.1319, 0.0219, 0.0311, -0.0398, -0.0465, -0.0008, -0.0375,
|
||||
0.0138, 0.0023, 0.0024, 0.1072, 0.0531, 0.0006, 0.0292, -0.0115, -0.062, 0.165,
|
||||
0.007, -0.0251, 0.0715, 0.038, -0.0404, 0.123, 0.0629, 0.0096, 0.0973, 0.0641,
|
||||
-0.0586, 0.0772, 0.0128, 0.106, 0.0715, 0.0374, -0.0074, -0.0365, -0.0543, -0.0489,
|
||||
-0.0392, 0.0871, -0.0069, -0.1084, 0.0264, -0.0495, 0.0396, 0.0005, -0.0293, -0.024,
|
||||
-0.0327, 0.0605, 0.0662, 0.01, -0.0007, -0.0525, -0.0812, -0.0686, -0.0873, -0.083,
|
||||
0.0119, 0.0058, 0.003, -0.0307, 0.065, 0.0175, -0.0741, -0.15, -0.1947, 0.0881,
|
||||
0.0572, 0.0411, 0.0152, -0.0127, -0.0589, -0.051, -0.0212, -0.0834, 0.1434, 0.1318,
|
||||
0.0518, 0.0417, -0.043, 0.0963, -0.0014, 0.0173, 0.0234, -0.0273, 0.0359, -0.0118,
|
||||
0.0652, 0.0587, 0.0013, -0.07, 0.1262, 0.0975, 0.068, 0.0598, 0.0048, -0.0305,
|
||||
-0.0185, -0.044, 0.1178, 0.0656, 0.0052, -0.0534, -0.1151, 0.1116, 0.0659, 0.0344,
|
||||
0.0788, 0.0577, 0.0452, 0.0283, -0.0278, 0.0911, 0.028, -0.0254, 0.0029, -0.0361,
|
||||
-0.0165, -0.0322, -0.0526, -0.1057, 0.0927, 0.0293, -0.1026, -0.1671, 0.047, 0.0355,
|
||||
0.01, 0.0001, -0.0221, -0.0775, -0.1109, -0.1416, 0.0884, 0.0441, 0.0632, 0.0409,
|
||||
0.0204, 0.0432, 0.0141, -0.0296, 0.1073, 0.058, 0.0383, 0.027, -0.0857, 0.1246,
|
||||
0.0488, 0.0231, 0.0648, -0.0179, 0.0747, 0.0156, -0.0384, -0.0733, -0.0732, -0.097,
|
||||
0.0005, -0.0199, -0.026, -0.0511, -0.111, 0.067, -0.0413, 0.1571, 0.0498, 0.0191,
|
||||
0.0037, -0.0085, -0.0796, 0.0086, -0.0852, 0.085, 0.0115, -0.0065, 0.1161, 0.0727,
|
||||
0.0023, 0.0483, 0.0285, -0.0642, -0.0477, 0.0175, 0.0346, 0.0452, 0.0655, 0.0284,
|
||||
-0.0986, 0.0463, 0.0326, -0.0055, 0.0702, 0.0194, -0.0423, -0.0107, 0.0338, 0.0619,
|
||||
0.0126, -0.0138, -0.1115, 0.0159, -0.0331, 0.0217, -0.0376, -0.0407, -0.0222, -0.0503,
|
||||
0.0222, 0.0071, -0.049, 0.1017, 0.0551, -0.0164, 0.1578, 0.1059, 0.0025, -0.0107,
|
||||
0.0124, -0.009, 0.0322, 0.093, 0.0281, -0.0403, -0.0781, 0.0125, -0.067, -0.1058,
|
||||
0.0363, 0.0077, 0.1052, 0.0039, 0.0676, 0.0891, 0.0433, 0.0252, 0.0224, -0.0043,
|
||||
-0.0045, -0.0194, -0.0193, -0.048, -0.064, -0.0695, -0.1597, -0.003, 0.1728, 0.1231,
|
||||
0.0297, 0.0025, 0.0619, -0.0347, -0.1171, 0.1043, 0.0868, 0.0191, -0.0739, -0.1075,
|
||||
0.0073, 0.0914, 0.0367, -0.0236, 0.0232, 0.0304, -0.0787, -0.1099, 0.046, 0.0082,
|
||||
0.0296, 0.0297, -0.0444, 0.0184, 0.0602, -0.0295, -0.0934, 0.0636, -0.0347, -0.0722,
|
||||
-0.029, -0.0629, 0.0598, 0.0013, 0.0064, 0.1431, 0.092, 0.0468, -0.0311, -0.0614,
|
||||
-0.0152, -0.0311, -0.05, -0.0672, -0.1257, -0.0134, -0.022, -0.0612, -0.1131, -0.1417,
|
||||
0.0371, 0.0153, -0.0817, -0.0007, 0.0837, 0.0481, 0.046, 0.0678, 0.0524, 0.0432,
|
||||
0.0126, -0.0069, -0.0092, -0.0693, -0.025, 0.151, 0.0098, -0.0683, -0.0566, -0.0769,
|
||||
-0.0199, -0.0423, 0.0806, 0.0562, 0.0009, -0.0563, -0.1358, -0.1578, -0.0456, 0.0032,
|
||||
0.0091, 0.0101, -0.009, -0.0279, -0.0489, -0.1038, -0.0815, 0.2184, 0.1172, 0.0902,
|
||||
-0.0024, -0.0135, 0.0392, 0.0028, 0.0792, 0.0404, 0.0867, 0.161, 0.0954, 0.0846,
|
||||
-0.0004, -0.022, -0.0282, -0.1022, -0.0799, 0.1278, 0.0765, 0.0402, 0.085, 0.0611,
|
||||
0.0443, 0.032, -0.0384, -0.0964, 0.003, -0.0398, -0.073, -0.0052, -0.0267, 0.1209,
|
||||
-0.0706, 0.1151, 0.0722, -0.0175, -0.0927, -0.0559, 0.0316, 0.0186, 0.0105, 0.0314,
|
||||
-0.0145, -0.0263, -0.0564, 0.0248, -0.0181, -0.0817, -0.0938, 0.0366, -0.0315, 0.1253,
|
||||
0.0307, 0.0039, 0.129, 0.0402, -0.0439, -0.0384, 0.0044, -0.0177, -0.0172, -0.031,
|
||||
0.0447, 0.0298, 0.0287, 0.0273, -0.035, -0.0708, -0.1829, -0.0317, 0.0643, 0.0057,
|
||||
-0.082, -0.0326, 0.0209, -0.0711, 0.0084, 0.0111, 0.0426, 0.0262, -0.0061, 0.0005,
|
||||
0.0545, 0.0377, -0.0417, -0.0625, 0.0114, -0.0405, 0.0573, 0.0191, -0.0263, -0.0472,
|
||||
-0.0053, -0.0049, -0.0255, -0.0578, -0.0237, -0.0721, -0.1487, -0.1636, 0.0046, -0.0355,
|
||||
0.0309, 0.0107, 0.0163, 0.0132, -0.0536, -0.0009, -0.0706, -0.135, -0.0514, -0.096,
|
||||
0.0306, 0.0003, 0.0494, 0.0701, 0.0027, -0.0458, 0.078, 0.0327, 0.0937, 0.0605,
|
||||
-0.0017, -0.0275, 0.0797, -0.0268, -0.1014, 0.0593, -0.0528, -0.1103, 0.0682, 0.0322,
|
||||
-0.0507, -0.0806, -0.0646, -0.0052, -0.0576, 0.0451, 0.0489, 0.015, 0.0029, -0.0189,
|
||||
0.027, 0.0143, -0.0375, -0.0071, -0.0607, -0.1157, -0.0345, -0.1115, 0.0201, -0.0104,
|
||||
-0.0807, -0.1088, 0.0845, 0.072, 0.0441, 0.0301, 0.0043, 0.0052, 0.0016, 0.0201,
|
||||
-0.029, -0.0532, 0.0036, -0.0201, -0.0723, -0.1321, 0.0867, 0.0479, -0.0556, -0.085,
|
||||
-0.0271, 0.0126, 0.1283, 0.0533, -0.003, -0.0352, -0.0326, -0.0553, 0.1402, 0.1121,
|
||||
-0.0358, -0.0518, -0.108, 0.0134, 0.095, 0.0384, -0.004, -0.0254, 0.0026, -0.0217,
|
||||
-0.0152, -0.0375, -0.0827, 0.0916, 0.0188, 0.1306, 0.0983, 0.0606, 0.0381, 0.008,
|
||||
-0.0107, -0.0269, -0.0573, -0.1189, 0.0258, 0.1009, 0.0565, 0.027, -0.0557, -0.0778,
|
||||
-0.0193, -0.0242, -0.0784, -0.0816, 0.0287, -0.0484, 0.0292, -0.0414, 0.1124, 0.0767,
|
||||
0.0177, -0.0148, 0.0472, -0.0808, 0.0623, -0.0636, 0.075, -0.0107, 0.0673, 0.0425,
|
||||
-0.022, 0.0577, -0.0769, -0.0247, -0.0321, 0.0341, -0.0108, 0.0109, -0.0142, 0.0122,
|
||||
0.0194, 0.0248, -0.0096, -0.0205, -0.046, -0.116, 0.0492, -0.0188, -0.1535, 0.0816,
|
||||
0.0301, -0.0286, -0.0077, -0.0117, -0.0036, -0.0026, 0.0133, -0.0032, 0.0007, -0.016,
|
||||
0.0115, -0.0111, 0.0246, -0.0639, 0.0325, -0.0313, 0.0808, 0.0435, -0.0777, -0.1108,
|
||||
-0.0079, -0.0334, -0.0144, -0.0539, 0.1564, 0.1175, 0.0549, 0.034, 0.0319, 0.0027,
|
||||
-0.0155, -0.0275, -0.0739, -0.0932, 0.0108, -0.0698, 0.0036, -0.0213, -0.0486, -0.067,
|
||||
-0.0234, -0.0567, 0.002, 0.0908, -0.0151, 0.046, -0.0175, -0.0523, 0.0098, -0.0237,
|
||||
0.0057, -0.0066, -0.0418, 0.0418, -0.0449, 0.1069, 0.0629, -0.0016, -0.1068, -0.1492,
|
||||
-0.0791, 0.0403, -0.0009, 0.0285, -0.0065, 0.0963, 0.055, 0.0634, 0.0693, 0.0694,
|
||||
-0.0068, -0.0197, -0.0919, 0.0071, -0.0551, -0.1173, 0.0926, 0.0413, 0.0127, -0.0158,
|
||||
0.054, 0.0389, -0.0195, -0.08, -0.1383, 0.044, -0.0139, -0.0405, 0.0147, -0.0183,
|
||||
0.038, 0.0248, 0.052, -0.0609, 0.0339, -0.007, -0.0974, 0.1182, 0.0221, -0.031,
|
||||
0.0043, 0.0046, -0.0274, -0.0502, 0.0326, -0.0143, -0.0586, -0.0866, -0.1673, -0.1624,
|
||||
0.0428, 0.0385, -0.0228, 0.0704, 0.0069, -0.0145, -0.0623, -0.0639, -0.1479, 0.0212,
|
||||
-0.0078, -0.0297, 0.0025, -0.0239, -0.0793, 0.0896, 0.0315, -0.0546, -0.1309, 0.108
|
||||
};
|
||||
/* codebook/lspvqanssi3.txt */
|
||||
static const float codes2[] = {
|
||||
-0.0291, 0.0272, -0.0364, -0.0313, -0.0487, -0.0205, 0.0501, 0.0225, 0.0178, 0.008,
|
||||
-0.0406, -0.0383, 0.0013, -0.0155, -0.0261, -0.0598, 0.0003, -0.0242, 0.0151, -0.014,
|
||||
-0.0445, 0.0356, 0.018, -0.0272, -0.0018, -0.0177, -0.0703, 0.0471, 0.0128, -0.0068,
|
||||
-0.0033, -0.0285, -0.056, -0.0186, -0.0499, -0.007, 0.0068, -0.0126, 0.0388, -0.0097,
|
||||
-0.0071, -0.0114, -0.0308, -0.0094, -0.0541, -0.0272, -0.0756, 0.0477, -0.0234, 0.0678,
|
||||
0.0048, 0.0307, -0.0174, -0.0593, 0.0097, -0.0134, 0.0034, -0.0212, -0.0418, 0.0869,
|
||||
-0.0189, 0.0165, -0.0269, 0.0744, 0.0344, -0.0177, -0.0603, 0.0212, -0.0104, 0.0345,
|
||||
-0.013, -0.0352, -0.0086, -0.0257, -0.0286, 0.0409, 0.0656, 0.0106, -0.0598, 0.0252,
|
||||
0.0041, 0.0097, -0.0032, -0.0154, -0.0405, 0.067, -0.0164, 0.0451, 0.0774, 0.0504,
|
||||
0.001, -0.0091, -0.0345, 0.0511, 0.0016, 0.0011, 0.0684, 0.0167, 0.0601, 0.0512,
|
||||
0.0204, -0.0038, -0.0426, 0.0185, -0.0191, -0.063, 0.0295, -0.0153, -0.0559, 0.056,
|
||||
-0.0461, -0.0041, 0.0515, 0.0219, 0.0322, 0.0093, 0.0044, 0.0106, -0.0329, -0.0521,
|
||||
0.0304, 0.0017, 0.0209, -0.0002, 0.0689, 0.0136, 0.0216, -0.0268, -0.0682, 0.0333,
|
||||
-0.0175, -0.0425, 0.0153, -0.005, -0.0113, 0.0297, -0.0659, -0.0344, 0.0302, -0.0272,
|
||||
-0.0217, -0.0362, 0.0426, 0.0233, -0.0393, 0.0052, 0.0138, 0.0657, 0.0427, 0.022,
|
||||
-0.0039, -0.0011, -0.0002, -0.0453, -0.0835, 0.0144, -0.0268, -0.0589, -0.0185, 0.0133,
|
||||
0.0081, -0.0032, 0.0638, 0.0032, 0.006, 0.0002, -0.0303, -0.0823, 0.0124, -0.0308,
|
||||
0.0108, 0.0011, 0.0059, 0.0396, 0.0392, 0.0351, -0.0045, -0.0323, -0.0512, -0.0975,
|
||||
-0.0144, -0.0306, -0.0302, -0.007, 0.0123, -0.0042, -0.0083, -0.0514, 0.012, 0.1116,
|
||||
-0.0046, -0.0131, 0.0472, 0.0144, -0.0296, -0.0518, 0.0337, -0.0145, -0.0733, 0.0793,
|
||||
-0.0064, -0.0162, -0.0327, -0.0711, 0.0108, -0.0131, 0.0025, -0.0254, -0.0277, -0.068,
|
||||
-0.0306, 0.0055, 0.0272, -0.0189, -0.0173, 0.0221, 0.0773, 0.0043, 0.0458, -0.0169,
|
||||
-0.0006, 0.0299, 0.0259, 0.0227, -0.053, -0.0596, -0.0271, -0.0091, 0.0181, -0.0233,
|
||||
-0.0116, -0.0398, 0.0089, 0.0708, -0.0028, -0.0084, -0.0206, -0.0354, -0.0275, -0.0037,
|
||||
0.0259, -0.0064, -0.038, 0.0572, 0.0083, 0.0286, -0.0565, 0.0158, 0.0396, -0.0123,
|
||||
0.0552, 0.0331, -0.0052, -0.0346, -0.018, -0.0194, -0.0237, 0.0184, 0.0056, -0.0199,
|
||||
0.0143, 0.0131, -0.0166, 0.0196, 0.0154, 0.031, -0.0048, 0.0901, -0.0333, 0.0761,
|
||||
0.0118, -0.0107, 0.0099, 0.0078, 0.0002, -0.0716, -0.0233, 0.0793, 0.0516, 0.03,
|
||||
0.0204, 0.0243, 0.0192, 0.0181, 0.0001, -0.0243, -0.0764, -0.0622, -0.0324, 0.064,
|
||||
0.0132, 0.0016, -0.0187, -0.0425, 0.0627, 0.0094, -0.0786, 0.0304, 0.0294, -0.0146,
|
||||
-0.0221, -0.0154, 0.0285, -0.0709, 0.0406, 0.0114, 0.0073, -0.0199, 0.0081, 0.0268,
|
||||
0.0227, 0.0055, 0.0163, -0.0447, 0.0246, 0.0795, 0.0239, 0.0211, -0.0145, -0.0576,
|
||||
-0.0119, 0.0637, 0.0278, 0.0202, -0.0086, 0.0389, 0.032, -0.0049, -0.0272, -0.0274,
|
||||
0.004, -0.0211, 0.0426, 0.048, 0.0415, 0.0659, 0.0408, 0.0198, 0.0327, 0.0029,
|
||||
0.043, 0.0311, 0.0083, 0.0353, 0.025, 0.0143, 0.0106, -0.0305, 0.0633, 0.0227,
|
||||
-0.0277, 0.0302, 0.0337, 0.0176, 0.0191, -0.0156, 0.0231, 0.0118, 0.0465, 0.0875,
|
||||
0.0221, 0.0146, 0.0147, -0.0211, -0.0317, -0.0179, -0.0049, -0.0297, -0.1078, -0.0413,
|
||||
-0.0531, 0.018, -0.0066, 0.0365, -0.0033, 0.009, -0.0158, -0.0698, 0.0315, -0.0048,
|
||||
0.0289, 0.0053, 0.0082, 0.0077, -0.0664, 0.0474, 0.0407, -0.0096, 0.0028, -0.0526,
|
||||
-0.0106, -0.0129, -0.0315, 0.0335, -0.0217, -0.0427, 0.0582, 0.0193, -0.0288, -0.0777,
|
||||
-0.0003, -0.0141, -0.0102, 0.0007, -0.0077, -0.0517, -0.0909, 0.0128, -0.0349, -0.0769,
|
||||
-0.0227, -0.0159, -0.0327, 0.0011, 0.0312, 0.01, -0.018, -0.0537, -0.0997, 0.0122,
|
||||
0.019, -0.0139, 0.0341, -0.0131, -0.0368, -0.0138, -0.0074, -0.0415, 0.0791, 0.0503,
|
||||
0.0182, 0.0027, 0.0032, -0.0325, -0.0309, -0.0898, 0.0509, -0.017, 0.0301, -0.0137,
|
||||
0.0233, 0.01, 0.0231, 0.073, 0.0212, -0.0299, 0.044, 0.0041, -0.0101, -0.0251,
|
||||
0.0074, -0.0033, -0.0285, -0.035, 0.0101, 0.0735, 0.0036, -0.0659, 0.0429, -0.0052,
|
||||
0.0148, -0.0035, -0.0233, 0.0079, -0.0142, -0.0402, -0.0358, -0.0985, -0.008, -0.0549,
|
||||
0.0203, 0.0057, -0.0604, 0.0098, 0.0402, 0.0151, 0.05, 0.0058, -0.0086, -0.0401,
|
||||
0.0056, -0.0381, 0.042, -0.0125, 0.0157, -0.0268, 0.0433, 0.0123, -0.0176, -0.0685,
|
||||
0.003, 0.0502, 0.0067, -0.0222, 0.0405, -0.0226, 0.002, -0.0401, -0.0026, -0.0521,
|
||||
0.0317, 0.0089, 0.062, 0.0251, 0.0066, 0.0089, -0.0565, 0.0414, 0.0005, -0.0365,
|
||||
-0.0058, 0.0086, -0.0291, -0.0164, -0.0134, -0.049, -0.0427, -0.0451, 0.0869, 0.0334,
|
||||
0.0024, 0.0328, -0.0415, 0.0003, -0.0287, 0.0193, -0.0547, -0.0222, -0.0196, -0.0571,
|
||||
-0.0271, -0.0397, -0.0431, -0.0043, 0.0332, 0.0093, 0.0082, 0.0585, 0.0282, 0.0004,
|
||||
-0.0251, -0.0167, -0.0289, 0.0196, -0.0363, 0.085, 0.0028, 0.0319, -0.0202, -0.0512,
|
||||
0.0389, 0.0226, 0.0401, -0.0091, -0.0152, 0.0001, 0.0738, 0.0402, 0.0097, 0.031,
|
||||
-0.0126, 0.013, -0.0046, -0.0216, 0.0298, -0.0344, 0.0713, 0.0547, -0.047, -0.0294,
|
||||
0.0125, 0.0044, -0.0028, 0.0209, -0.02, 0.0854, 0.0018, -0.0386, -0.0703, 0.0778,
|
||||
-0.0036, -0.0347, 0.0309, -0.0184, 0.029, -0.0025, -0.0644, 0.0347, -0.0523, 0.0644,
|
||||
0.0064, 0.0295, -0.0017, 0.0282, 0.0176, 0.0027, 0.0246, 0.0967, 0.0401, -0.0231,
|
||||
0.0054, -0.0109, 0.0055, -0.0479, -0.049, -0.0136, -0.0245, 0.0839, 0.0026, -0.0493,
|
||||
0.0128, -0.005, -0.0219, -0.0621, 0.0313, 0.0019, 0.0696, 0.0459, 0.0574, 0.0299,
|
||||
-0.0091, -0.029, -0.0068, 0.0276, 0.0645, -0.015, 0.0015, -0.0374, 0.0415, -0.0124,
|
||||
-0.0171, 0.0177, -0.0138, 0.0034, 0.084, 0.0584, 0.0233, 0.01, 0.0122, 0.0047
|
||||
};
|
||||
/* codebook/lspvqanssi4.txt */
|
||||
static const float codes3[] = {
|
||||
0.0221, -0.0035, -0.0032, -0.0177, -0.0327, 0.0518, -0.011, -0.015, -0.0136, -0.0327,
|
||||
0.0099, -0.0059, 0.0031, -0.0174, 0.0464, -0.024, 0.0251, -0.027, 0.0454, -0.0082,
|
||||
-0.0029, 0.0025, -0.0267, -0.0318, -0.0157, 0.0173, 0.0253, 0.0063, -0.0481, 0.0419,
|
||||
-0.0332, -0.0179, -0.0042, 0.0241, 0.0044, -0.0098, -0.0081, 0.0024, -0.0414, 0.0339,
|
||||
-0.006, 0.0182, -0.0051, -0.0479, 0.0016, -0.0179, 0.0316, 0.0222, -0.0029, -0.0351,
|
||||
0.0074, 0.0015, 0.0337, -0.0082, -0.0008, 0.0129, 0.0001, 0.065, 0.0175, 0.0309,
|
||||
-0.0212, -0.0261, 0.0196, -0.0309, 0.0093, -0.0272, 0.026, 0.0169, 0.0132, 0.0116,
|
||||
-0.001, 0.0202, 0.0228, -0.0227, -0.0141, 0.0192, -0.0423, -0.0097, -0.0342, 0.0338,
|
||||
-0.0149, -0.011, -0.0156, 0.029, 0.0028, 0.0123, -0.035, -0.0501, 0.0272, -0.0245,
|
||||
-0.0005, -0.0194, 0.046, -0.0001, -0.028, 0.0216, -0.0028, -0.0162, 0.0177, -0.0254,
|
||||
-0.0109, -0.0026, 0.0038, -0.015, -0.0421, -0.0422, 0.0164, -0.0436, 0.0054, -0.0098,
|
||||
0.0061, -0.0106, 0.0062, 0.0207, -0.0329, 0.0177, -0.0578, 0.0408, 0.0077, -0.026,
|
||||
0.0001, -0.0098, 0.0106, -0.0003, -0.0292, 0.0032, 0.056, 0.0311, -0.0282, -0.0445,
|
||||
0.0033, 0.0345, -0.0022, -0.0029, -0.0228, 0.0242, 0.0197, -0.0286, 0.0194, -0.0328,
|
||||
0.0094, -0.001, 0.0121, 0.0229, 0.0161, 0.0363, -0.0124, 0.0179, -0.0626, 0.002,
|
||||
-0.007, -0.0272, -0.0171, -0.0249, -0.0039, 0.0254, 0.0317, -0.0324, 0.0276, -0.009,
|
||||
-0.0002, 0.0057, -0.0204, 0.0512, -0.017, 0.0113, 0.0157, 0.0427, -0.0024, 0.0162,
|
||||
-0.0064, -0.0144, 0.0216, 0.0053, -0.0361, 0.0287, 0.023, -0.0161, -0.0189, 0.0589,
|
||||
0.0091, -0.0059, -0.0308, 0.0171, -0.0137, -0.0033, -0.0505, -0.0155, -0.0527, 0.0133,
|
||||
-0.0121, -0.0051, 0.0219, 0.0136, 0.0476, -0.009, -0.046, 0.0208, 0.0072, -0.0076,
|
||||
0.0098, -0.0328, -0.0211, 0.0054, -0.0146, -0.0263, 0.0248, 0.0045, -0.0183, 0.0301,
|
||||
0.0101, 0.0139, -0.0073, 0.0234, 0.0083, -0.0194, -0.0365, 0.0307, 0.058, 0.0153,
|
||||
-0.0111, 0.0019, 0.0265, -0.015, 0.0311, 0.0362, 0.0244, -0.0213, -0.0224, -0.0299,
|
||||
0.0061, 0.0082, -0.0181, 0.0081, -0.0344, 0.0133, -0.0095, -0.0411, 0.0462, 0.0371,
|
||||
0.0089, -0.0157, 0.0179, -0.0256, -0.0118, -0.0302, -0.0329, 0.0212, -0.0463, -0.0162,
|
||||
-0.0313, 0.0096, -0.004, 0.0186, 0.0248, -0.0126, 0.0472, -0.0079, 0.0115, -0.027,
|
||||
0.0055, 0.0044, 0.0172, 0.0079, -0.0089, -0.0202, -0.0233, -0.0397, -0.0305, -0.062,
|
||||
-0.0282, -0.0104, -0.0071, -0.0242, -0.0255, 0.0204, -0.0187, -0.0103, -0.0227, -0.0424,
|
||||
-0.0056, 0.0065, 0.0151, -0.0376, 0.0039, 0.0009, -0.0507, -0.004, 0.0393, -0.0201,
|
||||
0.0128, -0.0228, 0.0115, -0.0446, 0.0316, 0.0266, -0.0036, 0.0117, -0.0009, 0.0048,
|
||||
-0.0088, 0.0226, 0.0125, 0.009, 0.0008, -0.0341, 0.0243, -0.0178, -0.0589, 0.0278,
|
||||
0.0151, 0.0021, -0.0349, -0.0365, -0.0098, -0.0179, -0.0212, -0.0313, 0.0109, -0.0164,
|
||||
-0.0211, -0.0112, -0.0446, 0.0014, -0.0034, -0.0179, 0.011, 0.0176, 0.0286, 0.0045,
|
||||
0.0034, -0.0151, 0.038, 0.0331, -0.0034, -0.0439, 0.0145, 0.012, 0.0036, 0.0017,
|
||||
-0.0348, 0.0192, 0.0167, 0.0069, -0.0266, -0.0085, -0.0076, 0.026, 0.0234, 0.0075,
|
||||
-0.0237, 0.015, -0.0094, -0.0201, 0.0234, -0.0041, -0.016, -0.0549, -0.0021, 0.0239,
|
||||
-0.0019, 0.0173, 0.0295, 0.0443, 0.0081, 0.0181, -0.0039, -0.027, 0.0155, 0.0107,
|
||||
0.0065, -0.0055, -0.0368, 0.0232, 0.037, 0.0367, 0.0046, -0.0167, 0.0047, 0.0173,
|
||||
0.0116, 0.0053, -0.0229, 0.0382, 0.016, -0.0453, 0.0057, -0.0267, 0.002, -0.0051,
|
||||
-0.014, 0.0302, -0.0208, 0.0106, 0.0101, -0.0049, -0.0319, 0.0227, -0.0206, -0.0371,
|
||||
-0.0007, -0.0109, -0.0053, 0.0078, 0.041, -0.0001, 0.0543, 0.0328, -0.0196, 0.0332,
|
||||
-0.0043, -0.0028, -0.0246, 0.0285, -0.0248, 0.0153, 0.0303, -0.031, -0.0335, -0.0315,
|
||||
-0.0417, 0.1029, 0.0377, 0.0069, 0.0012, 0.0065, 0.0007, -0.0144, -0.0083, 0.0004,
|
||||
0.0295, 0.0099, -0.0144, -0.0145, 0.0141, -0.0013, 0.0362, -0.0142, -0.0428, -0.0161,
|
||||
-0.0095, -0.0206, 0.0116, 0.0132, 0.0164, 0.0158, 0.0012, -0.0024, 0.064, 0.0364,
|
||||
0.0005, -0.0022, -0.0165, -0.0057, 0.0263, 0.0339, 0.0014, 0.0541, 0.0164, -0.0411,
|
||||
0.0039, -0.0143, -0.0107, 0.0032, -0.016, -0.0502, 0.001, 0.0272, 0.0161, -0.05,
|
||||
0.0083, 0.0292, -0.0076, -0.0201, 0.0313, 0.0213, 0.012, 0.0087, 0.0285, 0.0332,
|
||||
0.017, 0.0018, 0.0001, 0.0205, 0.0106, -0.0064, -0.0082, -0.0083, -0.0082, 0.0886,
|
||||
0.0075, -0.0078, -0.0038, -0.0337, -0.0491, 0.0048, 0.0069, 0.03, 0.0369, 0.0088,
|
||||
-0.0091, -0.0327, 0.0041, 0.0376, 0.017, 0.0154, 0.0126, 0.0153, -0.0024, -0.0353,
|
||||
0.0289, -0.008, 0.0063, 0.0274, -0.0061, 0.0208, 0.039, -0.006, 0.0294, -0.0088,
|
||||
-0.0037, -0.0195, 0.0058, 0.0023, -0.0149, -0.036, -0.0587, -0.0248, 0.0288, 0.0203,
|
||||
-0.0031, 0.0081, -0.0112, -0.0221, 0.0067, -0.0505, -0.0233, 0.0353, -0.0131, 0.0417,
|
||||
0.0243, 0.0231, -0.0013, 0.0049, -0.0423, -0.0245, -0.0029, 0.0184, -0.0162, -0.001,
|
||||
0.0045, 0.0101, -0.0042, 0.0014, -0.0133, -0.0321, 0.0642, 0.0153, 0.0377, 0.0277,
|
||||
0.0275, 0.0083, 0.0286, -0.0243, -0.0084, -0.0236, 0.0027, -0.0289, 0.0201, 0.0235,
|
||||
0.0281, 0.0078, 0.0038, 0.0069, 0.0302, 0.017, -0.0423, -0.034, 0.0104, -0.0181,
|
||||
0.0334, -0.0034, -0.0257, -0.0061, 0.014, -0.0099, -0.0195, 0.0529, 0.0019, 0.001,
|
||||
-0.0114, 0.0012, -0.0038, -0.0016, -0.014, 0.0697, 0.0372, 0.0243, 0.0172, 0.0066,
|
||||
0.0192, 0.0149, 0.0285, 0.0077, 0.0246, -0.0135, 0.0145, 0.0317, -0.0074, -0.0438,
|
||||
-0.0034, -0.0175, -0.0245, -0.0153, 0.0357, -0.0102, -0.0062, -0.0053, -0.0308, -0.0499,
|
||||
0.0025, -0.0253, 0.0148, 0.0031, 0.0189, -0.0023, -0.0085, -0.0596, -0.0337, 0.0175,
|
||||
-0.0091, -0.0171, -0.0217, -0.0189, 0.0056, 0.0249, -0.0499, 0.0236, 0.0042, 0.0449
|
||||
};
|
||||
|
||||
const struct lsp_codebook lsp_cbvqanssi[] = {
|
||||
/* codebook/lspvqanssi1.txt */
|
||||
{
|
||||
10,
|
||||
8,
|
||||
256,
|
||||
codes0
|
||||
},
|
||||
/* codebook/lspvqanssi2.txt */
|
||||
{
|
||||
10,
|
||||
7,
|
||||
128,
|
||||
codes1
|
||||
},
|
||||
/* codebook/lspvqanssi3.txt */
|
||||
{
|
||||
10,
|
||||
6,
|
||||
64,
|
||||
codes2
|
||||
},
|
||||
/* codebook/lspvqanssi4.txt */
|
||||
{
|
||||
10,
|
||||
6,
|
||||
64,
|
||||
codes3
|
||||
},
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,76 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: codec2.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 21 August 2010
|
||||
|
||||
Codec 2 fully quantised encoder and decoder functions. If you want use
|
||||
Codec 2, these are the functions you need to call.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2010 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __CODEC2__
|
||||
#define __CODEC2__
|
||||
|
||||
/* set up the calling convention for DLL function import/export for
|
||||
WIN32 cross compiling */
|
||||
|
||||
#ifdef __CODEC2_WIN32__
|
||||
#ifdef __CODEC2_BUILDING_DLL__
|
||||
#define CODEC2_WIN32SUPPORT __declspec(dllexport) __stdcall
|
||||
#else
|
||||
#define CODEC2_WIN32SUPPORT __declspec(dllimport) __stdcall
|
||||
#endif
|
||||
#else
|
||||
#define CODEC2_WIN32SUPPORT
|
||||
#endif
|
||||
|
||||
#define CODEC2_MODE_3200 0
|
||||
#define CODEC2_MODE_2400 1
|
||||
#define CODEC2_MODE_1600 2
|
||||
#define CODEC2_MODE_1400 3
|
||||
#define CODEC2_MODE_1300 4
|
||||
#define CODEC2_MODE_1200 5
|
||||
|
||||
struct CODEC2;
|
||||
|
||||
struct CODEC2 * CODEC2_WIN32SUPPORT codec2_create(int mode);
|
||||
void CODEC2_WIN32SUPPORT codec2_destroy(struct CODEC2 *codec2_state);
|
||||
void CODEC2_WIN32SUPPORT codec2_encode(struct CODEC2 *codec2_state, unsigned char * bits, short speech_in[]);
|
||||
void CODEC2_WIN32SUPPORT codec2_decode(struct CODEC2 *codec2_state, short speech_out[], const unsigned char *bits);
|
||||
void CODEC2_WIN32SUPPORT codec2_decode_ber(struct CODEC2 *codec2_state, short speech_out[], const unsigned char *bits, float ber_est);
|
||||
int CODEC2_WIN32SUPPORT codec2_samples_per_frame(struct CODEC2 *codec2_state);
|
||||
int CODEC2_WIN32SUPPORT codec2_bits_per_frame(struct CODEC2 *codec2_state);
|
||||
|
||||
void CODEC2_WIN32SUPPORT codec2_set_lpc_post_filter(struct CODEC2 *codec2_state, int enable, int bass_boost, float beta, float gamma);
|
||||
int CODEC2_WIN32SUPPORT codec2_get_spare_bit_index(struct CODEC2 *codec2_state);
|
||||
int CODEC2_WIN32SUPPORT codec2_rebuild_spare_bit(struct CODEC2 *codec2_state, int unpacked_bits[]);
|
||||
void CODEC2_WIN32SUPPORT codec2_set_natural_or_gray(struct CODEC2 *codec2_state, int gray);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: codec2_fdmdv.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: April 14 2012
|
||||
|
||||
A 1400 bit/s (nominal) Frequency Division Multiplexed Digital Voice
|
||||
(FDMDV) modem. Used for digital audio over HF SSB. See
|
||||
README_fdmdv.txt for more information, and fdmdv_mod.c and
|
||||
fdmdv_demod.c for example usage.
|
||||
|
||||
The name codec2_fdmdv.h is used to make it unique when "make
|
||||
installed".
|
||||
|
||||
References:
|
||||
|
||||
[1] http://n1su.com/fdmdv/FDMDV_Docs_Rel_1_4b.pdf
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __FDMDV__
|
||||
#define __FDMDV__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* set up the calling convention for DLL function import/export for
|
||||
WIN32 cross compiling */
|
||||
|
||||
#ifdef __CODEC2_WIN32__
|
||||
#ifdef __CODEC2_BUILDING_DLL__
|
||||
#define CODEC2_WIN32SUPPORT __declspec(dllexport) __stdcall
|
||||
#else
|
||||
#define CODEC2_WIN32SUPPORT __declspec(dllimport) __stdcall
|
||||
#endif
|
||||
#else
|
||||
#define CODEC2_WIN32SUPPORT
|
||||
#endif
|
||||
|
||||
#include "comp.h"
|
||||
|
||||
#define FDMDV_NC 14 /* default number of data carriers */
|
||||
#define FDMDV_NC_MAX 20 /* maximum number of data carriers */
|
||||
#define FDMDV_BITS_PER_FRAME 28 /* 20ms frames, for nominal 1400 bit/s */
|
||||
#define FDMDV_NOM_SAMPLES_PER_FRAME 160 /* modulator output samples/frame and nominal demod samples/frame */
|
||||
/* at 8000 Hz sample rate */
|
||||
#define FDMDV_MAX_SAMPLES_PER_FRAME 200 /* max demod samples/frame, use this to allocate storage */
|
||||
#define FDMDV_SCALE 1000 /* suggested scaling for 16 bit shorts */
|
||||
#define FDMDV_FCENTRE 1500 /* Centre frequency, Nc/2 carriers below this, Nc/2 carriers above (Hz) */
|
||||
|
||||
/* 8 to 48 kHz sample rate conversion */
|
||||
|
||||
#define FDMDV_OS 2 /* oversampling rate */
|
||||
#define FDMDV_OS_TAPS_16K 48 /* number of OS filter taps at 16kHz */
|
||||
#define FDMDV_OS_TAPS_8K (FDMDV_OS_TAPS_16K/FDMDV_OS) /* number of OS filter taps at 8kHz */
|
||||
|
||||
/* FFT points */
|
||||
|
||||
#define FDMDV_NSPEC 512
|
||||
#define FDMDV_MAX_F_HZ 4000
|
||||
|
||||
/* FDMDV states and stats structures */
|
||||
|
||||
struct FDMDV;
|
||||
|
||||
struct FDMDV_STATS {
|
||||
int Nc;
|
||||
float snr_est; /* estimated SNR of rx signal in dB (3 kHz noise BW) */
|
||||
COMP rx_symbols[FDMDV_NC_MAX+1]; /* latest received symbols, for scatter plot */
|
||||
int sync; /* demod sync state */
|
||||
float foff; /* estimated freq offset in Hz */
|
||||
float rx_timing; /* estimated optimum timing offset in samples */
|
||||
float clock_offset; /* Estimated tx/rx sample clock offset in ppm */
|
||||
};
|
||||
|
||||
struct FDMDV * fdmdv_create(int Nc);
|
||||
void fdmdv_destroy(struct FDMDV *fdmdv_state);
|
||||
void fdmdv_use_old_qpsk_mapping(struct FDMDV *fdmdv_state);
|
||||
int fdmdv_bits_per_frame(struct FDMDV *fdmdv_state);
|
||||
float fdmdv_get_fsep(struct FDMDV *fdmdv_state);
|
||||
void fdmdv_set_fsep(struct FDMDV *fdmdv_state, float fsep);
|
||||
|
||||
void fdmdv_mod(struct FDMDV *fdmdv_state, COMP tx_fdm[], int tx_bits[], int *sync_bit);
|
||||
void fdmdv_demod(struct FDMDV *fdmdv_state, int rx_bits[], int *reliable_sync_bit, COMP rx_fdm[], int *nin);
|
||||
|
||||
void fdmdv_get_test_bits(struct FDMDV *fdmdv_state, int tx_bits[]);
|
||||
int fdmdv_error_pattern_size(struct FDMDV *fdmdv_state);
|
||||
void fdmdv_put_test_bits(struct FDMDV *f, int *sync, short error_pattern[], int *bit_errors, int *ntest_bits, int rx_bits[]);
|
||||
|
||||
void fdmdv_get_demod_stats(struct FDMDV *fdmdv_state, struct FDMDV_STATS *fdmdv_stats);
|
||||
void fdmdv_get_rx_spectrum(struct FDMDV *fdmdv_state, float mag_dB[], COMP rx_fdm[], int nin);
|
||||
|
||||
void fdmdv_8_to_16(float out16k[], float in8k[], int n);
|
||||
void fdmdv_8_to_16_short(short out16k[], short in8k[], int n);
|
||||
void fdmdv_16_to_8(float out8k[], float in16k[], int n);
|
||||
void fdmdv_16_to_8_short(short out8k[], short in16k[], int n);
|
||||
|
||||
void fdmdv_freq_shift(COMP rx_fdm_fcorr[], COMP rx_fdm[], float foff, COMP *foff_phase_rect, int nin);
|
||||
|
||||
/* debug/development function(s) */
|
||||
|
||||
void fdmdv_dump_osc_mags(struct FDMDV *f);
|
||||
void fdmdv_simulate_channel(struct FDMDV *f, COMP samples[], int nin, float target_snr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: codec2_fifo.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: Oct 15 2012
|
||||
|
||||
A FIFO design useful in gluing the FDMDV modem and codec together in
|
||||
integrated applications.
|
||||
|
||||
The name codec2_fifo.h is used to make it unique when "make
|
||||
installed".
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __FIFO__
|
||||
#define __FIFO__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct FIFO;
|
||||
|
||||
struct FIFO *fifo_create(int nshort);
|
||||
void fifo_destroy(struct FIFO *fifo);
|
||||
int fifo_write(struct FIFO *fifo, short data[], int n);
|
||||
int fifo_read(struct FIFO *fifo, short data[], int n);
|
||||
int fifo_used(struct FIFO *fifo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: codec2_internal.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: April 16 2012
|
||||
|
||||
Header file for Codec2 internal states, exposed via this header
|
||||
file to assist in testing.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __CODEC2_INTERNAL__
|
||||
#define __CODEC2_INTERNAL__
|
||||
|
||||
struct CODEC2 {
|
||||
int mode;
|
||||
kiss_fft_cfg fft_fwd_cfg; /* forward FFT config */
|
||||
float w[M]; /* time domain hamming window */
|
||||
COMP W[FFT_ENC]; /* DFT of w[] */
|
||||
float Pn[2*N]; /* trapezoidal synthesis window */
|
||||
float Sn[M]; /* input speech */
|
||||
float hpf_states[2]; /* high pass filter states */
|
||||
void *nlp; /* pitch predictor states */
|
||||
int gray; /* non-zero for gray encoding */
|
||||
|
||||
kiss_fft_cfg fft_inv_cfg; /* inverse FFT config */
|
||||
float Sn_[2*N]; /* synthesised output speech */
|
||||
float ex_phase; /* excitation model phase track */
|
||||
float bg_est; /* background noise estimate for post filter */
|
||||
float prev_Wo_enc; /* previous frame's pitch estimate */
|
||||
MODEL prev_model_dec; /* previous frame's model parameters */
|
||||
float prev_lsps_dec[LPC_ORD]; /* previous frame's LSPs */
|
||||
float prev_e_dec; /* previous frame's LPC energy */
|
||||
|
||||
int lpc_pf; /* LPC post filter on */
|
||||
int bass_boost; /* LPC post filter bass boost */
|
||||
float beta; /* LPC post filter parameters */
|
||||
float gamma;
|
||||
|
||||
float xq_enc[2]; /* joint pitch and energy VQ states */
|
||||
float xq_dec[2];
|
||||
|
||||
int smoothing; /* enable smoothing for channels with errors */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: comp.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/08/09
|
||||
|
||||
Complex number definition.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __COMP__
|
||||
#define __COMP__
|
||||
|
||||
/* Complex number */
|
||||
|
||||
typedef struct {
|
||||
float real;
|
||||
float imag;
|
||||
} COMP;
|
||||
|
||||
#endif
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: defines.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 23/4/93
|
||||
|
||||
Defines and structures used throughout the codec.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __DEFINES__
|
||||
#define __DEFINES__
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
DEFINES
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/* General defines */
|
||||
|
||||
#define N 80 /* number of samples per frame */
|
||||
#define MAX_AMP 80 /* maximum number of harmonics */
|
||||
#define PI 3.141592654 /* mathematical constant */
|
||||
#define TWO_PI 6.283185307 /* mathematical constant */
|
||||
#define FS 8000 /* sample rate in Hz */
|
||||
#define MAX_STR 256 /* maximum string size */
|
||||
|
||||
#define NW 279 /* analysis window size */
|
||||
#define FFT_ENC 512 /* size of FFT used for encoder */
|
||||
#define FFT_DEC 512 /* size of FFT used in decoder */
|
||||
#define TW 40 /* Trapezoidal synthesis window overlap */
|
||||
#define V_THRESH 6.0 /* voicing threshold in dB */
|
||||
#define LPC_ORD 10 /* phase modelling LPC order */
|
||||
|
||||
/* Pitch estimation defines */
|
||||
|
||||
#define M 320 /* pitch analysis frame size */
|
||||
#define P_MIN 20 /* minimum pitch */
|
||||
#define P_MAX 160 /* maximum pitch */
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
TYPEDEFS
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Structure to hold model parameters for one frame */
|
||||
|
||||
typedef struct {
|
||||
float Wo; /* fundamental frequency estimate in radians */
|
||||
int L; /* number of harmonics */
|
||||
float A[MAX_AMP+1]; /* amplitiude of each harmonic */
|
||||
float phi[MAX_AMP+1]; /* phase of each harmonic */
|
||||
int voiced; /* non-zero if this frame is voiced */
|
||||
} MODEL;
|
||||
|
||||
/* describes each codebook */
|
||||
|
||||
struct lsp_codebook {
|
||||
int k; /* dimension of vector */
|
||||
int log2m; /* number of bits in m */
|
||||
int m; /* elements in codebook */
|
||||
const float * cb; /* The elements */
|
||||
};
|
||||
|
||||
extern const struct lsp_codebook lsp_cb[];
|
||||
extern const struct lsp_codebook lsp_cbd[];
|
||||
extern const struct lsp_codebook lsp_cbvq[];
|
||||
extern const struct lsp_codebook lsp_cbjnd[];
|
||||
extern const struct lsp_codebook lsp_cbdt[];
|
||||
extern const struct lsp_codebook lsp_cbjvm[];
|
||||
extern const struct lsp_codebook lsp_cbvqanssi[];
|
||||
extern const struct lsp_codebook ge_cb[];
|
||||
|
||||
#endif
|
||||
|
|
@ -1,629 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: dump.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 25/8/09
|
||||
|
||||
Routines to dump data to text files for Octave analysis.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
#include "comp.h"
|
||||
#include "dump.h"
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __EMBEDDED__
|
||||
#include "gdb_stdio.h"
|
||||
#define fprintf gdb_stdio_fprintf
|
||||
#define fopen gdb_stdio_fopen
|
||||
#define fclose gdb_stdio_fclose
|
||||
#endif
|
||||
|
||||
#ifdef DUMP
|
||||
static int dumpon = 0;
|
||||
|
||||
static FILE *fsn = NULL;
|
||||
static FILE *fsw = NULL;
|
||||
static FILE *few = NULL;
|
||||
static FILE *fsw_ = NULL;
|
||||
static FILE *fmodel = NULL;
|
||||
static FILE *fqmodel = NULL;
|
||||
static FILE *fpwb = NULL;
|
||||
static FILE *fpw = NULL;
|
||||
static FILE *frw = NULL;
|
||||
static FILE *flsp = NULL;
|
||||
static FILE *fweights = NULL;
|
||||
static FILE *flsp_ = NULL;
|
||||
static FILE *fmel = NULL;
|
||||
static FILE *fphase = NULL;
|
||||
static FILE *fphase_ = NULL;
|
||||
static FILE *ffw = NULL;
|
||||
static FILE *fe = NULL;
|
||||
static FILE *fsq = NULL;
|
||||
static FILE *fdec = NULL;
|
||||
static FILE *fsnr = NULL;
|
||||
static FILE *flpcsnr = NULL;
|
||||
static FILE *fak = NULL;
|
||||
static FILE *fak_ = NULL;
|
||||
static FILE *fbg = NULL;
|
||||
static FILE *fE = NULL;
|
||||
static FILE *frk = NULL;
|
||||
static FILE *fhephase = NULL;
|
||||
|
||||
static char prefix[MAX_STR];
|
||||
|
||||
void dump_on(char p[]) {
|
||||
dumpon = 1;
|
||||
strcpy(prefix, p);
|
||||
}
|
||||
|
||||
void dump_off(){
|
||||
if (fsn != NULL)
|
||||
fclose(fsn);
|
||||
if (fsw != NULL)
|
||||
fclose(fsw);
|
||||
if (fsw_ != NULL)
|
||||
fclose(fsw_);
|
||||
if (few != NULL)
|
||||
fclose(few);
|
||||
if (fmodel != NULL)
|
||||
fclose(fmodel);
|
||||
if (fqmodel != NULL)
|
||||
fclose(fqmodel);
|
||||
if (fpwb != NULL)
|
||||
fclose(fpwb);
|
||||
if (fpw != NULL)
|
||||
fclose(fpw);
|
||||
if (frw != NULL)
|
||||
fclose(frw);
|
||||
if (flsp != NULL)
|
||||
fclose(flsp);
|
||||
if (fweights != NULL)
|
||||
fclose(fweights);
|
||||
if (flsp_ != NULL)
|
||||
fclose(flsp_);
|
||||
if (fmel != NULL)
|
||||
fclose(fmel);
|
||||
if (fphase != NULL)
|
||||
fclose(fphase);
|
||||
if (fphase_ != NULL)
|
||||
fclose(fphase_);
|
||||
if (ffw != NULL)
|
||||
fclose(ffw);
|
||||
if (fe != NULL)
|
||||
fclose(fe);
|
||||
if (fsq != NULL)
|
||||
fclose(fsq);
|
||||
if (fdec != NULL)
|
||||
fclose(fdec);
|
||||
if (fsnr != NULL)
|
||||
fclose(fsnr);
|
||||
if (flpcsnr != NULL)
|
||||
fclose(flpcsnr);
|
||||
if (fak != NULL)
|
||||
fclose(fak);
|
||||
if (fak_ != NULL)
|
||||
fclose(fak_);
|
||||
if (fbg != NULL)
|
||||
fclose(fbg);
|
||||
if (fE != NULL)
|
||||
fclose(fE);
|
||||
if (frk != NULL)
|
||||
fclose(frk);
|
||||
if (fhephase != NULL)
|
||||
fclose(fhephase);
|
||||
}
|
||||
|
||||
void dump_Sn(float Sn[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fsn == NULL) {
|
||||
sprintf(s,"%s_sn.txt", prefix);
|
||||
fsn = fopen(s, "wt");
|
||||
assert(fsn != NULL);
|
||||
}
|
||||
|
||||
/* split across two lines to avoid max line length problems */
|
||||
/* reconstruct in Octave */
|
||||
|
||||
for(i=0; i<M/2; i++)
|
||||
fprintf(fsn,"%f\t",Sn[i]);
|
||||
fprintf(fsn,"\n");
|
||||
for(i=M/2; i<M; i++)
|
||||
fprintf(fsn,"%f\t",Sn[i]);
|
||||
fprintf(fsn,"\n");
|
||||
}
|
||||
|
||||
void dump_Sw(COMP Sw[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fsw == NULL) {
|
||||
sprintf(s,"%s_sw.txt", prefix);
|
||||
fsw = fopen(s, "wt");
|
||||
assert(fsw != NULL);
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
void dump_Sw_(COMP Sw_[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fsw_ == NULL) {
|
||||
sprintf(s,"%s_sw_.txt", prefix);
|
||||
fsw_ = fopen(s, "wt");
|
||||
assert(fsw_ != NULL);
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
void dump_Ew(COMP Ew[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (few == NULL) {
|
||||
sprintf(s,"%s_ew.txt", prefix);
|
||||
few = fopen(s, "wt");
|
||||
assert(few != NULL);
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
void dump_model(MODEL *model) {
|
||||
int l;
|
||||
char s[MAX_STR];
|
||||
char line[2048];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fmodel == NULL) {
|
||||
sprintf(s,"%s_model.txt", prefix);
|
||||
fmodel = fopen(s, "wt");
|
||||
assert(fmodel != NULL);
|
||||
}
|
||||
|
||||
sprintf(line,"%12f %12d ", model->Wo, model->L);
|
||||
for(l=1; l<=model->L; l++) {
|
||||
sprintf(s,"%12f ",model->A[l]);
|
||||
strcat(line, s);
|
||||
}
|
||||
for(l=model->L+1; l<=MAX_AMP; l++) {
|
||||
sprintf(s,"%12f ", 0.0);
|
||||
strcat(line,s);
|
||||
}
|
||||
|
||||
sprintf(s,"%d\n",model->voiced);
|
||||
strcat(line,s);
|
||||
fprintf(fmodel,"%s",line);
|
||||
}
|
||||
|
||||
void dump_quantised_model(MODEL *model) {
|
||||
int l;
|
||||
char s[MAX_STR];
|
||||
char line[2048];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fqmodel == NULL) {
|
||||
sprintf(s,"%s_qmodel.txt", prefix);
|
||||
fqmodel = fopen(s, "wt");
|
||||
assert(fqmodel != NULL);
|
||||
}
|
||||
|
||||
sprintf(line,"%12f %12d ", model->Wo, model->L);
|
||||
for(l=1; l<=model->L; l++) {
|
||||
sprintf(s,"%12f ",model->A[l]);
|
||||
strcat(line, s);
|
||||
}
|
||||
for(l=model->L+1; l<=MAX_AMP; l++) {
|
||||
sprintf(s,"%12f ", 0.0);
|
||||
strcat(line, s);
|
||||
}
|
||||
|
||||
sprintf(s,"%d\n",model->voiced);
|
||||
strcat(line, s);
|
||||
fprintf(fqmodel, "%s", line);
|
||||
}
|
||||
|
||||
void dump_phase(float phase[], int L) {
|
||||
int l;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fphase == NULL) {
|
||||
sprintf(s,"%s_phase.txt", prefix);
|
||||
fphase = fopen(s, "wt");
|
||||
assert(fphase != NULL);
|
||||
}
|
||||
|
||||
for(l=1; l<=L; l++)
|
||||
fprintf(fphase,"%f\t",phase[l]);
|
||||
for(l=L+1; l<=MAX_AMP; l++)
|
||||
fprintf(fphase,"%f\t",0.0);
|
||||
fprintf(fphase,"\n");
|
||||
}
|
||||
|
||||
void dump_phase_(float phase_[], int L) {
|
||||
int l;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fphase_ == NULL) {
|
||||
sprintf(s,"%s_phase_.txt", prefix);
|
||||
fphase_ = fopen(s, "wt");
|
||||
assert(fphase_ != NULL);
|
||||
}
|
||||
|
||||
for(l=1; l<=L; l++)
|
||||
fprintf(fphase_,"%f\t",phase_[l]);
|
||||
for(l=L+1; l<MAX_AMP; l++)
|
||||
fprintf(fphase_,"%f\t",0.0);
|
||||
fprintf(fphase_,"\n");
|
||||
}
|
||||
|
||||
|
||||
void dump_hephase(int ind[], int dim) {
|
||||
int m;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fhephase == NULL) {
|
||||
sprintf(s,"%s_hephase.txt", prefix);
|
||||
fhephase = fopen(s, "wt");
|
||||
assert(fhephase != NULL);
|
||||
}
|
||||
|
||||
for(m=0; m<dim; m++)
|
||||
fprintf(fhephase,"%d\t",ind[m]);
|
||||
fprintf(fhephase,"\n");
|
||||
}
|
||||
|
||||
|
||||
void dump_snr(float snr) {
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fsnr == NULL) {
|
||||
sprintf(s,"%s_snr.txt", prefix);
|
||||
fsnr = fopen(s, "wt");
|
||||
assert(fsnr != NULL);
|
||||
}
|
||||
|
||||
fprintf(fsnr,"%f\n",snr);
|
||||
}
|
||||
|
||||
void dump_lpc_snr(float snr) {
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (flpcsnr == NULL) {
|
||||
sprintf(s,"%s_lpc_snr.txt", prefix);
|
||||
flpcsnr = fopen(s, "wt");
|
||||
assert(flpcsnr != NULL);
|
||||
}
|
||||
|
||||
fprintf(flpcsnr,"%f\n",snr);
|
||||
}
|
||||
|
||||
/* Pw "before" post filter so we can plot before and after */
|
||||
|
||||
void dump_Pwb(COMP Pwb[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fpwb == NULL) {
|
||||
sprintf(s,"%s_pwb.txt", prefix);
|
||||
fpwb = fopen(s, "wt");
|
||||
assert(fpwb != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<FFT_ENC/2; i++)
|
||||
fprintf(fpwb,"%f\t",Pwb[i].real);
|
||||
fprintf(fpwb,"\n");
|
||||
}
|
||||
|
||||
void dump_Pw(COMP Pw[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fpw == NULL) {
|
||||
sprintf(s,"%s_pw.txt", prefix);
|
||||
fpw = fopen(s, "wt");
|
||||
assert(fpw != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<FFT_ENC/2; i++)
|
||||
fprintf(fpw,"%f\t",Pw[i].real);
|
||||
fprintf(fpw,"\n");
|
||||
}
|
||||
|
||||
void dump_Rw(float Rw[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (frw == NULL) {
|
||||
sprintf(s,"%s_rw.txt", prefix);
|
||||
frw = fopen(s, "wt");
|
||||
assert(frw != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<FFT_ENC/2; i++)
|
||||
fprintf(frw,"%f\t",Rw[i]);
|
||||
fprintf(frw,"\n");
|
||||
}
|
||||
|
||||
void dump_weights(float w[], int order) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fweights == NULL) {
|
||||
sprintf(s,"%s_weights.txt", prefix);
|
||||
fweights = fopen(s, "wt");
|
||||
assert(fweights != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<order; i++)
|
||||
fprintf(fweights,"%f\t", w[i]);
|
||||
fprintf(fweights,"\n");
|
||||
}
|
||||
|
||||
void dump_lsp(float lsp[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (flsp == NULL) {
|
||||
sprintf(s,"%s_lsp.txt", prefix);
|
||||
flsp = fopen(s, "wt");
|
||||
assert(flsp != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<10; i++)
|
||||
fprintf(flsp,"%f\t",lsp[i]);
|
||||
fprintf(flsp,"\n");
|
||||
}
|
||||
|
||||
void dump_lsp_(float lsp_[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (flsp_ == NULL) {
|
||||
sprintf(s,"%s_lsp_.txt", prefix);
|
||||
flsp_ = fopen(s, "wt");
|
||||
assert(flsp_ != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<10; i++)
|
||||
fprintf(flsp_,"%f\t",lsp_[i]);
|
||||
fprintf(flsp_,"\n");
|
||||
}
|
||||
|
||||
void dump_mel(int mel[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fmel == NULL) {
|
||||
sprintf(s,"%s_mel.txt", prefix);
|
||||
fmel = fopen(s, "wt");
|
||||
assert(fmel != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<10; i++)
|
||||
fprintf(fmel,"%d\t",mel[i]);
|
||||
fprintf(fmel,"\n");
|
||||
}
|
||||
|
||||
void dump_ak(float ak[], int order) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fak == NULL) {
|
||||
sprintf(s,"%s_ak.txt", prefix);
|
||||
fak = fopen(s, "wt");
|
||||
assert(fak != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<=order; i++)
|
||||
fprintf(fak,"%f\t",ak[i]);
|
||||
fprintf(fak,"\n");
|
||||
}
|
||||
|
||||
void dump_ak_(float ak_[], int order) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fak_ == NULL) {
|
||||
sprintf(s,"%s_ak_.txt", prefix);
|
||||
fak_ = fopen(s, "wt");
|
||||
assert(fak_ != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<=order; i++)
|
||||
fprintf(fak_,"%f\t",ak_[i]);
|
||||
fprintf(fak_,"\n");
|
||||
}
|
||||
|
||||
void dump_Fw(COMP Fw[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (ffw == NULL) {
|
||||
sprintf(s,"%s_fw.txt", prefix);
|
||||
ffw = fopen(s, "wt");
|
||||
assert(ffw != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<256; i++)
|
||||
fprintf(ffw,"%f\t",Fw[i].real);
|
||||
fprintf(ffw,"\n");
|
||||
}
|
||||
|
||||
void dump_e(float e_hz[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fe == NULL) {
|
||||
sprintf(s,"%s_e.txt", prefix);
|
||||
fe = fopen(s, "wt");
|
||||
assert(fe != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<500/2; i++)
|
||||
fprintf(fe,"%f\t",e_hz[i]);
|
||||
fprintf(fe,"\n");
|
||||
for(i=500/2; i<500; i++)
|
||||
fprintf(fe,"%f\t",e_hz[i]);
|
||||
fprintf(fe,"\n");
|
||||
}
|
||||
|
||||
void dump_sq(float sq[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fsq == NULL) {
|
||||
sprintf(s,"%s_sq.txt", prefix);
|
||||
fsq = fopen(s, "wt");
|
||||
assert(fsq != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<M/2; i++)
|
||||
fprintf(fsq,"%f\t",sq[i]);
|
||||
fprintf(fsq,"\n");
|
||||
for(i=M/2; i<M; i++)
|
||||
fprintf(fsq,"%f\t",sq[i]);
|
||||
fprintf(fsq,"\n");
|
||||
}
|
||||
|
||||
void dump_dec(COMP Fw[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fdec == NULL) {
|
||||
sprintf(s,"%s_dec.txt", prefix);
|
||||
fdec = fopen(s, "wt");
|
||||
assert(fdec != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<320/5; i++)
|
||||
fprintf(fdec,"%f\t",Fw[i].real);
|
||||
fprintf(fdec,"\n");
|
||||
}
|
||||
|
||||
void dump_bg(float e, float bg_est, float percent_uv) {
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fbg == NULL) {
|
||||
sprintf(s,"%s_bg.txt", prefix);
|
||||
fbg = fopen(s, "wt");
|
||||
assert(fbg != NULL);
|
||||
}
|
||||
|
||||
fprintf(fbg,"%f\t%f\t%f\n", e, bg_est, percent_uv);
|
||||
}
|
||||
|
||||
void dump_E(float E) {
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fE == NULL) {
|
||||
sprintf(s,"%s_E.txt", prefix);
|
||||
fE = fopen(s, "wt");
|
||||
assert(fE != NULL);
|
||||
}
|
||||
|
||||
fprintf(fE,"%f\n", 10.0*log10(E));
|
||||
}
|
||||
|
||||
void dump_Rk(float Rk[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (frk == NULL) {
|
||||
sprintf(s,"%s_rk.txt", prefix);
|
||||
frk = fopen(s, "wt");
|
||||
assert(frk != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<P_MAX; i++)
|
||||
fprintf(frk,"%f\t",Rk[i]);
|
||||
fprintf(frk,"\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: dump.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 25/8/09
|
||||
|
||||
Routines to dump data to text files for Octave analysis.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __DUMP__
|
||||
#define __DUMP__
|
||||
|
||||
#include "defines.h"
|
||||
#include "comp.h"
|
||||
#include "kiss_fft.h"
|
||||
#include "codec2_internal.h"
|
||||
|
||||
void dump_on(char filename_prefix[]);
|
||||
void dump_off();
|
||||
|
||||
void dump_Sn(float Sn[]);
|
||||
void dump_Sw(COMP Sw[]);
|
||||
void dump_Sw_(COMP Sw_[]);
|
||||
void dump_Ew(COMP Ew[]);
|
||||
|
||||
/* amplitude modelling */
|
||||
|
||||
void dump_model(MODEL *m);
|
||||
void dump_quantised_model(MODEL *m);
|
||||
void dump_Pwn(COMP Pw[]);
|
||||
void dump_Pw(COMP Pw[]);
|
||||
void dump_Rw(float Rw[]);
|
||||
void dump_lsp(float lsp[]);
|
||||
void dump_weights(float w[], int ndim);
|
||||
void dump_lsp_(float lsp_[]);
|
||||
void dump_mel(int mel[]);
|
||||
void dump_ak(float ak[], int order);
|
||||
void dump_ak_(float ak[], int order);
|
||||
void dump_E(float E);
|
||||
void dump_lpc_snr(float snr);
|
||||
|
||||
/* phase modelling */
|
||||
|
||||
void dump_snr(float snr);
|
||||
void dump_phase(float phase[], int L);
|
||||
void dump_phase_(float phase[], int L);
|
||||
void dump_hephase(int ind[], int dim);
|
||||
|
||||
/* NLP states */
|
||||
|
||||
void dump_sq(float sq[]);
|
||||
void dump_dec(COMP Fw[]);
|
||||
void dump_Fw(COMP Fw[]);
|
||||
void dump_e(float e_hz[]);
|
||||
void dump_Rk(float Rk[]);
|
||||
|
||||
/* post filter */
|
||||
|
||||
void dump_bg(float e, float bg_est, float percent_uv);
|
||||
void dump_Pwb(COMP Pwb[]);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,193 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: fdmdv_internal.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: April 16 2012
|
||||
|
||||
Header file for FDMDV internal functions, exposed via this header
|
||||
file for testing.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __FDMDV_INTERNAL__
|
||||
#define __FDMDV_INTERNAL__
|
||||
|
||||
#include "comp.h"
|
||||
#include "codec2_fdmdv.h"
|
||||
#include "kiss_fft.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
DEFINES
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#define PI 3.141592654
|
||||
#define FS 8000 /* sample rate in Hz */
|
||||
#define T (1.0/FS) /* sample period in seconds */
|
||||
#define RS 50 /* symbol rate in Hz */
|
||||
#define NC 20 /* max number of data carriers (plus one pilot in the centre) */
|
||||
#define NB 2 /* Bits/symbol for QPSK modulation */
|
||||
#define RB (NC*RS*NB) /* bit rate */
|
||||
#define M (FS/RS) /* oversampling factor */
|
||||
#define NSYM 6 /* number of symbols to filter over */
|
||||
#define NFILTER (NSYM*M) /* size of tx/rx filters at sample rate M */
|
||||
|
||||
#define FSEP 75 /* Default separation between carriers (Hz) */
|
||||
|
||||
#define NT 5 /* number of symbols we estimate timing over */
|
||||
#define P 4 /* oversample factor used for initial rx symbol filtering output */
|
||||
#define Q (M/4) /* oversample factor used for initial rx symbol filtering input */
|
||||
#define NRXDEC 31 /* number of taps in the rx decimation filter */
|
||||
|
||||
#define NPILOT_LUT (4*M) /* number of pilot look up table samples */
|
||||
#define NPILOTCOEFF 30 /* number of FIR filter coeffs in LP filter */
|
||||
#define NPILOTBASEBAND (NPILOTCOEFF+M+M/P) /* number of pilot baseband samples reqd for pilot LPF */
|
||||
#define NPILOTLPF (4*M) /* number of samples we DFT pilot over, pilot est window */
|
||||
#define MPILOTFFT 256
|
||||
|
||||
#define NSYNC_MEM 6
|
||||
|
||||
/* averaging filter coeffs */
|
||||
|
||||
#define TRACK_COEFF 0.5
|
||||
#define SNR_COEFF 0.9 /* SNR est averaging filter coeff */
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
STRUCT for States
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
struct FDMDV {
|
||||
|
||||
int Nc;
|
||||
float fsep;
|
||||
|
||||
/* test data (test frame) states */
|
||||
|
||||
int ntest_bits;
|
||||
int current_test_bit;
|
||||
int *rx_test_bits_mem;
|
||||
|
||||
/* Modulator */
|
||||
|
||||
int old_qpsk_mapping;
|
||||
int tx_pilot_bit;
|
||||
COMP prev_tx_symbols[NC+1];
|
||||
COMP tx_filter_memory[NC+1][NSYM];
|
||||
COMP phase_tx[NC+1];
|
||||
COMP freq[NC+1];
|
||||
float freq_pol[NC+1];
|
||||
|
||||
/* Pilot generation at demodulator */
|
||||
|
||||
COMP pilot_lut[NPILOT_LUT];
|
||||
int pilot_lut_index;
|
||||
int prev_pilot_lut_index;
|
||||
|
||||
/* freq offset estimation states */
|
||||
|
||||
kiss_fft_cfg fft_pilot_cfg;
|
||||
COMP pilot_baseband1[NPILOTBASEBAND];
|
||||
COMP pilot_baseband2[NPILOTBASEBAND];
|
||||
COMP pilot_lpf1[NPILOTLPF];
|
||||
COMP pilot_lpf2[NPILOTLPF];
|
||||
COMP S1[MPILOTFFT];
|
||||
COMP S2[MPILOTFFT];
|
||||
|
||||
/* baseband to low IF carrier states */
|
||||
|
||||
COMP fbb_rect;
|
||||
float fbb_pol;
|
||||
COMP fbb_phase_tx;
|
||||
COMP fbb_phase_rx;
|
||||
|
||||
/* freq offset correction states */
|
||||
|
||||
float foff;
|
||||
COMP foff_phase_rect;
|
||||
|
||||
/* Demodulator */
|
||||
|
||||
COMP rxdec_lpf_mem[NRXDEC-1+M];
|
||||
COMP rx_fdm_mem[NFILTER+M];
|
||||
COMP phase_rx[NC+1];
|
||||
COMP rx_filter_mem_timing[NC+1][NT*P];
|
||||
float rx_timing;
|
||||
COMP phase_difference[NC+1];
|
||||
COMP prev_rx_symbols[NC+1];
|
||||
|
||||
/* sync state machine */
|
||||
|
||||
int sync_mem[NSYNC_MEM];
|
||||
int fest_state;
|
||||
int sync;
|
||||
int timer;
|
||||
|
||||
/* SNR estimation states */
|
||||
|
||||
float sig_est[NC+1];
|
||||
float noise_est[NC+1];
|
||||
|
||||
/* Buf for FFT/waterfall */
|
||||
|
||||
float fft_buf[2*FDMDV_NSPEC];
|
||||
kiss_fft_cfg fft_cfg;
|
||||
|
||||
/* channel simulation */
|
||||
|
||||
float sig_pwr_av;
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION PROTOTYPES
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void bits_to_dqpsk_symbols(COMP tx_symbols[], int Nc, COMP prev_tx_symbols[], int tx_bits[], int *pilot_bit, int old_qpsk_mapping);
|
||||
void tx_filter(COMP tx_baseband[NC+1][M], int Nc, COMP tx_symbols[], COMP tx_filter_memory[NC+1][NSYM]);
|
||||
void fdm_upconvert(COMP tx_fdm[], int Nc, COMP tx_baseband[NC+1][M], COMP phase_tx[], COMP freq_tx[],
|
||||
COMP *fbb_phase, COMP fbb_rect);
|
||||
void tx_filter_and_upconvert(COMP tx_fdm[], int Nc, COMP tx_symbols[],
|
||||
COMP tx_filter_memory[NC+1][NSYM],
|
||||
COMP phase_tx[], COMP freq[], COMP *fbb_phase, COMP fbb_rect);
|
||||
void generate_pilot_fdm(COMP *pilot_fdm, int *bit, float *symbol, float *filter_mem, COMP *phase, COMP *freq);
|
||||
void generate_pilot_lut(COMP pilot_lut[], COMP *pilot_freq);
|
||||
float rx_est_freq_offset(struct FDMDV *f, COMP rx_fdm[], int nin, int do_fft);
|
||||
void lpf_peak_pick(float *foff, float *max, COMP pilot_baseband[], COMP pilot_lpf[], kiss_fft_cfg fft_pilot_cfg, COMP S[], int nin, int do_fft);
|
||||
void fdm_downconvert(COMP rx_baseband[NC+1][M+M/P], int Nc, COMP rx_fdm[], COMP phase_rx[], COMP freq[], int nin);
|
||||
void rxdec_filter(COMP rx_fdm_filter[], COMP rx_fdm[], COMP rxdec_lpf_mem[], int nin);
|
||||
void rx_filter(COMP rx_filt[NC+1][P+1], int Nc, COMP rx_baseband[NC+1][M+M/P], COMP rx_filter_memory[NC+1][NFILTER], int nin);
|
||||
void down_convert_and_rx_filter(COMP rx_filt[NC+1][P+1], int Nc, COMP rx_fdm[],
|
||||
COMP rx_fdm_mem[], COMP phase_rx[], COMP freq[],
|
||||
float freq_pol[], int nin, int dec_rate);
|
||||
float rx_est_timing(COMP rx_symbols[], int Nc,
|
||||
COMP rx_filt[NC+1][P+1],
|
||||
COMP rx_filter_mem_timing[NC+1][NT*P],
|
||||
float env[],
|
||||
int nin);
|
||||
float qpsk_to_bits(int rx_bits[], int *sync_bit, int Nc, COMP phase_difference[], COMP prev_rx_symbols[], COMP rx_symbols[], int old_qpsk_mapping);
|
||||
void snr_update(float sig_est[], float noise_est[], int Nc, COMP phase_difference[]);
|
||||
int freq_state(int *reliable_sync_bit, int sync_bit, int *state, int *timer, int *sync_mem);
|
||||
float calc_snr(int Nc, float sig_est[], float noise_est[]);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: fifo.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: Oct 15 2012
|
||||
|
||||
A FIFO design useful in gluing the FDMDV modem and codec together in
|
||||
integrated applications. The unittest/tfifo indicates these
|
||||
routines are thread safe without the need for syncronisation
|
||||
object, e.g. a different thread can read and write to a fifo at the
|
||||
same time.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "codec2_fifo.h"
|
||||
|
||||
struct FIFO {
|
||||
short *buf;
|
||||
short *pin;
|
||||
short *pout;
|
||||
int nshort;
|
||||
};
|
||||
|
||||
struct FIFO *fifo_create(int nshort) {
|
||||
struct FIFO *fifo;
|
||||
|
||||
fifo = (struct FIFO *)malloc(sizeof(struct FIFO));
|
||||
assert(fifo != NULL);
|
||||
|
||||
fifo->buf = (short*)malloc(sizeof(short)*nshort);
|
||||
assert(fifo->buf != NULL);
|
||||
fifo->pin = fifo->buf;
|
||||
fifo->pout = fifo->buf;
|
||||
fifo->nshort = nshort;
|
||||
|
||||
return fifo;
|
||||
}
|
||||
|
||||
void fifo_destroy(struct FIFO *fifo) {
|
||||
assert(fifo != NULL);
|
||||
free(fifo->buf);
|
||||
free(fifo);
|
||||
}
|
||||
|
||||
int fifo_write(struct FIFO *fifo, short data[], int n) {
|
||||
int i;
|
||||
int fifo_free;
|
||||
short *pdata;
|
||||
short *pin = fifo->pin;
|
||||
|
||||
assert(fifo != NULL);
|
||||
assert(data != NULL);
|
||||
|
||||
// available storage is one less than nshort as prd == pwr
|
||||
// is reserved for empty rather than full
|
||||
|
||||
fifo_free = fifo->nshort - fifo_used(fifo) - 1;
|
||||
|
||||
if (n > fifo_free) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
/* This could be made more efficient with block copies
|
||||
using memcpy */
|
||||
|
||||
pdata = data;
|
||||
for(i=0; i<n; i++) {
|
||||
*pin++ = *pdata++;
|
||||
if (pin == (fifo->buf + fifo->nshort))
|
||||
pin = fifo->buf;
|
||||
}
|
||||
fifo->pin = pin;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fifo_read(struct FIFO *fifo, short data[], int n)
|
||||
{
|
||||
int i;
|
||||
short *pdata;
|
||||
short *pout = fifo->pout;
|
||||
|
||||
assert(fifo != NULL);
|
||||
assert(data != NULL);
|
||||
|
||||
if (n > fifo_used(fifo)) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
/* This could be made more efficient with block copies
|
||||
using memcpy */
|
||||
|
||||
pdata = data;
|
||||
for(i=0; i<n; i++) {
|
||||
*pdata++ = *pout++;
|
||||
if (pout == (fifo->buf + fifo->nshort))
|
||||
pout = fifo->buf;
|
||||
}
|
||||
fifo->pout = pout;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fifo_used(struct FIFO *fifo)
|
||||
{
|
||||
short *pin = fifo->pin;
|
||||
short *pout = fifo->pout;
|
||||
unsigned int used;
|
||||
|
||||
assert(fifo != NULL);
|
||||
if (pin >= pout)
|
||||
used = pin - pout;
|
||||
else
|
||||
used = fifo->nshort + (unsigned int)(pin - pout);
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
|
|
@ -1,399 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: freedv_api.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: August 2014
|
||||
|
||||
Library of API functions that implement FreeDV "modes", useful for
|
||||
embedding FreeDV in other programs.
|
||||
|
||||
TODO:
|
||||
[X] speex tx/rx works
|
||||
[X] txt messages
|
||||
[ ] optional test tx framemode
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2014 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "codec2.h"
|
||||
#include "codec2_fdmdv.h"
|
||||
#include "golay23.h"
|
||||
#include "varicode.h"
|
||||
#include "freedv_api.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: freedv_open
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 3 August 2014
|
||||
|
||||
Call this first to initialise. Returns NULL if initialisation fails
|
||||
(e.g. out of memory or mode not supported).
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
struct freedv *freedv_open(int mode) {
|
||||
struct freedv *f;
|
||||
int Nc, codec2_mode, nbit, nbyte;
|
||||
|
||||
if (mode != FREEDV_MODE_1600)
|
||||
return NULL;
|
||||
|
||||
f = (struct freedv*)malloc(sizeof(struct freedv));
|
||||
if (f == NULL)
|
||||
return NULL;
|
||||
|
||||
f->mode = mode;
|
||||
f->tx_sync_bit = 0;
|
||||
f->snr_thresh = 2.0;
|
||||
|
||||
if (mode == FREEDV_MODE_1600) {
|
||||
Nc = 16;
|
||||
codec2_mode = CODEC2_MODE_1300;
|
||||
}
|
||||
|
||||
f->codec2 = codec2_create(codec2_mode);
|
||||
if (f->codec2 == NULL)
|
||||
return NULL;
|
||||
|
||||
f->fdmdv = fdmdv_create(Nc);
|
||||
if (f->fdmdv == NULL)
|
||||
return NULL;
|
||||
|
||||
nbit = codec2_bits_per_frame(f->codec2);
|
||||
nbyte = (nbit + 7) / 8;
|
||||
f->packed_codec_bits = (unsigned char*)malloc(nbyte*sizeof(char));
|
||||
f->codec_bits = (int*)malloc(nbit*sizeof(int));
|
||||
|
||||
nbit = 2*fdmdv_bits_per_frame(f->fdmdv);
|
||||
f->tx_bits = (int*)malloc(nbit*sizeof(int));
|
||||
f->rx_bits = (int*)malloc(nbit*sizeof(int));
|
||||
|
||||
nbit = fdmdv_bits_per_frame(f->fdmdv);
|
||||
f->fdmdv_bits = (int*)malloc(nbit*sizeof(int));
|
||||
|
||||
if ((f->packed_codec_bits == NULL) || (f->codec_bits == NULL)
|
||||
|| (f->tx_bits == NULL) || (f->rx_bits == NULL) || (f->fdmdv_bits == NULL))
|
||||
return NULL;
|
||||
|
||||
varicode_decode_init(&f->varicode_dec_states, 1);
|
||||
f->nvaricode_bits = 0;
|
||||
f->varicode_bit_index = 0;
|
||||
f->freedv_get_next_tx_char = NULL;
|
||||
f->freedv_put_next_rx_char = NULL;
|
||||
|
||||
golay23_init();
|
||||
f->total_bit_errors = 0;
|
||||
|
||||
f->nin = FDMDV_NOM_SAMPLES_PER_FRAME;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: freedv_close
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 3 August 2014
|
||||
|
||||
Frees up memory.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void freedv_close(struct freedv *freedv) {
|
||||
free(freedv->packed_codec_bits);
|
||||
free(freedv->codec_bits);
|
||||
free(freedv->tx_bits);
|
||||
fdmdv_destroy(freedv->fdmdv);
|
||||
codec2_destroy(freedv->codec2);
|
||||
free(freedv);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: freedv_tx
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 3 August 2014
|
||||
|
||||
Takes a frame of input speech samples, encodes and modulates them to produce
|
||||
a frame of modem samples that can be sent to the transmitter.
|
||||
|
||||
speech_in[] and mod_out[] are sampled at 8 kHz, 16 bit shorts, and
|
||||
FREEDV_NSAMPLES long. The speech_in[] level should be such that the
|
||||
peak speech level is between +/16384 and +/- 32767. mod_out[] will
|
||||
be scaled such that the peak level is just less than +/-32767.
|
||||
|
||||
The FDM modem signal mod_out[] has a high crest factor (around
|
||||
12dB), however the energy and duration of the peaks is small.
|
||||
FreeDV is generally operated at a "backoff" of 6-8dB. Adjust the
|
||||
power amplifier drive so that the average power is 6-8dB less than
|
||||
the peak power of the PA. For example, on a radio rated at 100W PEP
|
||||
for SSB, the average FreeDV power is typically 20-25W.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void freedv_tx(struct freedv *f, short mod_out[], short speech_in[]) {
|
||||
int bit, byte, i, j;
|
||||
int bits_per_codec_frame, bits_per_fdmdv_frame;
|
||||
int data, codeword1, data_flag_index;
|
||||
COMP tx_fdm[2*FDMDV_NOM_SAMPLES_PER_FRAME];
|
||||
|
||||
bits_per_codec_frame = codec2_bits_per_frame(f->codec2);
|
||||
bits_per_fdmdv_frame = fdmdv_bits_per_frame(f->fdmdv);
|
||||
|
||||
codec2_encode(f->codec2, f->packed_codec_bits, speech_in);
|
||||
|
||||
/* unpack bits, MSB first */
|
||||
|
||||
bit = 7; byte = 0;
|
||||
for(i=0; i<bits_per_codec_frame; i++) {
|
||||
f->codec_bits[i] = (f->packed_codec_bits[byte] >> bit) & 0x1;
|
||||
bit--;
|
||||
if (bit < 0) {
|
||||
bit = 7;
|
||||
byte++;
|
||||
}
|
||||
}
|
||||
|
||||
// spare bit in frame that codec defines. Use this 1
|
||||
// bit/frame to send txt messages
|
||||
|
||||
data_flag_index = codec2_get_spare_bit_index(f->codec2);
|
||||
|
||||
if (f->nvaricode_bits) {
|
||||
f->codec_bits[data_flag_index] = f->tx_varicode_bits[f->varicode_bit_index++];
|
||||
f->nvaricode_bits--;
|
||||
}
|
||||
|
||||
if (f->nvaricode_bits == 0) {
|
||||
/* get new char and encode */
|
||||
char s[2];
|
||||
if (f->freedv_get_next_tx_char != NULL) {
|
||||
s[0] = (*f->freedv_get_next_tx_char)(f->callback_state);
|
||||
f->nvaricode_bits = varicode_encode(f->tx_varicode_bits, s, VARICODE_MAX_BITS, 1, 1);
|
||||
f->varicode_bit_index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (f->mode == FREEDV_MODE_1600) {
|
||||
|
||||
/* Protect first 12 out of first 16 excitation bits with (23,12) Golay Code:
|
||||
|
||||
0,1,2,3: v[0]..v[1]
|
||||
4,5,6,7: MSB of pitch
|
||||
11,12,13,14: MSB of energy
|
||||
|
||||
*/
|
||||
|
||||
data = 0;
|
||||
for(i=0; i<8; i++) {
|
||||
data <<= 1;
|
||||
data |= f->codec_bits[i];
|
||||
}
|
||||
for(i=11; i<15; i++) {
|
||||
data <<= 1;
|
||||
data |= f->codec_bits[i];
|
||||
}
|
||||
codeword1 = golay23_encode(data);
|
||||
|
||||
/* now pack output frame with parity bits at end to make them
|
||||
as far apart as possible from the data they protect. Parity
|
||||
bits are LSB of the Golay codeword */
|
||||
|
||||
for(i=0; i<bits_per_codec_frame; i++)
|
||||
f->tx_bits[i] = f->codec_bits[i];
|
||||
for(j=0; i<bits_per_codec_frame+11; i++,j++) {
|
||||
f->tx_bits[i] = (codeword1 >> (10-j)) & 0x1;
|
||||
}
|
||||
f->tx_bits[i] = 0; /* spare bit */
|
||||
|
||||
//for(i=0; i<bits_per_codec_frame+12; i++)
|
||||
// printf("%d\n", f->tx_bits[i]);
|
||||
}
|
||||
|
||||
/* modulate even and odd frames */
|
||||
|
||||
fdmdv_mod(f->fdmdv, tx_fdm, f->tx_bits, &f->tx_sync_bit);
|
||||
assert(f->tx_sync_bit == 1);
|
||||
|
||||
fdmdv_mod(f->fdmdv, &tx_fdm[FDMDV_NOM_SAMPLES_PER_FRAME], &f->tx_bits[bits_per_fdmdv_frame], &f->tx_sync_bit);
|
||||
assert(f->tx_sync_bit == 0);
|
||||
|
||||
for(i=0; i<2*FDMDV_NOM_SAMPLES_PER_FRAME; i++)
|
||||
mod_out[i] = FDMDV_SCALE * tx_fdm[i].real;
|
||||
|
||||
assert(2*FDMDV_NOM_SAMPLES_PER_FRAME == FREEDV_NSAMPLES);
|
||||
}
|
||||
|
||||
int freedv_nin(struct freedv *f) {
|
||||
return f->nin;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: freedv_rx
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 3 August 2014
|
||||
|
||||
Takes a frame of samples from the radio receiver, demodulates them,
|
||||
then decodes them, producing a frame of decoded speech samples.
|
||||
|
||||
Both demod_in[] and speech_out[] are 16 bit shorts sampled at 8 kHz.
|
||||
The peak level of demod_in[] is not critical, as the demod works
|
||||
well over a wide range of amplitude scaling. However it is best to
|
||||
avoid clipping (overload, or samples pinned to +/- 32767). Suggest
|
||||
scaling so the peak (modem signal plus noise) is between +/-16384
|
||||
and +/-32767. speech_out[] will peak at just less than +/-32767.
|
||||
|
||||
To account for difference in the transmit and receive sample clock
|
||||
frequencies, the number of demod_in[] samples is time varying. It
|
||||
is the responsibility of the caller to supply the correct number of
|
||||
samples. Call freedv_nin() before each call to freedv_rx() to
|
||||
determine how many samples to pass to this function (see example).
|
||||
|
||||
Returns the number of output speech samples available in
|
||||
speech_out[]. When in sync this will typically alternate between 0
|
||||
and FREEDV_NSAMPLES. When out of sync, this will be f->nin.
|
||||
|
||||
When out of sync, this function echoes the demod_in[] samples to
|
||||
speech_out[]. This allows the user to listen to the channel, which
|
||||
is useful for tuning FreeDV signals or reception of non-FreeDV
|
||||
signals.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
int freedv_rx(struct freedv *f, short speech_out[], short demod_in[]) {
|
||||
COMP rx_fdm[FDMDV_MAX_SAMPLES_PER_FRAME];
|
||||
int bits_per_codec_frame, bytes_per_codec_frame, bits_per_fdmdv_frame;
|
||||
int reliable_sync_bit, i, j, bit, byte, nin_prev, nout;
|
||||
int recd_codeword, codeword1, data_flag_index, n_ascii;
|
||||
short abit[1];
|
||||
char ascii_out;
|
||||
|
||||
bits_per_codec_frame = codec2_bits_per_frame(f->codec2);
|
||||
bytes_per_codec_frame = (bits_per_codec_frame + 7) / 8;
|
||||
bits_per_fdmdv_frame = fdmdv_bits_per_frame(f->fdmdv);
|
||||
|
||||
for(i=0; i<f->nin; i++) {
|
||||
rx_fdm[i].real = (float)demod_in[i]/FDMDV_SCALE;
|
||||
rx_fdm[i].imag = 0;
|
||||
}
|
||||
|
||||
nin_prev = f->nin;
|
||||
fdmdv_demod(f->fdmdv, f->fdmdv_bits, &reliable_sync_bit, rx_fdm, &f->nin);
|
||||
fdmdv_get_demod_stats(f->fdmdv, &f->fdmdv_stats);
|
||||
|
||||
if (f->fdmdv_stats.sync) {
|
||||
// printf("\033[97mIn sync. Pass demod_in to Codec, Codec to speech_out\n");
|
||||
if (reliable_sync_bit == 0) {
|
||||
memcpy(f->rx_bits, f->fdmdv_bits, bits_per_fdmdv_frame*sizeof(int));
|
||||
nout = 0;
|
||||
}
|
||||
else {
|
||||
memcpy(&f->rx_bits[bits_per_fdmdv_frame], f->fdmdv_bits, bits_per_fdmdv_frame*sizeof(int));
|
||||
|
||||
if (f->mode == FREEDV_MODE_1600) {
|
||||
recd_codeword = 0;
|
||||
for(i=0; i<8; i++) {
|
||||
recd_codeword <<= 1;
|
||||
recd_codeword |= f->rx_bits[i];
|
||||
}
|
||||
for(i=11; i<15; i++) {
|
||||
recd_codeword <<= 1;
|
||||
recd_codeword |= f->rx_bits[i];
|
||||
}
|
||||
for(i=bits_per_codec_frame; i<bits_per_codec_frame+11; i++) {
|
||||
recd_codeword <<= 1;
|
||||
recd_codeword |= f->rx_bits[i];
|
||||
}
|
||||
codeword1 = golay23_decode(recd_codeword);
|
||||
f->total_bit_errors += golay23_count_errors(recd_codeword, codeword1);
|
||||
|
||||
//codeword1 = recd_codeword;
|
||||
//fprintf(stderr, "received codeword1: 0x%x decoded codeword1: 0x%x\n", recd_codeword, codeword1);
|
||||
|
||||
for(i=0; i<bits_per_codec_frame; i++)
|
||||
f->codec_bits[i] = f->rx_bits[i];
|
||||
|
||||
for(i=0; i<8; i++) {
|
||||
f->codec_bits[i] = (codeword1 >> (22-i)) & 0x1;
|
||||
}
|
||||
for(i=8,j=11; i<12; i++,j++) {
|
||||
f->codec_bits[j] = (codeword1 >> (22-i)) & 0x1;
|
||||
}
|
||||
}
|
||||
|
||||
// extract txt msg data bit ------------------------------------------------------------
|
||||
|
||||
data_flag_index = codec2_get_spare_bit_index(f->codec2);
|
||||
abit[0] = f->codec_bits[data_flag_index];
|
||||
|
||||
n_ascii = varicode_decode(&f->varicode_dec_states, &ascii_out, abit, 1, 1);
|
||||
if (n_ascii && (f->freedv_put_next_rx_char != NULL)) {
|
||||
(*f->freedv_put_next_rx_char)(f->callback_state, ascii_out);
|
||||
}
|
||||
|
||||
// reconstruct missing bit we steal for data bit and decode speech
|
||||
|
||||
codec2_rebuild_spare_bit(f->codec2, f->codec_bits);
|
||||
|
||||
// pack bits, MSB received first
|
||||
|
||||
bit = 7;
|
||||
byte = 0;
|
||||
memset(f->packed_codec_bits, 0, bytes_per_codec_frame);
|
||||
for(i=0; i<bits_per_codec_frame; i++) {
|
||||
f->packed_codec_bits[byte] |= (f->codec_bits[i] << bit);
|
||||
bit--;
|
||||
if(bit < 0) {
|
||||
bit = 7;
|
||||
byte++;
|
||||
}
|
||||
}
|
||||
|
||||
codec2_decode(f->codec2, speech_out, f->packed_codec_bits);
|
||||
|
||||
/* squelch if beneath SNR threshold */
|
||||
|
||||
if (f->fdmdv_stats.snr_est < f->snr_thresh) {
|
||||
for(i=0; i<FREEDV_NSAMPLES; i++)
|
||||
speech_out[i] = 0;
|
||||
}
|
||||
|
||||
nout = FREEDV_NSAMPLES;
|
||||
}
|
||||
} /* if (sync) .... */
|
||||
else {
|
||||
// printf("\033[97mNot in sync. Pass demod_in to speech_out\n");
|
||||
/* if not in sync pass through analog samples */
|
||||
/* this lets us "hear" whats going on, e.g. during tuning */
|
||||
for(i=0; i<nin_prev; i++)
|
||||
speech_out[i] = demod_in[i];
|
||||
nout = nin_prev;
|
||||
}
|
||||
|
||||
return nout;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: freedv_api.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: August 2014
|
||||
|
||||
Library of API functions that implement FreeDV "modes", useful for
|
||||
embedding FreeDV in other programs.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2014 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __FREEDV__
|
||||
|
||||
#define FREEDV_MODE_1600 0
|
||||
#define FREEDV_NSAMPLES 320
|
||||
|
||||
#include "varicode.h"
|
||||
#include "codec2_fdmdv.h"
|
||||
|
||||
struct freedv {
|
||||
int mode;
|
||||
|
||||
void *codec2;
|
||||
struct FDMDV *fdmdv;
|
||||
struct FDMDV_STATS fdmdv_stats;
|
||||
|
||||
unsigned char *packed_codec_bits;
|
||||
int *codec_bits;
|
||||
int *tx_bits;
|
||||
int *fdmdv_bits;
|
||||
int *rx_bits;
|
||||
int tx_sync_bit;
|
||||
int total_bit_errors;
|
||||
|
||||
float snr_thresh;
|
||||
int nin;
|
||||
|
||||
struct VARICODE_DEC varicode_dec_states;
|
||||
short tx_varicode_bits[VARICODE_MAX_BITS];
|
||||
int nvaricode_bits;
|
||||
int varicode_bit_index;
|
||||
|
||||
/* user defined function ptrs to produce and consume ASCII
|
||||
characters using aux txt channel */
|
||||
|
||||
char (*freedv_get_next_tx_char)(void *callback_state);
|
||||
void (*freedv_put_next_rx_char)(void *callback_state, char c);
|
||||
|
||||
void *callback_state;
|
||||
|
||||
};
|
||||
|
||||
struct freedv *freedv_open(int mode);
|
||||
void freedv_close(struct freedv *freedv);
|
||||
void freedv_tx(struct freedv *f, short mod_out[], short speech_in[]);
|
||||
int freedv_nin(struct freedv *f);
|
||||
int freedv_rx(struct freedv *f, short speech_out[], short demod_in[]);
|
||||
|
||||
//float Get_freedv_S2N(struct freedv *f);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,418 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: golay23.c
|
||||
AUTHOR......: Robert Morelos-Zaragoza & David Rowe
|
||||
DATE CREATED: 3 March 2013
|
||||
|
||||
To test:
|
||||
|
||||
src$ gcc golay23.c -o golay23 -Wall -DGOLAY23_UNITTEST
|
||||
src$ ./golay23
|
||||
|
||||
To generate tables:
|
||||
src$ gcc golay23.c -o golay23 -Wall -DGOLAY23_MAKETABLES -DRUN_TIME_TABLES
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/* File: golay23.c
|
||||
* Title: Encoder/decoder for a binary (23,12,7) Golay code
|
||||
* Author: Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu)
|
||||
* Date: August 1994
|
||||
*
|
||||
* The binary (23,12,7) Golay code is an example of a perfect code, that is,
|
||||
* the number of syndromes equals the number of correctable error patterns.
|
||||
* The minimum distance is 7, so all error patterns of Hamming weight up to
|
||||
* 3 can be corrected. The total number of these error patterns is:
|
||||
*
|
||||
* Number of errors Number of patterns
|
||||
* ---------------- ------------------
|
||||
* 0 1
|
||||
* 1 23
|
||||
* 2 253
|
||||
* 3 1771
|
||||
* ----
|
||||
* Total number of error patterns = 2048 = 2^{11} = number of syndromes
|
||||
* --
|
||||
* number of redundant bits -------^
|
||||
*
|
||||
* Because of its relatively low length (23), dimension (12) and number of
|
||||
* redundant bits (11), the binary (23,12,7) Golay code can be encoded and
|
||||
* decoded simply by using look-up tables. The program below uses a 16K
|
||||
* encoding table and an 8K decoding table.
|
||||
*
|
||||
* For more information, suggestions, or other ideas on implementing error
|
||||
* correcting codes, please contact me at (I'm temporarily in Japan, but
|
||||
* below is my U.S. address):
|
||||
*
|
||||
* Robert Morelos-Zaragoza
|
||||
* 770 S. Post Oak Ln. #200
|
||||
* Houston, Texas 77056
|
||||
*
|
||||
* email: robert@spectra.eng.hawaii.edu
|
||||
*
|
||||
* Homework: Add an overall parity-check bit to get the (24,12,8)
|
||||
* extended Golay code.
|
||||
*
|
||||
* COPYRIGHT NOTICE: This computer program is free for non-commercial purposes.
|
||||
* You may implement this program for any non-commercial application. You may
|
||||
* also implement this program for commercial purposes, provided that you
|
||||
* obtain my written permission. Any modification of this program is covered
|
||||
* by this copyright.
|
||||
*
|
||||
* == Copyright (c) 1994 Robert Morelos-Zaragoza. All rights reserved. ==
|
||||
*/
|
||||
|
||||
#include "golay23.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define X22 0x00400000 /* vector representation of X^{22} */
|
||||
#define X11 0x00000800 /* vector representation of X^{11} */
|
||||
#define MASK12 0xfffff800 /* auxiliary vector for testing */
|
||||
#define GENPOL 0x00000c75 /* generator polinomial, g(x) */
|
||||
|
||||
/* Global variables:
|
||||
*
|
||||
* pattern = error pattern, or information, or received vector
|
||||
* encoding_table[] = encoding table
|
||||
* decoding_table[] = decoding table
|
||||
* data = information bits, i(x)
|
||||
* codeword = code bits = x^{11}i(x) + (x^{11}i(x) mod g(x))
|
||||
* numerr = number of errors = Hamming weight of error polynomial e(x)
|
||||
* position[] = error positions in the vector representation of e(x)
|
||||
* recd = representation of corrupted received polynomial r(x) = c(x) + e(x)
|
||||
* decerror = number of decoding errors
|
||||
* a[] = auxiliary array to generate correctable error patterns
|
||||
*/
|
||||
|
||||
static int inited = 0;
|
||||
|
||||
#ifdef RUN_TIME_TABLES
|
||||
static int encoding_table[4096], decoding_table[2048];
|
||||
#else
|
||||
#include "golayenctable.h"
|
||||
#include "golaydectable.h"
|
||||
#endif
|
||||
|
||||
#ifdef GOLAY23_UNITTEST
|
||||
static int position[23] = { 0x00000001, 0x00000002, 0x00000004, 0x00000008,
|
||||
0x00000010, 0x00000020, 0x00000040, 0x00000080,
|
||||
0x00000100, 0x00000200, 0x00000400, 0x00000800,
|
||||
0x00001000, 0x00002000, 0x00004000, 0x00008000,
|
||||
0x00010000, 0x00020000, 0x00040000, 0x00080000,
|
||||
0x00100000, 0x00200000, 0x00400000 };
|
||||
#endif
|
||||
|
||||
#ifdef RUN_TIME_TABLES
|
||||
static int arr2int(int a[], int r)
|
||||
/*
|
||||
* Convert a binary vector of Hamming weight r, and nonzero positions in
|
||||
* array a[1]...a[r], to a long integer \sum_{i=1}^r 2^{a[i]-1}.
|
||||
*/
|
||||
{
|
||||
int i;
|
||||
long mul, result = 0, temp;
|
||||
|
||||
for (i=1; i<=r; i++) {
|
||||
mul = 1;
|
||||
temp = a[i]-1;
|
||||
while (temp--)
|
||||
mul = mul << 1;
|
||||
result += mul;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
#endif
|
||||
|
||||
void nextcomb(int n, int r, int a[])
|
||||
/*
|
||||
* Calculate next r-combination of an n-set.
|
||||
*/
|
||||
{
|
||||
int i, j;
|
||||
|
||||
a[r]++;
|
||||
if (a[r] <= n)
|
||||
return;
|
||||
j = r - 1;
|
||||
while (a[j] == n - r + j)
|
||||
j--;
|
||||
for (i = r; i >= j; i--)
|
||||
a[i] = a[j] + i - j + 1;
|
||||
return;
|
||||
}
|
||||
|
||||
int get_syndrome(int pattern)
|
||||
/*
|
||||
* Compute the syndrome corresponding to the given pattern, i.e., the
|
||||
* remainder after dividing the pattern (when considering it as the vector
|
||||
* representation of a polynomial) by the generator polynomial, GENPOL.
|
||||
* In the program this pattern has several meanings: (1) pattern = infomation
|
||||
* bits, when constructing the encoding table; (2) pattern = error pattern,
|
||||
* when constructing the decoding table; and (3) pattern = received vector, to
|
||||
* obtain its syndrome in decoding.
|
||||
*/
|
||||
{
|
||||
int aux = X22;
|
||||
|
||||
if (pattern >= X11)
|
||||
while (pattern & MASK12) {
|
||||
while (!(aux & pattern))
|
||||
aux = aux >> 1;
|
||||
pattern ^= (aux/X11) * GENPOL;
|
||||
}
|
||||
return(pattern);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: golay23_init()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 3 March 2013
|
||||
|
||||
Call this once when you start your program to init the Golay tables.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void golay23_init(void) {
|
||||
#ifdef RUN_TIME_TABLES
|
||||
int i;
|
||||
long temp;
|
||||
int a[4];
|
||||
int pattern;
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------------
|
||||
* Generate ENCODING TABLE
|
||||
*
|
||||
* An entry to the table is an information vector, a 32-bit integer,
|
||||
* whose 12 least significant positions are the information bits. The
|
||||
* resulting value is a codeword in the (23,12,7) Golay code: A 32-bit
|
||||
* integer whose 23 least significant bits are coded bits: Of these, the
|
||||
* 12 most significant bits are information bits and the 11 least
|
||||
* significant bits are redundant bits (systematic encoding).
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
for (pattern = 0; pattern < 4096; pattern++) {
|
||||
temp = pattern << 11; /* multiply information by X^{11} */
|
||||
encoding_table[pattern] = temp + get_syndrome(temp);/* add redundancy */
|
||||
}
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------------
|
||||
* Generate DECODING TABLE
|
||||
*
|
||||
* An entry to the decoding table is a syndrome and the resulting value
|
||||
* is the most likely error pattern. First an error pattern is generated.
|
||||
* Then its syndrome is calculated and used as a pointer to the table
|
||||
* where the error pattern value is stored.
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* (1) Error patterns of WEIGHT 1 (SINGLE ERRORS)
|
||||
*/
|
||||
decoding_table[0] = 0;
|
||||
decoding_table[1] = 1;
|
||||
temp = 1;
|
||||
for (i=2; i<= 23; i++) {
|
||||
temp *= 2;
|
||||
decoding_table[get_syndrome(temp)] = temp;
|
||||
}
|
||||
/*
|
||||
* (2) Error patterns of WEIGHT 2 (DOUBLE ERRORS)
|
||||
*/
|
||||
a[1] = 1; a[2] = 2;
|
||||
temp = arr2int(a,2);
|
||||
decoding_table[get_syndrome(temp)] = temp;
|
||||
for (i=1; i<253; i++) {
|
||||
nextcomb(23,2,a);
|
||||
temp = arr2int(a,2);
|
||||
decoding_table[get_syndrome(temp)] = temp;
|
||||
}
|
||||
/*
|
||||
* (3) Error patterns of WEIGHT 3 (TRIPLE ERRORS)
|
||||
*/
|
||||
a[1] = 1; a[2] = 2; a[3] = 3;
|
||||
temp = arr2int(a,3);
|
||||
decoding_table[get_syndrome(temp)] = temp;
|
||||
for (i=1; i<1771; i++) {
|
||||
nextcomb(23,3,a);
|
||||
temp = arr2int(a,3);
|
||||
decoding_table[get_syndrome(temp)] = temp;
|
||||
}
|
||||
#endif
|
||||
inited = 1;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: golay23_encode()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 3 March 2013
|
||||
|
||||
Given 12 bits of data retiurns a 23 bit codeword for transmission
|
||||
over the channel.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
int golay23_encode(int data) {
|
||||
assert(inited);
|
||||
|
||||
//printf("data: 0x%x\n", data);
|
||||
assert(data <= 0xfff);
|
||||
return encoding_table[data];
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: golay23_decode()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 3 March 2013
|
||||
|
||||
Given a 23 bit received codeword, returns the 12 bit corrected data.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
int golay23_decode(int received_codeword) {
|
||||
assert(inited);
|
||||
|
||||
//printf("syndrome: 0x%x\n", get_syndrome(received_codeword));
|
||||
return received_codeword ^= decoding_table[get_syndrome(received_codeword)];
|
||||
}
|
||||
|
||||
int golay23_count_errors(int recd_codeword, int corrected_codeword)
|
||||
{
|
||||
int errors = 0;
|
||||
int diff, i;
|
||||
|
||||
diff = recd_codeword ^ corrected_codeword;
|
||||
for(i=0; i<23; i++) {
|
||||
if (diff & 0x1)
|
||||
errors++;
|
||||
diff >>= 1;
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
#ifdef GOLAY23_UNITTEST
|
||||
|
||||
static int golay23_test(int error_pattern) {
|
||||
int data;
|
||||
int codeword;
|
||||
int recd;
|
||||
int pattern;
|
||||
int decerror;
|
||||
int i, tests;
|
||||
|
||||
decerror = 0;
|
||||
tests = 0;
|
||||
|
||||
for (data = 0; data<(1<<12); data++) {
|
||||
|
||||
codeword = golay23_encode(data);
|
||||
recd = codeword ^ error_pattern;
|
||||
recd = golay23_decode(recd);
|
||||
pattern = (recd ^ codeword) >> 11;
|
||||
for (i=0; i<12; i++)
|
||||
if (pattern & position[i])
|
||||
decerror++;
|
||||
if (decerror) {
|
||||
printf("data: 0x%x codeword: 0x%x recd: 0x%x\n", data, codeword, recd);
|
||||
printf("there were %d decoding errors\n", decerror);
|
||||
exit(1);
|
||||
}
|
||||
tests++;
|
||||
}
|
||||
|
||||
return tests;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i;
|
||||
int tests;
|
||||
int a[4];
|
||||
int error_pattern;
|
||||
|
||||
golay23_init();
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Generate DATA
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* Test all combinations of data and 1,2 or 3 errors */
|
||||
|
||||
tests = 0;
|
||||
error_pattern = 1;
|
||||
for (i=0; i< 23; i++) {
|
||||
//printf("error_pattern: 0x%x\n", error_pattern);
|
||||
tests += golay23_test(error_pattern);
|
||||
error_pattern *= 2;
|
||||
}
|
||||
printf("%d 1 bit error tests performed OK!\n", tests);
|
||||
|
||||
tests = 0;
|
||||
a[1] = 1; a[2] = 2;
|
||||
error_pattern = arr2int(a,2);
|
||||
tests += golay23_test(error_pattern);
|
||||
for (i=1; i<253; i++) {
|
||||
nextcomb(23,2,a);
|
||||
error_pattern = arr2int(a,2);
|
||||
//printf("error_pattern: 0x%x\n", error_pattern);
|
||||
tests += golay23_test(error_pattern);
|
||||
}
|
||||
printf("%d 2 bit error tests performed OK!\n", tests);
|
||||
|
||||
tests = 0;
|
||||
a[1] = 1; a[2] = 2; a[3] = 3;
|
||||
error_pattern = arr2int(a,3);
|
||||
tests += golay23_test(error_pattern);
|
||||
for (i=1; i<1771; i++) {
|
||||
nextcomb(23,3,a);
|
||||
error_pattern = arr2int(a,3);
|
||||
//printf("error_pattern: 0x%x\n", error_pattern);
|
||||
tests += golay23_test(error_pattern);
|
||||
}
|
||||
printf("%d 3 bit error tests performed OK!\n", tests);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GOLAY23_MAKETABLES
|
||||
int main(int argc, char *argv[]) {
|
||||
FILE *f;
|
||||
int i;
|
||||
|
||||
golay23_init();
|
||||
|
||||
f=fopen("golayenctable.h","wt");
|
||||
assert(f != NULL);
|
||||
|
||||
fprintf(f,"/* Generated by golay23.c -DGOLAY23_MAKETABLE */\n\n");
|
||||
fprintf(f,"const int static encoding_table[]={\n");
|
||||
|
||||
for (i=0; i<4095; i++)
|
||||
fprintf(f," 0x%x,\n", encoding_table[i]);
|
||||
fprintf(f, " 0x%x\n};\n", encoding_table[i]);
|
||||
fclose(f);
|
||||
|
||||
f=fopen("golaydectable.h","wt");
|
||||
assert(f != NULL);
|
||||
|
||||
fprintf(f,"/* Generated by golay23.c -DGOLAY23_MAKETABLE */\n\n");
|
||||
fprintf(f,"const int static decoding_table[]={\n");
|
||||
|
||||
for (i=0; i<2047; i++)
|
||||
fprintf(f," 0x%x,\n", decoding_table[i]);
|
||||
fprintf(f, " 0x%x\n};\n", decoding_table[i]);
|
||||
fclose(f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: golay23.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 3 March 2013
|
||||
|
||||
Header file for Golay FEC.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2013 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __GOLAY23__
|
||||
#define __GOLAY23__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void golay23_init(void);
|
||||
int golay23_encode(int data);
|
||||
int golay23_decode(int received_codeword);
|
||||
int golay23_count_errors(int recd_codeword, int corrected_codeword);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,644 +0,0 @@
|
|||
/* Generated by hanning_file() Octave function */
|
||||
|
||||
const float hanning[]={
|
||||
0,
|
||||
2.4171e-05,
|
||||
9.66816e-05,
|
||||
0.000217525,
|
||||
0.000386689,
|
||||
0.000604158,
|
||||
0.00086991,
|
||||
0.00118392,
|
||||
0.00154616,
|
||||
0.00195659,
|
||||
0.00241517,
|
||||
0.00292186,
|
||||
0.00347661,
|
||||
0.00407937,
|
||||
0.00473008,
|
||||
0.00542867,
|
||||
0.00617507,
|
||||
0.00696922,
|
||||
0.00781104,
|
||||
0.00870045,
|
||||
0.00963736,
|
||||
0.0106217,
|
||||
0.0116533,
|
||||
0.0127322,
|
||||
0.0138581,
|
||||
0.0150311,
|
||||
0.0162509,
|
||||
0.0175175,
|
||||
0.0188308,
|
||||
0.0201906,
|
||||
0.0215968,
|
||||
0.0230492,
|
||||
0.0245478,
|
||||
0.0260923,
|
||||
0.0276826,
|
||||
0.0293186,
|
||||
0.0310001,
|
||||
0.032727,
|
||||
0.034499,
|
||||
0.036316,
|
||||
0.0381779,
|
||||
0.0400844,
|
||||
0.0420354,
|
||||
0.0440307,
|
||||
0.04607,
|
||||
0.0481533,
|
||||
0.0502802,
|
||||
0.0524506,
|
||||
0.0546643,
|
||||
0.056921,
|
||||
0.0592206,
|
||||
0.0615627,
|
||||
0.0639473,
|
||||
0.0663741,
|
||||
0.0688427,
|
||||
0.0713531,
|
||||
0.0739048,
|
||||
0.0764978,
|
||||
0.0791318,
|
||||
0.0818064,
|
||||
0.0845214,
|
||||
0.0872767,
|
||||
0.0900718,
|
||||
0.0929066,
|
||||
0.0957807,
|
||||
0.0986939,
|
||||
0.101646,
|
||||
0.104636,
|
||||
0.107665,
|
||||
0.110732,
|
||||
0.113836,
|
||||
0.116978,
|
||||
0.120156,
|
||||
0.123372,
|
||||
0.126624,
|
||||
0.129912,
|
||||
0.133235,
|
||||
0.136594,
|
||||
0.139989,
|
||||
0.143418,
|
||||
0.146881,
|
||||
0.150379,
|
||||
0.153911,
|
||||
0.157476,
|
||||
0.161074,
|
||||
0.164705,
|
||||
0.168368,
|
||||
0.172063,
|
||||
0.17579,
|
||||
0.179549,
|
||||
0.183338,
|
||||
0.187158,
|
||||
0.191008,
|
||||
0.194888,
|
||||
0.198798,
|
||||
0.202737,
|
||||
0.206704,
|
||||
0.2107,
|
||||
0.214724,
|
||||
0.218775,
|
||||
0.222854,
|
||||
0.226959,
|
||||
0.231091,
|
||||
0.235249,
|
||||
0.239432,
|
||||
0.243641,
|
||||
0.247874,
|
||||
0.252132,
|
||||
0.256414,
|
||||
0.260719,
|
||||
0.265047,
|
||||
0.269398,
|
||||
0.273772,
|
||||
0.278167,
|
||||
0.282584,
|
||||
0.287021,
|
||||
0.29148,
|
||||
0.295958,
|
||||
0.300456,
|
||||
0.304974,
|
||||
0.30951,
|
||||
0.314065,
|
||||
0.318638,
|
||||
0.323228,
|
||||
0.327835,
|
||||
0.332459,
|
||||
0.3371,
|
||||
0.341756,
|
||||
0.346427,
|
||||
0.351113,
|
||||
0.355814,
|
||||
0.360528,
|
||||
0.365256,
|
||||
0.369997,
|
||||
0.374751,
|
||||
0.379516,
|
||||
0.384293,
|
||||
0.389082,
|
||||
0.393881,
|
||||
0.398691,
|
||||
0.40351,
|
||||
0.408338,
|
||||
0.413176,
|
||||
0.418022,
|
||||
0.422876,
|
||||
0.427737,
|
||||
0.432605,
|
||||
0.43748,
|
||||
0.44236,
|
||||
0.447247,
|
||||
0.452138,
|
||||
0.457034,
|
||||
0.461935,
|
||||
0.466839,
|
||||
0.471746,
|
||||
0.476655,
|
||||
0.481568,
|
||||
0.486481,
|
||||
0.491397,
|
||||
0.496313,
|
||||
0.501229,
|
||||
0.506145,
|
||||
0.511061,
|
||||
0.515976,
|
||||
0.520889,
|
||||
0.5258,
|
||||
0.530708,
|
||||
0.535614,
|
||||
0.540516,
|
||||
0.545414,
|
||||
0.550308,
|
||||
0.555197,
|
||||
0.560081,
|
||||
0.564958,
|
||||
0.56983,
|
||||
0.574695,
|
||||
0.579552,
|
||||
0.584402,
|
||||
0.589244,
|
||||
0.594077,
|
||||
0.598901,
|
||||
0.603715,
|
||||
0.60852,
|
||||
0.613314,
|
||||
0.618097,
|
||||
0.622868,
|
||||
0.627628,
|
||||
0.632375,
|
||||
0.63711,
|
||||
0.641831,
|
||||
0.646538,
|
||||
0.651232,
|
||||
0.655911,
|
||||
0.660574,
|
||||
0.665222,
|
||||
0.669855,
|
||||
0.67447,
|
||||
0.679069,
|
||||
0.683651,
|
||||
0.688215,
|
||||
0.69276,
|
||||
0.697287,
|
||||
0.701795,
|
||||
0.706284,
|
||||
0.710752,
|
||||
0.7152,
|
||||
0.719627,
|
||||
0.724033,
|
||||
0.728418,
|
||||
0.73278,
|
||||
0.73712,
|
||||
0.741437,
|
||||
0.74573,
|
||||
0.75,
|
||||
0.754246,
|
||||
0.758467,
|
||||
0.762663,
|
||||
0.766833,
|
||||
0.770978,
|
||||
0.775097,
|
||||
0.779189,
|
||||
0.783254,
|
||||
0.787291,
|
||||
0.791301,
|
||||
0.795283,
|
||||
0.799236,
|
||||
0.80316,
|
||||
0.807055,
|
||||
0.810921,
|
||||
0.814756,
|
||||
0.81856,
|
||||
0.822334,
|
||||
0.826077,
|
||||
0.829788,
|
||||
0.833468,
|
||||
0.837115,
|
||||
0.840729,
|
||||
0.844311,
|
||||
0.847859,
|
||||
0.851374,
|
||||
0.854855,
|
||||
0.858301,
|
||||
0.861713,
|
||||
0.86509,
|
||||
0.868431,
|
||||
0.871737,
|
||||
0.875007,
|
||||
0.87824,
|
||||
0.881437,
|
||||
0.884598,
|
||||
0.887721,
|
||||
0.890806,
|
||||
0.893854,
|
||||
0.896864,
|
||||
0.899835,
|
||||
0.902768,
|
||||
0.905661,
|
||||
0.908516,
|
||||
0.911331,
|
||||
0.914106,
|
||||
0.916841,
|
||||
0.919536,
|
||||
0.92219,
|
||||
0.924804,
|
||||
0.927376,
|
||||
0.929907,
|
||||
0.932397,
|
||||
0.934845,
|
||||
0.93725,
|
||||
0.939614,
|
||||
0.941935,
|
||||
0.944213,
|
||||
0.946448,
|
||||
0.94864,
|
||||
0.950789,
|
||||
0.952894,
|
||||
0.954955,
|
||||
0.956972,
|
||||
0.958946,
|
||||
0.960874,
|
||||
0.962759,
|
||||
0.964598,
|
||||
0.966393,
|
||||
0.968142,
|
||||
0.969846,
|
||||
0.971505,
|
||||
0.973118,
|
||||
0.974686,
|
||||
0.976207,
|
||||
0.977683,
|
||||
0.979112,
|
||||
0.980495,
|
||||
0.981832,
|
||||
0.983122,
|
||||
0.984365,
|
||||
0.985561,
|
||||
0.986711,
|
||||
0.987813,
|
||||
0.988868,
|
||||
0.989876,
|
||||
0.990837,
|
||||
0.99175,
|
||||
0.992616,
|
||||
0.993434,
|
||||
0.994204,
|
||||
0.994927,
|
||||
0.995601,
|
||||
0.996228,
|
||||
0.996807,
|
||||
0.997337,
|
||||
0.99782,
|
||||
0.998255,
|
||||
0.998641,
|
||||
0.998979,
|
||||
0.999269,
|
||||
0.999511,
|
||||
0.999704,
|
||||
0.999849,
|
||||
0.999946,
|
||||
0.999994,
|
||||
0.999994,
|
||||
0.999946,
|
||||
0.999849,
|
||||
0.999704,
|
||||
0.999511,
|
||||
0.999269,
|
||||
0.998979,
|
||||
0.998641,
|
||||
0.998255,
|
||||
0.99782,
|
||||
0.997337,
|
||||
0.996807,
|
||||
0.996228,
|
||||
0.995601,
|
||||
0.994927,
|
||||
0.994204,
|
||||
0.993434,
|
||||
0.992616,
|
||||
0.99175,
|
||||
0.990837,
|
||||
0.989876,
|
||||
0.988868,
|
||||
0.987813,
|
||||
0.986711,
|
||||
0.985561,
|
||||
0.984365,
|
||||
0.983122,
|
||||
0.981832,
|
||||
0.980495,
|
||||
0.979112,
|
||||
0.977683,
|
||||
0.976207,
|
||||
0.974686,
|
||||
0.973118,
|
||||
0.971505,
|
||||
0.969846,
|
||||
0.968142,
|
||||
0.966393,
|
||||
0.964598,
|
||||
0.962759,
|
||||
0.960874,
|
||||
0.958946,
|
||||
0.956972,
|
||||
0.954955,
|
||||
0.952894,
|
||||
0.950789,
|
||||
0.94864,
|
||||
0.946448,
|
||||
0.944213,
|
||||
0.941935,
|
||||
0.939614,
|
||||
0.93725,
|
||||
0.934845,
|
||||
0.932397,
|
||||
0.929907,
|
||||
0.927376,
|
||||
0.924804,
|
||||
0.92219,
|
||||
0.919536,
|
||||
0.916841,
|
||||
0.914106,
|
||||
0.911331,
|
||||
0.908516,
|
||||
0.905661,
|
||||
0.902768,
|
||||
0.899835,
|
||||
0.896864,
|
||||
0.893854,
|
||||
0.890806,
|
||||
0.887721,
|
||||
0.884598,
|
||||
0.881437,
|
||||
0.87824,
|
||||
0.875007,
|
||||
0.871737,
|
||||
0.868431,
|
||||
0.86509,
|
||||
0.861713,
|
||||
0.858301,
|
||||
0.854855,
|
||||
0.851374,
|
||||
0.847859,
|
||||
0.844311,
|
||||
0.840729,
|
||||
0.837115,
|
||||
0.833468,
|
||||
0.829788,
|
||||
0.826077,
|
||||
0.822334,
|
||||
0.81856,
|
||||
0.814756,
|
||||
0.810921,
|
||||
0.807055,
|
||||
0.80316,
|
||||
0.799236,
|
||||
0.795283,
|
||||
0.791301,
|
||||
0.787291,
|
||||
0.783254,
|
||||
0.779189,
|
||||
0.775097,
|
||||
0.770978,
|
||||
0.766833,
|
||||
0.762663,
|
||||
0.758467,
|
||||
0.754246,
|
||||
0.75,
|
||||
0.74573,
|
||||
0.741437,
|
||||
0.73712,
|
||||
0.73278,
|
||||
0.728418,
|
||||
0.724033,
|
||||
0.719627,
|
||||
0.7152,
|
||||
0.710752,
|
||||
0.706284,
|
||||
0.701795,
|
||||
0.697287,
|
||||
0.69276,
|
||||
0.688215,
|
||||
0.683651,
|
||||
0.679069,
|
||||
0.67447,
|
||||
0.669855,
|
||||
0.665222,
|
||||
0.660574,
|
||||
0.655911,
|
||||
0.651232,
|
||||
0.646538,
|
||||
0.641831,
|
||||
0.63711,
|
||||
0.632375,
|
||||
0.627628,
|
||||
0.622868,
|
||||
0.618097,
|
||||
0.613314,
|
||||
0.60852,
|
||||
0.603715,
|
||||
0.598901,
|
||||
0.594077,
|
||||
0.589244,
|
||||
0.584402,
|
||||
0.579552,
|
||||
0.574695,
|
||||
0.56983,
|
||||
0.564958,
|
||||
0.560081,
|
||||
0.555197,
|
||||
0.550308,
|
||||
0.545414,
|
||||
0.540516,
|
||||
0.535614,
|
||||
0.530708,
|
||||
0.5258,
|
||||
0.520889,
|
||||
0.515976,
|
||||
0.511061,
|
||||
0.506145,
|
||||
0.501229,
|
||||
0.496313,
|
||||
0.491397,
|
||||
0.486481,
|
||||
0.481568,
|
||||
0.476655,
|
||||
0.471746,
|
||||
0.466839,
|
||||
0.461935,
|
||||
0.457034,
|
||||
0.452138,
|
||||
0.447247,
|
||||
0.44236,
|
||||
0.43748,
|
||||
0.432605,
|
||||
0.427737,
|
||||
0.422876,
|
||||
0.418022,
|
||||
0.413176,
|
||||
0.408338,
|
||||
0.40351,
|
||||
0.398691,
|
||||
0.393881,
|
||||
0.389082,
|
||||
0.384293,
|
||||
0.379516,
|
||||
0.374751,
|
||||
0.369997,
|
||||
0.365256,
|
||||
0.360528,
|
||||
0.355814,
|
||||
0.351113,
|
||||
0.346427,
|
||||
0.341756,
|
||||
0.3371,
|
||||
0.332459,
|
||||
0.327835,
|
||||
0.323228,
|
||||
0.318638,
|
||||
0.314065,
|
||||
0.30951,
|
||||
0.304974,
|
||||
0.300456,
|
||||
0.295958,
|
||||
0.29148,
|
||||
0.287021,
|
||||
0.282584,
|
||||
0.278167,
|
||||
0.273772,
|
||||
0.269398,
|
||||
0.265047,
|
||||
0.260719,
|
||||
0.256414,
|
||||
0.252132,
|
||||
0.247874,
|
||||
0.243641,
|
||||
0.239432,
|
||||
0.235249,
|
||||
0.231091,
|
||||
0.226959,
|
||||
0.222854,
|
||||
0.218775,
|
||||
0.214724,
|
||||
0.2107,
|
||||
0.206704,
|
||||
0.202737,
|
||||
0.198798,
|
||||
0.194888,
|
||||
0.191008,
|
||||
0.187158,
|
||||
0.183338,
|
||||
0.179549,
|
||||
0.17579,
|
||||
0.172063,
|
||||
0.168368,
|
||||
0.164705,
|
||||
0.161074,
|
||||
0.157476,
|
||||
0.153911,
|
||||
0.150379,
|
||||
0.146881,
|
||||
0.143418,
|
||||
0.139989,
|
||||
0.136594,
|
||||
0.133235,
|
||||
0.129912,
|
||||
0.126624,
|
||||
0.123372,
|
||||
0.120156,
|
||||
0.116978,
|
||||
0.113836,
|
||||
0.110732,
|
||||
0.107665,
|
||||
0.104636,
|
||||
0.101646,
|
||||
0.0986939,
|
||||
0.0957807,
|
||||
0.0929066,
|
||||
0.0900718,
|
||||
0.0872767,
|
||||
0.0845214,
|
||||
0.0818064,
|
||||
0.0791318,
|
||||
0.0764978,
|
||||
0.0739048,
|
||||
0.0713531,
|
||||
0.0688427,
|
||||
0.0663741,
|
||||
0.0639473,
|
||||
0.0615627,
|
||||
0.0592206,
|
||||
0.056921,
|
||||
0.0546643,
|
||||
0.0524506,
|
||||
0.0502802,
|
||||
0.0481533,
|
||||
0.04607,
|
||||
0.0440307,
|
||||
0.0420354,
|
||||
0.0400844,
|
||||
0.0381779,
|
||||
0.036316,
|
||||
0.034499,
|
||||
0.032727,
|
||||
0.0310001,
|
||||
0.0293186,
|
||||
0.0276826,
|
||||
0.0260923,
|
||||
0.0245478,
|
||||
0.0230492,
|
||||
0.0215968,
|
||||
0.0201906,
|
||||
0.0188308,
|
||||
0.0175175,
|
||||
0.0162509,
|
||||
0.0150311,
|
||||
0.0138581,
|
||||
0.0127322,
|
||||
0.0116533,
|
||||
0.0106217,
|
||||
0.00963736,
|
||||
0.00870045,
|
||||
0.00781104,
|
||||
0.00696922,
|
||||
0.00617507,
|
||||
0.00542867,
|
||||
0.00473008,
|
||||
0.00407937,
|
||||
0.00347661,
|
||||
0.00292186,
|
||||
0.00241517,
|
||||
0.00195659,
|
||||
0.00154616,
|
||||
0.00118392,
|
||||
0.00086991,
|
||||
0.000604158,
|
||||
0.000386689,
|
||||
0.000217525,
|
||||
9.66816e-05,
|
||||
2.4171e-05,
|
||||
0
|
||||
};
|
||||
|
|
@ -1,325 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: interp.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 9/10/09
|
||||
|
||||
Interpolation of 20ms frames to 10ms frames.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "interp.h"
|
||||
#include "lsp.h"
|
||||
#include "quantise.h"
|
||||
|
||||
float sample_log_amp(MODEL *model, float w);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
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
|
||||
amplitudes and Wo for the interpolated frame.
|
||||
|
||||
This version can interpolate the amplitudes between two frames of
|
||||
different Wo and L.
|
||||
|
||||
This version works by log linear interpolation, but listening tests
|
||||
showed it creates problems in background noise, e.g. hts2a and mmt1.
|
||||
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(
|
||||
MODEL *interp, /* interpolated model params */
|
||||
MODEL *prev, /* previous frames model params */
|
||||
MODEL *next /* next frames model params */
|
||||
)
|
||||
{
|
||||
int l;
|
||||
float w,log_amp;
|
||||
|
||||
/* Wo depends on voicing of this and adjacent frames */
|
||||
|
||||
if (interp->voiced) {
|
||||
if (prev->voiced && next->voiced)
|
||||
interp->Wo = (prev->Wo + next->Wo)/2.0;
|
||||
if (!prev->voiced && next->voiced)
|
||||
interp->Wo = next->Wo;
|
||||
if (prev->voiced && !next->voiced)
|
||||
interp->Wo = prev->Wo;
|
||||
}
|
||||
else {
|
||||
interp->Wo = TWO_PI/P_MAX;
|
||||
}
|
||||
interp->L = PI/interp->Wo;
|
||||
|
||||
/* Interpolate amplitudes using linear interpolation in log domain */
|
||||
|
||||
for(l=1; l<=interp->L; l++) {
|
||||
w = l*interp->Wo;
|
||||
log_amp = (sample_log_amp(prev, w) + sample_log_amp(next, w))/2.0;
|
||||
interp->A[l] = pow(10.0, log_amp);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: sample_log_amp()
|
||||
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)
|
||||
{
|
||||
int m;
|
||||
float f, log_amp;
|
||||
|
||||
assert(w > 0.0); assert (w <= PI);
|
||||
|
||||
m = floorf(w/model->Wo + 0.5);
|
||||
f = (w - m*model->Wo)/w;
|
||||
assert(f <= 1.0);
|
||||
|
||||
if (m < 1) {
|
||||
log_amp = f*log10f(model->A[1] + 1E-6);
|
||||
}
|
||||
else if ((m+1) > model->L) {
|
||||
log_amp = (1.0-f)*log10f(model->A[model->L] + 1E-6);
|
||||
}
|
||||
else {
|
||||
log_amp = (1.0-f)*log10f(model->A[m] + 1E-6) +
|
||||
f*log10f(model->A[m+1] + 1E-6);
|
||||
}
|
||||
|
||||
return log_amp;
|
||||
}
|
||||
|
||||
#ifdef NOT_NEEDED
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
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
|
||||
amplitudes and Wo for the interpolated frame.
|
||||
|
||||
This version uses interpolation of LSPs, seems to do a better job
|
||||
with bg noise.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void interpolate_lsp(
|
||||
kiss_fft_cfg fft_fwd_cfg,
|
||||
MODEL *interp, /* interpolated model params */
|
||||
MODEL *prev, /* previous frames model params */
|
||||
MODEL *next, /* next frames model params */
|
||||
float *prev_lsps, /* previous frames LSPs */
|
||||
float prev_e, /* previous frames LPC energy */
|
||||
float *next_lsps, /* next frames LSPs */
|
||||
float next_e, /* next frames LPC energy */
|
||||
float *ak_interp, /* interpolated aks for this frame */
|
||||
float *lsps_interp/* interpolated lsps for this frame */
|
||||
)
|
||||
{
|
||||
int i;
|
||||
float e;
|
||||
float snr;
|
||||
|
||||
/* trap corner case where V est is probably wrong */
|
||||
|
||||
if (interp->voiced && !prev->voiced && !next->voiced) {
|
||||
interp->voiced = 0;
|
||||
}
|
||||
|
||||
/* Wo depends on voicing of this and adjacent frames */
|
||||
|
||||
if (interp->voiced) {
|
||||
if (prev->voiced && next->voiced)
|
||||
interp->Wo = (prev->Wo + next->Wo)/2.0;
|
||||
if (!prev->voiced && next->voiced)
|
||||
interp->Wo = next->Wo;
|
||||
if (prev->voiced && !next->voiced)
|
||||
interp->Wo = prev->Wo;
|
||||
}
|
||||
else {
|
||||
interp->Wo = TWO_PI/P_MAX;
|
||||
}
|
||||
interp->L = PI/interp->Wo;
|
||||
|
||||
//printf(" interp: prev_v: %d next_v: %d prev_Wo: %f next_Wo: %f\n",
|
||||
// prev->voiced, next->voiced, prev->Wo, next->Wo);
|
||||
//printf(" interp: Wo: %1.5f L: %d\n", interp->Wo, interp->L);
|
||||
|
||||
/* interpolate LSPs */
|
||||
|
||||
for(i=0; i<LPC_ORD; i++) {
|
||||
lsps_interp[i] = (prev_lsps[i] + next_lsps[i])/2.0;
|
||||
}
|
||||
|
||||
/* Interpolate LPC energy in log domain */
|
||||
|
||||
e = powf(10.0, (log10f(prev_e) + log10f(next_e))/2.0);
|
||||
//printf(" interp: e: %f\n", e);
|
||||
|
||||
/* convert back to amplitudes */
|
||||
|
||||
lsp_to_lpc(lsps_interp, ak_interp, LPC_ORD);
|
||||
aks_to_M2(fft_fwd_cfg, ak_interp, LPC_ORD, interp, e, &snr, 0, 0, 1, 1, LPCPF_BETA, LPCPF_GAMMA);
|
||||
//printf(" interp: ak[1]: %f A[1] %f\n", ak_interp[1], interp->A[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: interp_Wo()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 22 May 2012
|
||||
|
||||
Interpolates centre 10ms sample of Wo and L samples given two
|
||||
samples 20ms apart. Assumes voicing is available for centre
|
||||
(interpolated) frame.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void interp_Wo(
|
||||
MODEL *interp, /* interpolated model params */
|
||||
MODEL *prev, /* previous frames model params */
|
||||
MODEL *next /* next frames model params */
|
||||
)
|
||||
{
|
||||
interp_Wo2(interp, prev, next, 0.5);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: interp_Wo2()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 22 May 2012
|
||||
|
||||
Weighted interpolation of two Wo samples.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void interp_Wo2(
|
||||
MODEL *interp, /* interpolated model params */
|
||||
MODEL *prev, /* previous frames model params */
|
||||
MODEL *next, /* next frames model params */
|
||||
float weight
|
||||
)
|
||||
{
|
||||
/* trap corner case where voicing est is probably wrong */
|
||||
|
||||
if (interp->voiced && !prev->voiced && !next->voiced) {
|
||||
interp->voiced = 0;
|
||||
}
|
||||
|
||||
/* Wo depends on voicing of this and adjacent frames */
|
||||
|
||||
if (interp->voiced) {
|
||||
if (prev->voiced && next->voiced)
|
||||
interp->Wo = (1.0 - weight)*prev->Wo + weight*next->Wo;
|
||||
if (!prev->voiced && next->voiced)
|
||||
interp->Wo = next->Wo;
|
||||
if (prev->voiced && !next->voiced)
|
||||
interp->Wo = prev->Wo;
|
||||
}
|
||||
else {
|
||||
interp->Wo = TWO_PI/P_MAX;
|
||||
}
|
||||
interp->L = PI/interp->Wo;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: interp_energy()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 22 May 2012
|
||||
|
||||
Interpolates centre 10ms sample of energy given two samples 20ms
|
||||
apart.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
float interp_energy(float prev_e, float next_e)
|
||||
{
|
||||
return powf(10.0, (log10f(prev_e) + log10f(next_e))/2.0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: interp_energy2()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 22 May 2012
|
||||
|
||||
Interpolates centre 10ms sample of energy given two samples 20ms
|
||||
apart.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
float interp_energy2(float prev_e, float next_e, float weight)
|
||||
{
|
||||
return powf(10.0, (1.0 - weight)*log10f(prev_e) + weight*log10f(next_e));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: interpolate_lsp_ver2()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 22 May 2012
|
||||
|
||||
Weighted interpolation of LSPs.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void interpolate_lsp_ver2(float interp[], float prev[], float next[], float weight)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<LPC_ORD; i++)
|
||||
interp[i] = (1.0 - weight)*prev[i] + weight*next[i];
|
||||
}
|
||||
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: interp.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 9/10/09
|
||||
|
||||
Interpolation of 20ms frames to 10ms frames.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __INTERP__
|
||||
#define __INTERP__
|
||||
|
||||
#include "kiss_fft.h"
|
||||
|
||||
void interpolate(MODEL *interp, MODEL *prev, MODEL *next);
|
||||
void interpolate_lsp(kiss_fft_cfg fft_dec_cfg,
|
||||
MODEL *interp, MODEL *prev, MODEL *next,
|
||||
float *prev_lsps, float prev_e,
|
||||
float *next_lsps, float next_e,
|
||||
float *ak_interp, float *lsps_interp);
|
||||
void interp_Wo(MODEL *interp, MODEL *prev, MODEL *next);
|
||||
void interp_Wo2(MODEL *interp, MODEL *prev, MODEL *next, float weight);
|
||||
float interp_energy(float prev, float next);
|
||||
float interp_energy2(float prev, float next, float weight);
|
||||
void interpolate_lsp_ver2(float interp[], float prev[], float next[], float weight);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,408 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2003-2010, Mark Borgerding
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "_kiss_fft_guts.h"
|
||||
/* The guts header contains all the multiplication and addition macros that are defined for
|
||||
fixed or floating point complex numbers. It also delares the kf_ internal functions.
|
||||
*/
|
||||
|
||||
static void kf_bfly2(
|
||||
kiss_fft_cpx * Fout,
|
||||
const size_t fstride,
|
||||
const kiss_fft_cfg st,
|
||||
int m
|
||||
)
|
||||
{
|
||||
kiss_fft_cpx * Fout2;
|
||||
kiss_fft_cpx * tw1 = st->twiddles;
|
||||
kiss_fft_cpx t;
|
||||
Fout2 = Fout + m;
|
||||
do{
|
||||
C_FIXDIV(*Fout,2); C_FIXDIV(*Fout2,2);
|
||||
|
||||
C_MUL (t, *Fout2 , *tw1);
|
||||
tw1 += fstride;
|
||||
C_SUB( *Fout2 , *Fout , t );
|
||||
C_ADDTO( *Fout , t );
|
||||
++Fout2;
|
||||
++Fout;
|
||||
}while (--m);
|
||||
}
|
||||
|
||||
static void kf_bfly4(
|
||||
kiss_fft_cpx * Fout,
|
||||
const size_t fstride,
|
||||
const kiss_fft_cfg st,
|
||||
const size_t m
|
||||
)
|
||||
{
|
||||
kiss_fft_cpx *tw1,*tw2,*tw3;
|
||||
kiss_fft_cpx scratch[6];
|
||||
size_t k=m;
|
||||
const size_t m2=2*m;
|
||||
const size_t m3=3*m;
|
||||
|
||||
|
||||
tw3 = tw2 = tw1 = st->twiddles;
|
||||
|
||||
do {
|
||||
C_FIXDIV(*Fout,4); C_FIXDIV(Fout[m],4); C_FIXDIV(Fout[m2],4); C_FIXDIV(Fout[m3],4);
|
||||
|
||||
C_MUL(scratch[0],Fout[m] , *tw1 );
|
||||
C_MUL(scratch[1],Fout[m2] , *tw2 );
|
||||
C_MUL(scratch[2],Fout[m3] , *tw3 );
|
||||
|
||||
C_SUB( scratch[5] , *Fout, scratch[1] );
|
||||
C_ADDTO(*Fout, scratch[1]);
|
||||
C_ADD( scratch[3] , scratch[0] , scratch[2] );
|
||||
C_SUB( scratch[4] , scratch[0] , scratch[2] );
|
||||
C_SUB( Fout[m2], *Fout, scratch[3] );
|
||||
tw1 += fstride;
|
||||
tw2 += fstride*2;
|
||||
tw3 += fstride*3;
|
||||
C_ADDTO( *Fout , scratch[3] );
|
||||
|
||||
if(st->inverse) {
|
||||
Fout[m].r = scratch[5].r - scratch[4].i;
|
||||
Fout[m].i = scratch[5].i + scratch[4].r;
|
||||
Fout[m3].r = scratch[5].r + scratch[4].i;
|
||||
Fout[m3].i = scratch[5].i - scratch[4].r;
|
||||
}else{
|
||||
Fout[m].r = scratch[5].r + scratch[4].i;
|
||||
Fout[m].i = scratch[5].i - scratch[4].r;
|
||||
Fout[m3].r = scratch[5].r - scratch[4].i;
|
||||
Fout[m3].i = scratch[5].i + scratch[4].r;
|
||||
}
|
||||
++Fout;
|
||||
}while(--k);
|
||||
}
|
||||
|
||||
static void kf_bfly3(
|
||||
kiss_fft_cpx * Fout,
|
||||
const size_t fstride,
|
||||
const kiss_fft_cfg st,
|
||||
size_t m
|
||||
)
|
||||
{
|
||||
size_t k=m;
|
||||
const size_t m2 = 2*m;
|
||||
kiss_fft_cpx *tw1,*tw2;
|
||||
kiss_fft_cpx scratch[5];
|
||||
kiss_fft_cpx epi3;
|
||||
epi3 = st->twiddles[fstride*m];
|
||||
|
||||
tw1=tw2=st->twiddles;
|
||||
|
||||
do{
|
||||
C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3);
|
||||
|
||||
C_MUL(scratch[1],Fout[m] , *tw1);
|
||||
C_MUL(scratch[2],Fout[m2] , *tw2);
|
||||
|
||||
C_ADD(scratch[3],scratch[1],scratch[2]);
|
||||
C_SUB(scratch[0],scratch[1],scratch[2]);
|
||||
tw1 += fstride;
|
||||
tw2 += fstride*2;
|
||||
|
||||
Fout[m].r = Fout->r - HALF_OF(scratch[3].r);
|
||||
Fout[m].i = Fout->i - HALF_OF(scratch[3].i);
|
||||
|
||||
C_MULBYSCALAR( scratch[0] , epi3.i );
|
||||
|
||||
C_ADDTO(*Fout,scratch[3]);
|
||||
|
||||
Fout[m2].r = Fout[m].r + scratch[0].i;
|
||||
Fout[m2].i = Fout[m].i - scratch[0].r;
|
||||
|
||||
Fout[m].r -= scratch[0].i;
|
||||
Fout[m].i += scratch[0].r;
|
||||
|
||||
++Fout;
|
||||
}while(--k);
|
||||
}
|
||||
|
||||
static void kf_bfly5(
|
||||
kiss_fft_cpx * Fout,
|
||||
const size_t fstride,
|
||||
const kiss_fft_cfg st,
|
||||
int m
|
||||
)
|
||||
{
|
||||
kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4;
|
||||
int u;
|
||||
kiss_fft_cpx scratch[13];
|
||||
kiss_fft_cpx * twiddles = st->twiddles;
|
||||
kiss_fft_cpx *tw;
|
||||
kiss_fft_cpx ya,yb;
|
||||
ya = twiddles[fstride*m];
|
||||
yb = twiddles[fstride*2*m];
|
||||
|
||||
Fout0=Fout;
|
||||
Fout1=Fout0+m;
|
||||
Fout2=Fout0+2*m;
|
||||
Fout3=Fout0+3*m;
|
||||
Fout4=Fout0+4*m;
|
||||
|
||||
tw=st->twiddles;
|
||||
for ( u=0; u<m; ++u ) {
|
||||
C_FIXDIV( *Fout0,5); C_FIXDIV( *Fout1,5); C_FIXDIV( *Fout2,5); C_FIXDIV( *Fout3,5); C_FIXDIV( *Fout4,5);
|
||||
scratch[0] = *Fout0;
|
||||
|
||||
C_MUL(scratch[1] ,*Fout1, tw[u*fstride]);
|
||||
C_MUL(scratch[2] ,*Fout2, tw[2*u*fstride]);
|
||||
C_MUL(scratch[3] ,*Fout3, tw[3*u*fstride]);
|
||||
C_MUL(scratch[4] ,*Fout4, tw[4*u*fstride]);
|
||||
|
||||
C_ADD( scratch[7],scratch[1],scratch[4]);
|
||||
C_SUB( scratch[10],scratch[1],scratch[4]);
|
||||
C_ADD( scratch[8],scratch[2],scratch[3]);
|
||||
C_SUB( scratch[9],scratch[2],scratch[3]);
|
||||
|
||||
Fout0->r += scratch[7].r + scratch[8].r;
|
||||
Fout0->i += scratch[7].i + scratch[8].i;
|
||||
|
||||
scratch[5].r = scratch[0].r + S_MUL(scratch[7].r,ya.r) + S_MUL(scratch[8].r,yb.r);
|
||||
scratch[5].i = scratch[0].i + S_MUL(scratch[7].i,ya.r) + S_MUL(scratch[8].i,yb.r);
|
||||
|
||||
scratch[6].r = S_MUL(scratch[10].i,ya.i) + S_MUL(scratch[9].i,yb.i);
|
||||
scratch[6].i = -S_MUL(scratch[10].r,ya.i) - S_MUL(scratch[9].r,yb.i);
|
||||
|
||||
C_SUB(*Fout1,scratch[5],scratch[6]);
|
||||
C_ADD(*Fout4,scratch[5],scratch[6]);
|
||||
|
||||
scratch[11].r = scratch[0].r + S_MUL(scratch[7].r,yb.r) + S_MUL(scratch[8].r,ya.r);
|
||||
scratch[11].i = scratch[0].i + S_MUL(scratch[7].i,yb.r) + S_MUL(scratch[8].i,ya.r);
|
||||
scratch[12].r = - S_MUL(scratch[10].i,yb.i) + S_MUL(scratch[9].i,ya.i);
|
||||
scratch[12].i = S_MUL(scratch[10].r,yb.i) - S_MUL(scratch[9].r,ya.i);
|
||||
|
||||
C_ADD(*Fout2,scratch[11],scratch[12]);
|
||||
C_SUB(*Fout3,scratch[11],scratch[12]);
|
||||
|
||||
++Fout0;++Fout1;++Fout2;++Fout3;++Fout4;
|
||||
}
|
||||
}
|
||||
|
||||
/* perform the butterfly for one stage of a mixed radix FFT */
|
||||
static void kf_bfly_generic(
|
||||
kiss_fft_cpx * Fout,
|
||||
const size_t fstride,
|
||||
const kiss_fft_cfg st,
|
||||
int m,
|
||||
int p
|
||||
)
|
||||
{
|
||||
int u,k,q1,q;
|
||||
kiss_fft_cpx * twiddles = st->twiddles;
|
||||
kiss_fft_cpx t;
|
||||
int Norig = st->nfft;
|
||||
|
||||
kiss_fft_cpx * scratch = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC(sizeof(kiss_fft_cpx)*p);
|
||||
|
||||
for ( u=0; u<m; ++u ) {
|
||||
k=u;
|
||||
for ( q1=0 ; q1<p ; ++q1 ) {
|
||||
scratch[q1] = Fout[ k ];
|
||||
C_FIXDIV(scratch[q1],p);
|
||||
k += m;
|
||||
}
|
||||
|
||||
k=u;
|
||||
for ( q1=0 ; q1<p ; ++q1 ) {
|
||||
int twidx=0;
|
||||
Fout[ k ] = scratch[0];
|
||||
for (q=1;q<p;++q ) {
|
||||
twidx += fstride * k;
|
||||
if (twidx>=Norig) twidx-=Norig;
|
||||
C_MUL(t,scratch[q] , twiddles[twidx] );
|
||||
C_ADDTO( Fout[ k ] ,t);
|
||||
}
|
||||
k += m;
|
||||
}
|
||||
}
|
||||
KISS_FFT_TMP_FREE(scratch);
|
||||
}
|
||||
|
||||
static
|
||||
void kf_work(
|
||||
kiss_fft_cpx * Fout,
|
||||
const kiss_fft_cpx * f,
|
||||
const size_t fstride,
|
||||
int in_stride,
|
||||
int * factors,
|
||||
const kiss_fft_cfg st
|
||||
)
|
||||
{
|
||||
kiss_fft_cpx * Fout_beg=Fout;
|
||||
const int p=*factors++; /* the radix */
|
||||
const int m=*factors++; /* stage's fft length/p */
|
||||
const kiss_fft_cpx * Fout_end = Fout + p*m;
|
||||
|
||||
#ifdef _OPENMP
|
||||
// use openmp extensions at the
|
||||
// top-level (not recursive)
|
||||
if (fstride==1 && p<=5)
|
||||
{
|
||||
int k;
|
||||
|
||||
// execute the p different work units in different threads
|
||||
# pragma omp parallel for
|
||||
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 4: kf_bfly4(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;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m==1) {
|
||||
do{
|
||||
*Fout = *f;
|
||||
f += fstride*in_stride;
|
||||
}while(++Fout != Fout_end );
|
||||
}else{
|
||||
do{
|
||||
// recursive call:
|
||||
// DFT of size m*p performed by doing
|
||||
// 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;
|
||||
}while( (Fout += m) != Fout_end );
|
||||
}
|
||||
|
||||
Fout=Fout_beg;
|
||||
|
||||
// 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 4: kf_bfly4(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
|
||||
p[i] * m[i] = m[i-1]
|
||||
m0 = n */
|
||||
static
|
||||
void kf_factor(int n,int * facbuf)
|
||||
{
|
||||
int p=4;
|
||||
double floor_sqrt;
|
||||
floor_sqrt = floor( sqrt((double)n) );
|
||||
|
||||
/*factor out powers of 4, powers of 2, then any remaining primes */
|
||||
do {
|
||||
while (n % p) {
|
||||
switch (p) {
|
||||
case 4: p = 2; break;
|
||||
case 2: p = 3; break;
|
||||
default: p += 2; break;
|
||||
}
|
||||
if (p > floor_sqrt)
|
||||
p = n; /* no more factors, skip to end */
|
||||
}
|
||||
n /= p;
|
||||
*facbuf++ = p;
|
||||
*facbuf++ = n;
|
||||
} while (n > 1);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* User-callable function to allocate all necessary storage space for the fft.
|
||||
*
|
||||
* The return value is a contiguous block of memory, allocated with malloc. As such,
|
||||
* It can be freed with free(), rather than a kiss_fft-specific function.
|
||||
* */
|
||||
kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem )
|
||||
{
|
||||
kiss_fft_cfg st=NULL;
|
||||
size_t memneeded = sizeof(struct kiss_fft_state)
|
||||
+ sizeof(kiss_fft_cpx)*(nfft-1); /* twiddle factors*/
|
||||
|
||||
if ( lenmem==NULL ) {
|
||||
st = ( kiss_fft_cfg)KISS_FFT_MALLOC( memneeded );
|
||||
}else{
|
||||
if (mem != NULL && *lenmem >= memneeded)
|
||||
st = (kiss_fft_cfg)mem;
|
||||
*lenmem = memneeded;
|
||||
}
|
||||
if (st) {
|
||||
int i;
|
||||
st->nfft=nfft;
|
||||
st->inverse = inverse_fft;
|
||||
|
||||
for (i=0;i<nfft;++i) {
|
||||
const double pi=3.141592653589793238462643383279502884197169399375105820974944;
|
||||
double phase = -2*pi*i / nfft;
|
||||
if (st->inverse)
|
||||
phase *= -1;
|
||||
kf_cexp(st->twiddles+i, phase );
|
||||
}
|
||||
|
||||
kf_factor(nfft,st->factors);
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
|
||||
void kiss_fft_stride(kiss_fft_cfg st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int in_stride)
|
||||
{
|
||||
if (fin == fout) {
|
||||
//NOTE: this is not really an in-place FFT algorithm.
|
||||
//It just performs an out-of-place FFT into a temp buffer
|
||||
kiss_fft_cpx * tmpbuf = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC( sizeof(kiss_fft_cpx)*st->nfft);
|
||||
kf_work(tmpbuf,fin,1,in_stride, st->factors,st);
|
||||
memcpy(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft);
|
||||
KISS_FFT_TMP_FREE(tmpbuf);
|
||||
}else{
|
||||
kf_work( fout, fin, 1,in_stride, st->factors,st );
|
||||
}
|
||||
}
|
||||
|
||||
void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout)
|
||||
{
|
||||
kiss_fft_stride(cfg,fin,fout,1);
|
||||
}
|
||||
|
||||
|
||||
void kiss_fft_cleanup(void)
|
||||
{
|
||||
// nothing needed any more
|
||||
}
|
||||
|
||||
int kiss_fft_next_fast_size(int n)
|
||||
{
|
||||
while(1) {
|
||||
int m=n;
|
||||
while ( (m%2) == 0 ) m/=2;
|
||||
while ( (m%3) == 0 ) m/=3;
|
||||
while ( (m%5) == 0 ) m/=5;
|
||||
if (m<=1)
|
||||
break; /* n is completely factorable by twos, threes, and fives */
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
#ifndef KISS_FFT_H
|
||||
#define KISS_FFT_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
ATTENTION!
|
||||
If you would like a :
|
||||
-- a utility that will handle the caching of fft objects
|
||||
-- real-only (no imaginary time component ) FFT
|
||||
-- a multi-dimensional FFT
|
||||
-- a command-line utility to perform ffts
|
||||
-- a command-line utility to perform fast-convolution filtering
|
||||
|
||||
Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c
|
||||
in the tools/ directory.
|
||||
*/
|
||||
|
||||
#ifdef USE_SIMD
|
||||
# include <xmmintrin.h>
|
||||
# define kiss_fft_scalar __m128
|
||||
#define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16)
|
||||
#define KISS_FFT_FREE _mm_free
|
||||
#else
|
||||
#define KISS_FFT_MALLOC malloc
|
||||
#define KISS_FFT_FREE free
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
#include <sys/types.h>
|
||||
# if (FIXED_POINT == 32)
|
||||
# define kiss_fft_scalar int32_t
|
||||
# else
|
||||
# define kiss_fft_scalar int16_t
|
||||
# endif
|
||||
#else
|
||||
# ifndef kiss_fft_scalar
|
||||
/* default is float */
|
||||
# define kiss_fft_scalar float
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
kiss_fft_scalar r;
|
||||
kiss_fft_scalar i;
|
||||
}kiss_fft_cpx;
|
||||
|
||||
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);
|
||||
*
|
||||
* The return value from fft_alloc is a cfg buffer used internally
|
||||
* by the fft routine or NULL.
|
||||
*
|
||||
* 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
|
||||
* buffer size in *lenmem.
|
||||
* */
|
||||
|
||||
kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem);
|
||||
|
||||
/*
|
||||
* kiss_fft(cfg,in_out_buf)
|
||||
*
|
||||
* Perform an FFT on a complex input buffer.
|
||||
* for a forward FFT,
|
||||
* fin should be f[0] , f[1] , ... ,f[nfft-1]
|
||||
* fout will be F[0] , F[1] , ... ,F[nfft-1]
|
||||
* Note that each element is complex and can be accessed like
|
||||
f[k].r and f[k].i
|
||||
* */
|
||||
void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
|
||||
|
||||
/*
|
||||
A more generic version of the above function. It reads its input from every Nth sample.
|
||||
* */
|
||||
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
|
||||
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
|
||||
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)
|
||||
*/
|
||||
int kiss_fft_next_fast_size(int n);
|
||||
|
||||
/* for real ffts, we need an even size */
|
||||
#define kiss_fftr_next_fast_size_real(n) \
|
||||
(kiss_fft_next_fast_size( ((n)+1)>>1)<<1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,306 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: lpc.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 30 Sep 1990 (!)
|
||||
|
||||
Linear Prediction functions written in C.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009-2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#define LPC_MAX_N 512 /* maximum no. of samples in frame */
|
||||
#define PI 3.141592654 /* mathematical constant */
|
||||
|
||||
#define ALPHA 1.0
|
||||
#define BETA 0.94
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include "defines.h"
|
||||
#include "lpc.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
pre_emp()
|
||||
|
||||
Pre-emphasise (high pass filter with zero close to 0 Hz) a frame of
|
||||
speech samples. Helps reduce dynamic range of LPC spectrum, giving
|
||||
greater weight and hensea better match to low energy formants.
|
||||
|
||||
Should be balanced by de-emphasis of the output speech.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void pre_emp(
|
||||
float Sn_pre[], /* output frame of speech samples */
|
||||
float Sn[], /* input frame of speech samples */
|
||||
float *mem, /* Sn[-1]single sample memory */
|
||||
int Nsam /* number of speech samples to use */
|
||||
)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<Nsam; i++) {
|
||||
Sn_pre[i] = Sn[i] - ALPHA * mem[0];
|
||||
mem[0] = Sn[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
de_emp()
|
||||
|
||||
De-emphasis filter (low pass filter with polse close to 0 Hz).
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void de_emp(
|
||||
float Sn_de[], /* output frame of speech samples */
|
||||
float Sn[], /* input frame of speech samples */
|
||||
float *mem, /* Sn[-1]single sample memory */
|
||||
int Nsam /* number of speech samples to use */
|
||||
)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<Nsam; i++) {
|
||||
Sn_de[i] = Sn[i] + BETA * mem[0];
|
||||
mem[0] = Sn_de[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
hanning_window()
|
||||
|
||||
Hanning windows a frame of speech samples.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void hanning_window(
|
||||
float Sn[], /* input frame of speech samples */
|
||||
float Wn[], /* output frame of windowed samples */
|
||||
int Nsam /* number of samples */
|
||||
)
|
||||
{
|
||||
int i; /* loop variable */
|
||||
|
||||
for(i=0; i<Nsam; i++)
|
||||
Wn[i] = Sn[i]*(0.5 - 0.5*cosf(2*PI*(float)i/(Nsam-1)));
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
autocorrelate()
|
||||
|
||||
Finds the first P autocorrelation values of an array of windowed speech
|
||||
samples Sn[].
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void autocorrelate(
|
||||
float Sn[], /* frame of Nsam windowed speech samples */
|
||||
float Rn[], /* array of P+1 autocorrelation coefficients */
|
||||
int Nsam, /* number of windowed samples to use */
|
||||
int order /* order of LPC analysis */
|
||||
)
|
||||
{
|
||||
int i,j; /* loop variables */
|
||||
|
||||
for(j=0; j<order+1; j++) {
|
||||
Rn[j] = 0.0;
|
||||
for(i=0; i<Nsam-j; i++)
|
||||
Rn[j] += Sn[i]*Sn[i+j];
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
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
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void levinson_durbin(
|
||||
float R[], /* order+1 autocorrelation coeff */
|
||||
float lpcs[], /* order+1 LPC's */
|
||||
int order /* order of the LPC analysis */
|
||||
)
|
||||
{
|
||||
float a[order+1][order+1];
|
||||
float sum, e, k;
|
||||
int i,j; /* loop variables */
|
||||
|
||||
e = R[0]; /* Equation 38a, Makhoul */
|
||||
|
||||
for(i=1; i<=order; i++) {
|
||||
sum = 0.0;
|
||||
for(j=1; j<=i-1; j++)
|
||||
sum += a[i-1][j]*R[i-j];
|
||||
k = -1.0*(R[i] + sum)/e; /* Equation 38b, Makhoul */
|
||||
if (fabsf(k) > 1.0)
|
||||
k = 0.0;
|
||||
|
||||
a[i][i] = k;
|
||||
|
||||
for(j=1; j<=i-1; j++)
|
||||
a[i][j] = a[i-1][j] + k*a[i-1][i-j]; /* Equation 38c, Makhoul */
|
||||
|
||||
e *= (1-k*k); /* Equation 38d, Makhoul */
|
||||
}
|
||||
|
||||
for(i=1; i<=order; i++)
|
||||
lpcs[i] = a[order][i];
|
||||
lpcs[0] = 1.0;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
inverse_filter()
|
||||
|
||||
Inverse Filter, A(z). Produces an array of residual samples from an array
|
||||
of input samples and linear prediction coefficients.
|
||||
|
||||
The filter memory is stored in the first order samples of the input array.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void inverse_filter(
|
||||
float Sn[], /* Nsam input samples */
|
||||
float a[], /* LPCs for this frame of samples */
|
||||
int Nsam, /* number of samples */
|
||||
float res[], /* Nsam residual samples */
|
||||
int order /* order of LPC */
|
||||
)
|
||||
{
|
||||
int i,j; /* loop variables */
|
||||
|
||||
for(i=0; i<Nsam; i++) {
|
||||
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
|
||||
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
|
||||
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.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void synthesis_filter(
|
||||
float res[], /* Nsam input residual (excitation) samples */
|
||||
float a[], /* LPCs for this frame of speech samples */
|
||||
int Nsam, /* number of speech samples */
|
||||
int order, /* LPC order */
|
||||
float Sn_[] /* Nsam output synthesised speech samples */
|
||||
)
|
||||
{
|
||||
int i,j; /* loop variables */
|
||||
|
||||
/* Filter Nsam samples */
|
||||
|
||||
for(i=0; i<Nsam; i++) {
|
||||
Sn_[i] = res[i]*a[0];
|
||||
for(j=1; j<=order; j++)
|
||||
Sn_[i] -= Sn_[i-j]*a[j];
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
find_aks()
|
||||
|
||||
This function takes a frame of samples, and determines the linear
|
||||
prediction coefficients for that frame of samples.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void find_aks(
|
||||
float Sn[], /* Nsam samples with order sample memory */
|
||||
float a[], /* order+1 LPCs with first coeff 1.0 */
|
||||
int Nsam, /* number of input speech samples */
|
||||
int order, /* order of the LPC analysis */
|
||||
float *E /* residual energy */
|
||||
)
|
||||
{
|
||||
float Wn[LPC_MAX_N]; /* windowed frame of Nsam speech samples */
|
||||
float R[order+1]; /* order+1 autocorrelation values of Sn[] */
|
||||
int i;
|
||||
|
||||
assert(Nsam < LPC_MAX_N);
|
||||
|
||||
hanning_window(Sn,Wn,Nsam);
|
||||
autocorrelate(Wn,R,Nsam,order);
|
||||
levinson_durbin(R,a,order);
|
||||
|
||||
*E = 0.0;
|
||||
for(i=0; i<=order; i++)
|
||||
*E += a[i]*R[i];
|
||||
if (*E < 0.0)
|
||||
*E = 1E-12;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
weight()
|
||||
|
||||
Weights a vector of LPCs.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void weight(
|
||||
float ak[], /* vector of order+1 LPCs */
|
||||
float gamma, /* weighting factor */
|
||||
int order, /* num LPCs (excluding leading 1.0) */
|
||||
float akw[] /* weighted vector of order+1 LPCs */
|
||||
)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=1; i<=order; i++)
|
||||
akw[i] = ak[i]*powf(gamma,(float)i);
|
||||
}
|
||||
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: lpc.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/8/09
|
||||
|
||||
Linear Prediction functions written in C.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009-2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __LPC__
|
||||
#define __LPC__
|
||||
|
||||
#define LPC_MAX_ORDER 20
|
||||
|
||||
void pre_emp(float Sn_pre[], float Sn[], float *mem, int Nsam);
|
||||
void de_emp(float Sn_se[], float Sn[], float *mem, int Nsam);
|
||||
void hanning_window(float Sn[], float Wn[], int Nsam);
|
||||
void autocorrelate(float Sn[], float Rn[], int Nsam, int order);
|
||||
void levinson_durbin(float R[], float lpcs[], int order);
|
||||
void inverse_filter(float Sn[], float a[], int Nsam, float res[], int order);
|
||||
void synthesis_filter(float res[], float a[], int Nsam, int order, float Sn_[]);
|
||||
void find_aks(float Sn[], float a[], int Nsam, int order, float *E);
|
||||
void weight(float ak[], float gamma, int order, float akw[]);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,321 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: lsp.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
|
||||
This file contains functions for LPC to LSP conversion and LSP to
|
||||
LPC conversion. Note that the LSP coefficients are not in radians
|
||||
format but in the x domain of the unit circle.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
#include "lsp.h"
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
Introduction to Line Spectrum Pairs (LSPs)
|
||||
------------------------------------------
|
||||
|
||||
LSPs are used to encode the LPC filter coefficients {ak} for
|
||||
transmission over the channel. LSPs have several properties (like
|
||||
less sensitivity to quantisation noise) that make them superior to
|
||||
direct quantisation of {ak}.
|
||||
|
||||
A(z) is a polynomial of order lpcrdr with {ak} as the coefficients.
|
||||
|
||||
A(z) is transformed to P(z) and Q(z) (using a substitution and some
|
||||
algebra), to obtain something like:
|
||||
|
||||
A(z) = 0.5[P(z)(z+z^-1) + Q(z)(z-z^-1)] (1)
|
||||
|
||||
As you can imagine A(z) has complex zeros all over the z-plane. P(z)
|
||||
and Q(z) have the very neat property of only having zeros _on_ the
|
||||
unit circle. So to find them we take a test point z=exp(jw) and
|
||||
evaluate P (exp(jw)) and Q(exp(jw)) using a grid of points between 0
|
||||
and pi.
|
||||
|
||||
The zeros (roots) of P(z) also happen to alternate, which is why we
|
||||
swap coefficients as we find roots. So the process of finding the
|
||||
LSP frequencies is basically finding the roots of 5th order
|
||||
polynomials.
|
||||
|
||||
The root so P(z) and Q(z) occur in symmetrical pairs at +/-w, hence
|
||||
the name Line Spectrum Pairs (LSPs).
|
||||
|
||||
To convert back to ak we just evaluate (1), "clocking" an impulse
|
||||
thru it lpcrdr times gives us the impulse response of A(z) which is
|
||||
{ak}.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: cheb_poly_eva()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
This function evalutes a series of chebyshev polynomials
|
||||
|
||||
FIXME: performing memory allocation at run time is very inefficient,
|
||||
replace with stack variables of MAX_P size.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
static float
|
||||
cheb_poly_eva(float *coef,float x,int order)
|
||||
/* float coef[] coefficients of the polynomial to be evaluated */
|
||||
/* float x the point where polynomial is to be evaluated */
|
||||
/* int order order of the polynomial */
|
||||
{
|
||||
int i;
|
||||
float *t,*u,*v,sum;
|
||||
float T[(order / 2) + 1];
|
||||
|
||||
/* Initialize pointers */
|
||||
|
||||
t = T; /* T[i-2] */
|
||||
*t++ = 1.0;
|
||||
u = t--; /* T[i-1] */
|
||||
*u++ = x;
|
||||
v = u--; /* T[i] */
|
||||
|
||||
/* Evaluate chebyshev series formulation using iterative approach */
|
||||
|
||||
for(i=2;i<=order/2;i++)
|
||||
*v++ = (2*x)*(*u++) - *t++; /* T[i] = 2*x*T[i-1] - T[i-2] */
|
||||
|
||||
sum=0.0; /* initialise sum to zero */
|
||||
t = T; /* reset pointer */
|
||||
|
||||
/* Evaluate polynomial and return value also free memory space */
|
||||
|
||||
for(i=0;i<=order/2;i++)
|
||||
sum+=coef[(order/2)-i]**t++;
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: lpc_to_lsp()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
This function converts LPC coefficients to LSP coefficients.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
int lpc_to_lsp (float *a, int order, float *freq, int nb, float delta)
|
||||
/* float *a lpc coefficients */
|
||||
/* int order order of LPC coefficients (10) */
|
||||
/* float *freq LSP frequencies in radians */
|
||||
/* int nb number of sub-intervals (4) */
|
||||
/* float delta grid spacing interval (0.02) */
|
||||
{
|
||||
float psuml,psumr,psumm,temp_xr,xl,xr,xm = 0;
|
||||
float temp_psumr;
|
||||
int i,j,m,flag,k;
|
||||
float *px; /* ptrs of respective P'(z) & Q'(z) */
|
||||
float *qx;
|
||||
float *p;
|
||||
float *q;
|
||||
float *pt; /* ptr used for cheb_poly_eval()
|
||||
whether P' or Q' */
|
||||
int roots=0; /* number of roots found */
|
||||
float Q[order + 1];
|
||||
float P[order + 1];
|
||||
|
||||
flag = 1;
|
||||
m = order/2; /* order of P'(z) & Q'(z) polynimials */
|
||||
|
||||
/* Allocate memory space for polynomials */
|
||||
|
||||
/* determine P'(z)'s and Q'(z)'s coefficients where
|
||||
P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */
|
||||
|
||||
px = P; /* initilaise ptrs */
|
||||
qx = Q;
|
||||
p = px;
|
||||
q = qx;
|
||||
*px++ = 1.0;
|
||||
*qx++ = 1.0;
|
||||
for(i=1;i<=m;i++){
|
||||
*px++ = a[i]+a[order+1-i]-*p++;
|
||||
*qx++ = a[i]-a[order+1-i]+*q++;
|
||||
}
|
||||
px = P;
|
||||
qx = Q;
|
||||
for(i=0;i<m;i++){
|
||||
*px = 2**px;
|
||||
*qx = 2**qx;
|
||||
px++;
|
||||
qx++;
|
||||
}
|
||||
px = P; /* re-initialise ptrs */
|
||||
qx = Q;
|
||||
|
||||
/* Search for a zero in P'(z) polynomial first and then alternate to Q'(z).
|
||||
Keep alternating between the two polynomials as each zero is found */
|
||||
|
||||
xr = 0; /* initialise xr to zero */
|
||||
xl = 1.0; /* start at point xl = 1 */
|
||||
|
||||
|
||||
for(j=0;j<order;j++){
|
||||
if(j%2) /* determines whether P' or Q' is eval. */
|
||||
pt = qx;
|
||||
else
|
||||
pt = px;
|
||||
|
||||
psuml = cheb_poly_eva(pt,xl,order); /* evals poly. at xl */
|
||||
flag = 1;
|
||||
while(flag && (xr >= -1.0)){
|
||||
xr = xl - delta ; /* interval spacing */
|
||||
psumr = cheb_poly_eva(pt,xr,order);/* poly(xl-delta_x) */
|
||||
temp_psumr = psumr;
|
||||
temp_xr = xr;
|
||||
|
||||
/* if no sign change increment xr and re-evaluate
|
||||
poly(xr). Repeat til sign change. if a sign change has
|
||||
occurred the interval is bisected and then checked again
|
||||
for a sign change which determines in which interval the
|
||||
zero lies in. If there is no sign change between poly(xm)
|
||||
and poly(xl) set interval between xm and xr else set
|
||||
interval between xl and xr and repeat till root is located
|
||||
within the specified limits */
|
||||
|
||||
if(((psumr*psuml)<0.0) || (psumr == 0.0)){
|
||||
roots++;
|
||||
|
||||
psumm=psuml;
|
||||
for(k=0;k<=nb;k++){
|
||||
xm = (xl+xr)/2; /* bisect the interval */
|
||||
psumm=cheb_poly_eva(pt,xm,order);
|
||||
if(psumm*psuml>0.){
|
||||
psuml=psumm;
|
||||
xl=xm;
|
||||
}
|
||||
else{
|
||||
psumr=psumm;
|
||||
xr=xm;
|
||||
}
|
||||
}
|
||||
|
||||
/* once zero is found, reset initial interval to xr */
|
||||
freq[j] = (xm);
|
||||
xl = xm;
|
||||
flag = 0; /* reset flag for next search */
|
||||
}
|
||||
else{
|
||||
psuml=temp_psumr;
|
||||
xl=temp_xr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* convert from x domain to radians */
|
||||
|
||||
for(i=0; i<order; i++) {
|
||||
freq[i] = acos(freq[i]);
|
||||
}
|
||||
|
||||
return(roots);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: lsp_to_lpc()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
This function converts LSP coefficients to LPC coefficients. In the
|
||||
Speex code we worked out a way to simplify this significantly.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void lsp_to_lpc(float *lsp, float *ak, int order)
|
||||
/* float *freq array of LSP frequencies in radians */
|
||||
/* float *ak array of LPC coefficients */
|
||||
/* int order order of LPC coefficients */
|
||||
|
||||
|
||||
{
|
||||
int i,j;
|
||||
float xout1,xout2,xin1,xin2;
|
||||
float *pw,*n1,*n2,*n3,*n4 = 0;
|
||||
float freq[order];
|
||||
float Wp[(order * 4) + 2];
|
||||
|
||||
/* convert from radians to the x=cos(w) domain */
|
||||
|
||||
for(i=0; i<order; i++)
|
||||
freq[i] = cos(lsp[i]);
|
||||
|
||||
pw = Wp;
|
||||
|
||||
/* initialise contents of array */
|
||||
|
||||
for(i=0;i<=4*(order/2)+1;i++){ /* set contents of buffer to 0 */
|
||||
*pw++ = 0.0;
|
||||
}
|
||||
|
||||
/* Set pointers up */
|
||||
|
||||
pw = Wp;
|
||||
xin1 = 1.0;
|
||||
xin2 = 1.0;
|
||||
|
||||
/* reconstruct P(z) and Q(z) by cascading second order polynomials
|
||||
in form 1 - 2xz(-1) +z(-2), where x is the LSP coefficient */
|
||||
|
||||
for(j=0;j<=order;j++){
|
||||
for(i=0;i<(order/2);i++){
|
||||
n1 = pw+(i*4);
|
||||
n2 = n1 + 1;
|
||||
n3 = n2 + 1;
|
||||
n4 = n3 + 1;
|
||||
xout1 = xin1 - 2*(freq[2*i]) * *n1 + *n2;
|
||||
xout2 = xin2 - 2*(freq[2*i+1]) * *n3 + *n4;
|
||||
*n2 = *n1;
|
||||
*n4 = *n3;
|
||||
*n1 = xin1;
|
||||
*n3 = xin2;
|
||||
xin1 = xout1;
|
||||
xin2 = xout2;
|
||||
}
|
||||
xout1 = xin1 + *(n4+1);
|
||||
xout2 = xin2 - *(n4+2);
|
||||
ak[j] = (xout1 + xout2)*0.5;
|
||||
*(n4+1) = xin1;
|
||||
*(n4+2) = xin2;
|
||||
|
||||
xin1 = 0.0;
|
||||
xin2 = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: lsp.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
|
||||
This file contains functions for LPC to LSP conversion and LSP to
|
||||
LPC conversion. Note that the LSP coefficients are not in radians
|
||||
format but in the x domain of the unit circle.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __LSP__
|
||||
#define __LSP__
|
||||
|
||||
int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta);
|
||||
void lsp_to_lpc(float *freq, float *ak, int lpcrdr);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: machdep.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: May 2 2013
|
||||
|
||||
Machine dependant functions, e.g. profiling that requires access to a clock
|
||||
counter register.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2013 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MACHDEP__
|
||||
#define __MACHDEP__
|
||||
|
||||
#ifdef PROFILE
|
||||
#define PROFILE_VAR(...) unsigned int __VA_ARGS__
|
||||
#define PROFILE_SAMPLE(timestamp) timestamp = machdep_profile_sample()
|
||||
#define PROFILE_SAMPLE_AND_LOG(timestamp, prev_timestamp, label) \
|
||||
timestamp = machdep_profile_sample_and_log(prev_timestamp, label)
|
||||
#define PROFILE_SAMPLE_AND_LOG2(prev_timestamp, label) \
|
||||
machdep_profile_sample_and_log(prev_timestamp, label)
|
||||
#else
|
||||
#define PROFILE_VAR(...)
|
||||
#define PROFILE_SAMPLE(timestamp)
|
||||
#define PROFILE_SAMPLE_AND_LOG(timestamp, prev_timestamp, label)
|
||||
#define PROFILE_SAMPLE_AND_LOG2(prev_timestamp, label)
|
||||
#endif
|
||||
|
||||
void machdep_profile_init(void);
|
||||
void machdep_profile_reset(void);
|
||||
unsigned int machdep_profile_sample(void);
|
||||
unsigned int machdep_profile_sample_and_log(unsigned int start, char s[]);
|
||||
void machdep_profile_print_logged_samples(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,589 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: nlp.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 23/3/93
|
||||
|
||||
Non Linear Pitch (NLP) estimation functions.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
#include "nlp.h"
|
||||
#include "dump.h"
|
||||
#include "kiss_fft.h"
|
||||
#undef PROFILE
|
||||
#include "machdep.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
DEFINES
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#define PMAX_M 600 /* maximum NLP analysis window size */
|
||||
#define COEFF 0.95 /* notch filter parameter */
|
||||
#define PE_FFT_SIZE 512 /* DFT size for pitch estimation */
|
||||
#define DEC 5 /* decimation factor */
|
||||
#define SAMPLE_RATE 8000
|
||||
#define PI 3.141592654 /* mathematical constant */
|
||||
#define T 0.1 /* threshold for local minima candidate */
|
||||
#define F0_MAX 500
|
||||
#define CNLP 0.3 /* post processor constant */
|
||||
#define NLP_NTAP 48 /* Decimation LPF order */
|
||||
|
||||
//#undef DUMP
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
GLOBALS
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/* 48 tap 600Hz low pass FIR filter coefficients */
|
||||
|
||||
const float nlp_fir[] = {
|
||||
-1.0818124e-03,
|
||||
-1.1008344e-03,
|
||||
-9.2768838e-04,
|
||||
-4.2289438e-04,
|
||||
5.5034190e-04,
|
||||
2.0029849e-03,
|
||||
3.7058509e-03,
|
||||
5.1449415e-03,
|
||||
5.5924666e-03,
|
||||
4.3036754e-03,
|
||||
8.0284511e-04,
|
||||
-4.8204610e-03,
|
||||
-1.1705810e-02,
|
||||
-1.8199275e-02,
|
||||
-2.2065282e-02,
|
||||
-2.0920610e-02,
|
||||
-1.2808831e-02,
|
||||
3.2204775e-03,
|
||||
2.6683811e-02,
|
||||
5.5520624e-02,
|
||||
8.6305944e-02,
|
||||
1.1480192e-01,
|
||||
1.3674206e-01,
|
||||
1.4867556e-01,
|
||||
1.4867556e-01,
|
||||
1.3674206e-01,
|
||||
1.1480192e-01,
|
||||
8.6305944e-02,
|
||||
5.5520624e-02,
|
||||
2.6683811e-02,
|
||||
3.2204775e-03,
|
||||
-1.2808831e-02,
|
||||
-2.0920610e-02,
|
||||
-2.2065282e-02,
|
||||
-1.8199275e-02,
|
||||
-1.1705810e-02,
|
||||
-4.8204610e-03,
|
||||
8.0284511e-04,
|
||||
4.3036754e-03,
|
||||
5.5924666e-03,
|
||||
5.1449415e-03,
|
||||
3.7058509e-03,
|
||||
2.0029849e-03,
|
||||
5.5034190e-04,
|
||||
-4.2289438e-04,
|
||||
-9.2768838e-04,
|
||||
-1.1008344e-03,
|
||||
-1.0818124e-03
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int m;
|
||||
float w[PMAX_M/DEC]; /* DFT window */
|
||||
float sq[PMAX_M]; /* squared speech samples */
|
||||
float mem_x,mem_y; /* memory for notch filter */
|
||||
float mem_fir[NLP_NTAP]; /* decimation FIR filter memory */
|
||||
kiss_fft_cfg fft_cfg; /* kiss FFT config */
|
||||
} NLP;
|
||||
|
||||
float test_candidate_mbe(COMP Sw[], COMP W[], float f0);
|
||||
float post_process_mbe(COMP Fw[], int pmin, int pmax, float gmax, COMP Sw[], COMP W[], float *prev_Wo);
|
||||
float post_process_sub_multiples(COMP Fw[],
|
||||
int pmin, int pmax, float gmax, int gmax_bin,
|
||||
float *prev_Wo);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
nlp_create()
|
||||
|
||||
Initialisation function for NLP pitch estimator.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void *nlp_create(
|
||||
int m /* analysis window size */
|
||||
)
|
||||
{
|
||||
NLP *nlp;
|
||||
int i;
|
||||
|
||||
assert(m <= PMAX_M);
|
||||
|
||||
nlp = (NLP*)malloc(sizeof(NLP));
|
||||
if (nlp == NULL)
|
||||
return NULL;
|
||||
|
||||
nlp->m = m;
|
||||
for(i=0; i<m/DEC; i++) {
|
||||
nlp->w[i] = 0.5 - 0.5*cosf(2*PI*i/(m/DEC-1));
|
||||
}
|
||||
|
||||
for(i=0; i<PMAX_M; i++)
|
||||
nlp->sq[i] = 0.0;
|
||||
nlp->mem_x = 0.0;
|
||||
nlp->mem_y = 0.0;
|
||||
for(i=0; i<NLP_NTAP; i++)
|
||||
nlp->mem_fir[i] = 0.0;
|
||||
|
||||
nlp->fft_cfg = kiss_fft_alloc (PE_FFT_SIZE, 0, NULL, NULL);
|
||||
assert(nlp->fft_cfg != NULL);
|
||||
|
||||
return (void*)nlp;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
nlp_destroy()
|
||||
|
||||
Shut down function for NLP pitch estimator.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void nlp_destroy(void *nlp_state)
|
||||
{
|
||||
NLP *nlp;
|
||||
assert(nlp_state != NULL);
|
||||
nlp = (NLP*)nlp_state;
|
||||
|
||||
KISS_FFT_FREE(nlp->fft_cfg);
|
||||
free(nlp_state);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
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
|
||||
the current N sample input vector. This is (I think) a delay of 2.5
|
||||
frames with N=80 samples. You should align further analysis using
|
||||
this pitch estimate to be centred on the middle of Sn[].
|
||||
|
||||
Two post processors have been tried, the MBE version (as discussed
|
||||
in [1]), and a post processor that checks sub-multiples. Both
|
||||
suffer occasional gross pitch errors (i.e. neither are perfect). In
|
||||
the presence of background noise the sub-multiple algorithm tends
|
||||
towards low F0 which leads to better sounding background noise than
|
||||
the MBE post processor.
|
||||
|
||||
A good way to test and develop the NLP pitch estimator is using the
|
||||
tnlp (codec2/unittest) and the codec2/octave/plnlp.m Octave script.
|
||||
|
||||
A pitch tracker searching a few frames forward and backward in time
|
||||
would be a useful addition.
|
||||
|
||||
References:
|
||||
|
||||
[1] http://www.itr.unisa.edu.au/~steven/thesis/dgr.pdf Chapter 4
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
float nlp(
|
||||
void *nlp_state,
|
||||
float Sn[], /* input speech vector */
|
||||
int n, /* frames shift (no. new samples in Sn[]) */
|
||||
int pmin, /* minimum pitch value */
|
||||
int pmax, /* maximum pitch value */
|
||||
float *pitch, /* estimated pitch period in samples */
|
||||
COMP Sw[], /* Freq domain version of Sn[] */
|
||||
COMP W[], /* Freq domain window */
|
||||
float *prev_Wo
|
||||
)
|
||||
{
|
||||
NLP *nlp;
|
||||
float notch; /* current notch filter output */
|
||||
COMP fw[PE_FFT_SIZE]; /* DFT of squared signal (input) */
|
||||
COMP Fw[PE_FFT_SIZE]; /* DFT of squared signal (output) */
|
||||
float gmax;
|
||||
int gmax_bin;
|
||||
int m, i,j;
|
||||
float best_f0;
|
||||
PROFILE_VAR(start, tnotch, filter, peakpick, window, fft, magsq, shiftmem);
|
||||
|
||||
assert(nlp_state != NULL);
|
||||
nlp = (NLP*)nlp_state;
|
||||
m = nlp->m;
|
||||
|
||||
PROFILE_SAMPLE(start);
|
||||
|
||||
/* Square, notch filter at DC, and LP filter vector */
|
||||
|
||||
for(i=m-n; i<m; i++) /* square latest speech samples */
|
||||
nlp->sq[i] = Sn[i]*Sn[i];
|
||||
|
||||
for(i=m-n; i<m; i++) { /* notch filter at DC */
|
||||
notch = nlp->sq[i] - nlp->mem_x;
|
||||
notch += COEFF*nlp->mem_y;
|
||||
nlp->mem_x = nlp->sq[i];
|
||||
nlp->mem_y = notch;
|
||||
nlp->sq[i] = notch + 1.0; /* With 0 input vectors to codec,
|
||||
kiss_fft() would take a long
|
||||
time to execute when running in
|
||||
real time. Problem was traced
|
||||
to kiss_fft function call in
|
||||
this function. Adding this small
|
||||
constant fixed problem. Not
|
||||
exactly sure why. */
|
||||
}
|
||||
|
||||
PROFILE_SAMPLE_AND_LOG(tnotch, start, " square and notch");
|
||||
|
||||
for(i=m-n; i<m; i++) { /* FIR filter vector */
|
||||
|
||||
for(j=0; j<NLP_NTAP-1; j++)
|
||||
nlp->mem_fir[j] = nlp->mem_fir[j+1];
|
||||
nlp->mem_fir[NLP_NTAP-1] = nlp->sq[i];
|
||||
|
||||
nlp->sq[i] = 0.0;
|
||||
for(j=0; j<NLP_NTAP; j++)
|
||||
nlp->sq[i] += nlp->mem_fir[j]*nlp_fir[j];
|
||||
}
|
||||
|
||||
PROFILE_SAMPLE_AND_LOG(filter, tnotch, " filter");
|
||||
|
||||
/* Decimate and DFT */
|
||||
|
||||
for(i=0; i<PE_FFT_SIZE; i++) {
|
||||
fw[i].real = 0.0;
|
||||
fw[i].imag = 0.0;
|
||||
}
|
||||
for(i=0; i<m/DEC; i++) {
|
||||
fw[i].real = nlp->sq[i*DEC]*nlp->w[i];
|
||||
}
|
||||
PROFILE_SAMPLE_AND_LOG(window, filter, " window");
|
||||
#ifdef DUMP
|
||||
dump_dec(Fw);
|
||||
#endif
|
||||
|
||||
kiss_fft(nlp->fft_cfg, (kiss_fft_cpx *)fw, (kiss_fft_cpx *)Fw);
|
||||
PROFILE_SAMPLE_AND_LOG(fft, window, " fft");
|
||||
|
||||
for(i=0; i<PE_FFT_SIZE; i++)
|
||||
Fw[i].real = Fw[i].real*Fw[i].real + Fw[i].imag*Fw[i].imag;
|
||||
|
||||
PROFILE_SAMPLE_AND_LOG(magsq, fft, " mag sq");
|
||||
#ifdef DUMP
|
||||
dump_sq(nlp->sq);
|
||||
dump_Fw(Fw);
|
||||
#endif
|
||||
|
||||
/* find global peak */
|
||||
|
||||
gmax = 0.0;
|
||||
gmax_bin = PE_FFT_SIZE*DEC/pmax;
|
||||
for(i=PE_FFT_SIZE*DEC/pmax; i<=PE_FFT_SIZE*DEC/pmin; i++) {
|
||||
if (Fw[i].real > gmax) {
|
||||
gmax = Fw[i].real;
|
||||
gmax_bin = i;
|
||||
}
|
||||
}
|
||||
|
||||
PROFILE_SAMPLE_AND_LOG(peakpick, magsq, " peak pick");
|
||||
|
||||
//#define POST_PROCESS_MBE
|
||||
#ifdef POST_PROCESS_MBE
|
||||
best_f0 = post_process_mbe(Fw, pmin, pmax, gmax, Sw, W, prev_Wo);
|
||||
#else
|
||||
best_f0 = post_process_sub_multiples(Fw, pmin, pmax, gmax, gmax_bin, prev_Wo);
|
||||
#endif
|
||||
|
||||
PROFILE_SAMPLE_AND_LOG(shiftmem, peakpick, " post process");
|
||||
|
||||
/* Shift samples in buffer to make room for new samples */
|
||||
|
||||
for(i=0; i<m-n; i++)
|
||||
nlp->sq[i] = nlp->sq[i+n];
|
||||
|
||||
/* return pitch and F0 estimate */
|
||||
|
||||
*pitch = (float)SAMPLE_RATE/best_f0;
|
||||
|
||||
PROFILE_SAMPLE_AND_LOG2(shiftmem, " shift mem");
|
||||
|
||||
PROFILE_SAMPLE_AND_LOG2(start, " nlp int");
|
||||
|
||||
return(best_f0);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
post_process_sub_multiples()
|
||||
|
||||
Given the global maximma of Fw[] we search integer submultiples for
|
||||
local maxima. If local maxima exist and they are above an
|
||||
experimentally derived threshold (OK a magic number I pulled out of
|
||||
the air) we choose the submultiple as the F0 estimate.
|
||||
|
||||
The rational for this is that the lowest frequency peak of Fw[]
|
||||
should be F0, as Fw[] can be considered the autocorrelation function
|
||||
of Sw[] (the speech spectrum). However sometimes due to phase
|
||||
effects the lowest frequency maxima may not be the global maxima.
|
||||
|
||||
This works OK in practice and favours low F0 values in the presence
|
||||
of background noise which means the sinusoidal codec does an OK job
|
||||
of synthesising the background noise. High F0 in background noise
|
||||
tends to sound more periodic introducing annoying artifacts.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
float post_process_sub_multiples(COMP Fw[],
|
||||
int pmin, int pmax, float gmax, int gmax_bin,
|
||||
float *prev_Wo)
|
||||
{
|
||||
int min_bin, cmax_bin;
|
||||
int mult;
|
||||
float thresh, best_f0;
|
||||
int b, bmin, bmax, lmax_bin;
|
||||
float lmax;
|
||||
int prev_f0_bin;
|
||||
|
||||
/* post process estimate by searching submultiples */
|
||||
|
||||
mult = 2;
|
||||
min_bin = PE_FFT_SIZE*DEC/pmax;
|
||||
cmax_bin = gmax_bin;
|
||||
prev_f0_bin = *prev_Wo*(4000.0/PI)*(PE_FFT_SIZE*DEC)/SAMPLE_RATE;
|
||||
|
||||
while(gmax_bin/mult >= min_bin) {
|
||||
|
||||
b = gmax_bin/mult; /* determine search interval */
|
||||
bmin = 0.8*b;
|
||||
bmax = 1.2*b;
|
||||
if (bmin < min_bin)
|
||||
bmin = min_bin;
|
||||
|
||||
/* lower threshold to favour previous frames pitch estimate,
|
||||
this is a form of pitch tracking */
|
||||
|
||||
if ((prev_f0_bin > bmin) && (prev_f0_bin < bmax))
|
||||
thresh = CNLP*0.5*gmax;
|
||||
else
|
||||
thresh = CNLP*gmax;
|
||||
|
||||
lmax = 0;
|
||||
lmax_bin = bmin;
|
||||
for (b=bmin; b<=bmax; b++) /* look for maximum in interval */
|
||||
if (Fw[b].real > lmax) {
|
||||
lmax = Fw[b].real;
|
||||
lmax_bin = b;
|
||||
}
|
||||
|
||||
if (lmax > thresh)
|
||||
if ((lmax > Fw[lmax_bin-1].real) && (lmax > Fw[lmax_bin+1].real)) {
|
||||
cmax_bin = lmax_bin;
|
||||
}
|
||||
|
||||
mult++;
|
||||
}
|
||||
|
||||
best_f0 = (float)cmax_bin*SAMPLE_RATE/(PE_FFT_SIZE*DEC);
|
||||
|
||||
return best_f0;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
post_process_mbe()
|
||||
|
||||
Use the MBE pitch estimation algorithm to evaluate pitch candidates. This
|
||||
works OK but the accuracy at low F0 is affected by NW, the analysis window
|
||||
size used for the DFT of the input speech Sw[]. Also favours high F0 in
|
||||
the presence of background noise which causes periodic artifacts in the
|
||||
synthesised speech.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
float post_process_mbe(COMP Fw[], int pmin, int pmax, float gmax, COMP Sw[], COMP W[], float *prev_Wo)
|
||||
{
|
||||
float candidate_f0;
|
||||
float f0,best_f0; /* fundamental frequency */
|
||||
float e,e_min; /* MBE cost function */
|
||||
int i;
|
||||
#ifdef DUMP
|
||||
float e_hz[F0_MAX];
|
||||
#endif
|
||||
#if !defined(NDEBUG) || defined(DUMP)
|
||||
int bin;
|
||||
#endif
|
||||
float f0_min, f0_max;
|
||||
float f0_start, f0_end;
|
||||
|
||||
f0_min = (float)SAMPLE_RATE/pmax;
|
||||
f0_max = (float)SAMPLE_RATE/pmin;
|
||||
|
||||
/* Now look for local maxima. Each local maxima is a candidate
|
||||
that we test using the MBE pitch estimation algotithm */
|
||||
|
||||
#ifdef DUMP
|
||||
for(i=0; i<F0_MAX; i++)
|
||||
e_hz[i] = -1;
|
||||
#endif
|
||||
e_min = 1E32;
|
||||
best_f0 = 50;
|
||||
for(i=PE_FFT_SIZE*DEC/pmax; i<=PE_FFT_SIZE*DEC/pmin; i++) {
|
||||
if ((Fw[i].real > Fw[i-1].real) && (Fw[i].real > Fw[i+1].real)) {
|
||||
|
||||
/* local maxima found, lets test if it's big enough */
|
||||
|
||||
if (Fw[i].real > T*gmax) {
|
||||
|
||||
/* OK, sample MBE cost function over +/- 10Hz range in 2.5Hz steps */
|
||||
|
||||
candidate_f0 = (float)i*SAMPLE_RATE/(PE_FFT_SIZE*DEC);
|
||||
f0_start = candidate_f0-20;
|
||||
f0_end = candidate_f0+20;
|
||||
if (f0_start < f0_min) f0_start = f0_min;
|
||||
if (f0_end > f0_max) f0_end = f0_max;
|
||||
|
||||
for(f0=f0_start; f0<=f0_end; f0+= 2.5) {
|
||||
e = test_candidate_mbe(Sw, W, f0);
|
||||
#if !defined(NDEBUG) || defined(DUMP)
|
||||
bin = floor(f0); assert((bin > 0) && (bin < F0_MAX));
|
||||
#endif
|
||||
#ifdef DUMP
|
||||
e_hz[bin] = e;
|
||||
#endif
|
||||
if (e < e_min) {
|
||||
e_min = e;
|
||||
best_f0 = f0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* finally sample MBE cost function around previous pitch estimate
|
||||
(form of pitch tracking) */
|
||||
|
||||
candidate_f0 = *prev_Wo * SAMPLE_RATE/TWO_PI;
|
||||
f0_start = candidate_f0-20;
|
||||
f0_end = candidate_f0+20;
|
||||
if (f0_start < f0_min) f0_start = f0_min;
|
||||
if (f0_end > f0_max) f0_end = f0_max;
|
||||
|
||||
for(f0=f0_start; f0<=f0_end; f0+= 2.5) {
|
||||
e = test_candidate_mbe(Sw, W, f0);
|
||||
#if !defined(NDEBUG) || defined(DUMP)
|
||||
bin = floor(f0); assert((bin > 0) && (bin < F0_MAX));
|
||||
#endif
|
||||
#ifdef DUMP
|
||||
e_hz[bin] = e;
|
||||
#endif
|
||||
if (e < e_min) {
|
||||
e_min = e;
|
||||
best_f0 = f0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DUMP
|
||||
dump_e(e_hz);
|
||||
#endif
|
||||
|
||||
return best_f0;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
test_candidate_mbe()
|
||||
|
||||
Returns the error of the MBE cost function for the input 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 test_candidate_mbe(
|
||||
COMP Sw[],
|
||||
COMP W[],
|
||||
float f0
|
||||
)
|
||||
{
|
||||
COMP Sw_[FFT_ENC]; /* DFT of all voiced synthesised signal */
|
||||
int l,al,bl,m; /* loop variables */
|
||||
COMP Am; /* amplitude sample for this band */
|
||||
int offset; /* centers Hw[] about current harmonic */
|
||||
float den; /* denominator of Am expression */
|
||||
float error; /* accumulated error between originl and synthesised */
|
||||
float Wo; /* current "test" fundamental freq. */
|
||||
int L;
|
||||
|
||||
L = floor((SAMPLE_RATE/2.0)/f0);
|
||||
Wo = f0*(2*PI/SAMPLE_RATE);
|
||||
|
||||
error = 0.0;
|
||||
|
||||
/* Just test across the harmonics in the first 1000 Hz (L/4) */
|
||||
|
||||
for(l=1; l<L/4; l++) {
|
||||
Am.real = 0.0;
|
||||
Am.imag = 0.0;
|
||||
den = 0.0;
|
||||
al = ceil((l - 0.5)*Wo*FFT_ENC/TWO_PI);
|
||||
bl = ceil((l + 0.5)*Wo*FFT_ENC/TWO_PI);
|
||||
|
||||
/* Estimate amplitude of harmonic assuming harmonic is totally voiced */
|
||||
|
||||
for(m=al; m<bl; m++) {
|
||||
offset = FFT_ENC/2 + m - l*Wo*FFT_ENC/TWO_PI + 0.5;
|
||||
Am.real += Sw[m].real*W[offset].real + Sw[m].imag*W[offset].imag;
|
||||
Am.imag += Sw[m].imag*W[offset].real - Sw[m].real*W[offset].imag;
|
||||
den += W[offset].real*W[offset].real + W[offset].imag*W[offset].imag;
|
||||
}
|
||||
|
||||
Am.real = Am.real/den;
|
||||
Am.imag = Am.imag/den;
|
||||
|
||||
/* Determine error between estimated harmonic and original */
|
||||
|
||||
for(m=al; m<bl; m++) {
|
||||
offset = FFT_ENC/2 + m - l*Wo*FFT_ENC/TWO_PI + 0.5;
|
||||
Sw_[m].real = Am.real*W[offset].real - Am.imag*W[offset].imag;
|
||||
Sw_[m].imag = Am.real*W[offset].imag + Am.imag*W[offset].real;
|
||||
error += (Sw[m].real - Sw_[m].real)*(Sw[m].real - Sw_[m].real);
|
||||
error += (Sw[m].imag - Sw_[m].imag)*(Sw[m].imag - Sw_[m].imag);
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: nlp.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 23/3/93
|
||||
|
||||
Non Linear Pitch (NLP) estimation functions.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __NLP__
|
||||
#define __NLP__
|
||||
|
||||
#include "comp.h"
|
||||
|
||||
void *nlp_create(int m);
|
||||
void nlp_destroy(void *nlp_state);
|
||||
float nlp(void *nlp_state, float Sn[], int n, int pmin, int pmax,
|
||||
float *pitch, COMP Sw[], COMP W[], float *prev_Wo);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/* Generate using fir1(47,1/2) in Octave */
|
||||
|
||||
const float fdmdv_os_filter[]= {
|
||||
-0.0008215855034550382,
|
||||
-0.0007833023901802921,
|
||||
0.001075563790768233,
|
||||
0.001199092367787555,
|
||||
-0.001765309502928316,
|
||||
-0.002055372115328064,
|
||||
0.002986877604154257,
|
||||
0.003462567920638414,
|
||||
-0.004856570111126334,
|
||||
-0.005563143845031497,
|
||||
0.007533613299748122,
|
||||
0.008563932468880897,
|
||||
-0.01126857129039911,
|
||||
-0.01280782411693687,
|
||||
0.01651443896361847,
|
||||
0.01894875110322284,
|
||||
-0.02421604439474981,
|
||||
-0.02845107338464062,
|
||||
0.03672973563400258,
|
||||
0.04542046150312214,
|
||||
-0.06189165826716491,
|
||||
-0.08721876380763803,
|
||||
0.1496157094199961,
|
||||
0.4497962274137046,
|
||||
0.4497962274137046,
|
||||
0.1496157094199961,
|
||||
-0.08721876380763803,
|
||||
-0.0618916582671649,
|
||||
0.04542046150312216,
|
||||
0.03672973563400257,
|
||||
-0.02845107338464062,
|
||||
-0.02421604439474984,
|
||||
0.01894875110322284,
|
||||
0.01651443896361848,
|
||||
-0.01280782411693687,
|
||||
-0.0112685712903991,
|
||||
0.008563932468880899,
|
||||
0.007533613299748123,
|
||||
-0.005563143845031501,
|
||||
-0.004856570111126346,
|
||||
0.003462567920638419,
|
||||
0.002986877604154259,
|
||||
-0.002055372115328063,
|
||||
-0.001765309502928318,
|
||||
0.001199092367787557,
|
||||
0.001075563790768233,
|
||||
-0.0007833023901802925,
|
||||
-0.0008215855034550383
|
||||
};
|
||||
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2010 Perens LLC <bruce@perens.com>
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
#include "quantise.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/* Compile-time constants */
|
||||
/* Size of unsigned char in bits. Assumes 8 bits-per-char. */
|
||||
static const unsigned int WordSize = 8;
|
||||
|
||||
/* Mask to pick the bit component out of bitIndex. */
|
||||
static const unsigned int IndexMask = 0x7;
|
||||
|
||||
/* Used to pick the word component out of bitIndex. */
|
||||
static const unsigned int ShiftRight = 3;
|
||||
|
||||
/** Pack a bit field into a bit string, encoding the field in Gray code.
|
||||
*
|
||||
* The output is an array of unsigned char data. The fields are efficiently
|
||||
* packed into the bit string. The Gray coding is a naive attempt to reduce
|
||||
* the effect of single-bit errors, we expect to do a better job as the
|
||||
* codec develops.
|
||||
*
|
||||
* This code would be simpler if it just set one bit at a time in the string,
|
||||
* but would hit the same cache line more often. I'm not sure the complexity
|
||||
* gains us anything here.
|
||||
*
|
||||
* Although field is currently of int type rather than unsigned for
|
||||
* compatibility with the rest of the code, indices are always expected to
|
||||
* be >= 0.
|
||||
*/
|
||||
void
|
||||
pack(
|
||||
unsigned char * bitArray, /* The output bit string. */
|
||||
unsigned int * bitIndex, /* Index into the string in BITS, not bytes.*/
|
||||
int field, /* The bit field to be packed. */
|
||||
unsigned int fieldWidth/* Width of the field in BITS, not bytes. */
|
||||
)
|
||||
{
|
||||
pack_natural_or_gray(bitArray, bitIndex, field, fieldWidth, 1);
|
||||
}
|
||||
|
||||
void
|
||||
pack_natural_or_gray(
|
||||
unsigned char * bitArray, /* The output bit string. */
|
||||
unsigned int * bitIndex, /* Index into the string in BITS, not bytes.*/
|
||||
int field, /* The bit field to be packed. */
|
||||
unsigned int fieldWidth,/* Width of the field in BITS, not bytes. */
|
||||
unsigned int gray /* non-zero for gray coding */
|
||||
)
|
||||
{
|
||||
if (gray) {
|
||||
/* Convert the field to Gray code */
|
||||
field = (field >> 1) ^ field;
|
||||
}
|
||||
|
||||
do {
|
||||
unsigned int bI = *bitIndex;
|
||||
unsigned int bitsLeft = WordSize - (bI & IndexMask);
|
||||
unsigned int sliceWidth =
|
||||
bitsLeft < fieldWidth ? bitsLeft : fieldWidth;
|
||||
unsigned int wordIndex = bI >> ShiftRight;
|
||||
|
||||
bitArray[wordIndex] |=
|
||||
((unsigned char)((field >> (fieldWidth - sliceWidth))
|
||||
<< (bitsLeft - sliceWidth)));
|
||||
|
||||
*bitIndex = bI + sliceWidth;
|
||||
fieldWidth -= sliceWidth;
|
||||
} while ( fieldWidth != 0 );
|
||||
}
|
||||
|
||||
/** Unpack a field from a bit string, converting from Gray code to binary.
|
||||
*
|
||||
*/
|
||||
int
|
||||
unpack(
|
||||
const unsigned char * bitArray, /* The input bit string. */
|
||||
unsigned int * bitIndex, /* Index into the string in BITS, not bytes.*/
|
||||
unsigned int fieldWidth/* Width of the field in BITS, not bytes. */
|
||||
)
|
||||
{
|
||||
return unpack_natural_or_gray(bitArray, bitIndex, fieldWidth, 1);
|
||||
}
|
||||
|
||||
/** Unpack a field from a bit string, to binary, optionally using
|
||||
* natural or Gray code.
|
||||
*
|
||||
*/
|
||||
int
|
||||
unpack_natural_or_gray(
|
||||
const unsigned char * bitArray, /* The input bit string. */
|
||||
unsigned int * bitIndex, /* Index into the string in BITS, not bytes.*/
|
||||
unsigned int fieldWidth,/* Width of the field in BITS, not bytes. */
|
||||
unsigned int gray /* non-zero for Gray coding */
|
||||
)
|
||||
{
|
||||
unsigned int field = 0;
|
||||
unsigned int t;
|
||||
|
||||
do {
|
||||
unsigned int bI = *bitIndex;
|
||||
unsigned int bitsLeft = WordSize - (bI & IndexMask);
|
||||
unsigned int sliceWidth =
|
||||
bitsLeft < fieldWidth ? bitsLeft : fieldWidth;
|
||||
|
||||
field |= (((bitArray[bI >> ShiftRight] >> (bitsLeft - sliceWidth)) & ((1 << sliceWidth) - 1)) << (fieldWidth - sliceWidth));
|
||||
|
||||
*bitIndex = bI + sliceWidth;
|
||||
fieldWidth -= sliceWidth;
|
||||
} while ( fieldWidth != 0 );
|
||||
|
||||
if (gray) {
|
||||
/* Convert from Gray code to binary. Works for maximum 8-bit fields. */
|
||||
t = field ^ (field >> 8);
|
||||
t ^= (t >> 4);
|
||||
t ^= (t >> 2);
|
||||
t ^= (t >> 1);
|
||||
}
|
||||
else {
|
||||
t = field;
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
|
@ -1,199 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: phase.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 1/2/09
|
||||
|
||||
Functions for modelling and synthesising phase.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
#include "phase.h"
|
||||
#include "kiss_fft.h"
|
||||
#include "comp.h"
|
||||
#include "sine.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
phase_synth_zero_order()
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
in the time domain is equivalent to harmonics in the frequency
|
||||
domain. We can make an excitation pulse train using a sum of
|
||||
sinsusoids:
|
||||
|
||||
for(m=1; m<=L; m++)
|
||||
ex[n] = cos(m*Wo*n)
|
||||
|
||||
Note: the Octave script ../octave/phase.m is an example of this if
|
||||
you would like to try making a pulse train.
|
||||
|
||||
The phase of each excitation harmonic is:
|
||||
|
||||
arg(E[m]) = mWo
|
||||
|
||||
where E[m] are the complex excitation (freq domain) samples,
|
||||
arg(x), just returns the phase of a complex sample x.
|
||||
|
||||
As we don't transmit the pulse position for this model, we need to
|
||||
synthesise it. Now the excitation pulses occur at a rate of Wo.
|
||||
This means the phase of the first harmonic advances by N samples
|
||||
over a synthesis frame of N samples. For example if Wo is pi/20
|
||||
(200 Hz), then over a 10ms frame (N=80 samples), the phase of the
|
||||
first harmonic would advance (pi/20)*80 = 4*pi or two complete
|
||||
cycles.
|
||||
|
||||
We generate the excitation phase of the fundamental (first
|
||||
harmonic):
|
||||
|
||||
arg[E[1]] = Wo*N;
|
||||
|
||||
We then relate the phase of the m-th excitation harmonic to the
|
||||
phase of the fundamental as:
|
||||
|
||||
arg(E[m]) = m*arg(E[1])
|
||||
|
||||
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
|
||||
good. Through a loudspeaker it is very close to original phases.
|
||||
|
||||
- If there are voicing errors, the speech can sound clicky or
|
||||
staticy. If V speech is mistakenly declared UV, this model tends to
|
||||
synthesise impulses or clicks, as there is usually very little shift or
|
||||
dispersion through the LPC filter.
|
||||
|
||||
- When combined with LPC amplitude modelling there is an additional
|
||||
drop in quality. I am not sure why, theory is interformant energy
|
||||
is raised making any phase errors more obvious.
|
||||
|
||||
NOTES:
|
||||
|
||||
1/ This synthesis model is effectively the same as a simple LPC-10
|
||||
vocoders, and yet sounds much better. Why? Conventional wisdom
|
||||
(AMBE, MELP) says mixed voicing is required for high quality
|
||||
speech.
|
||||
|
||||
2/ I am pretty sure the Lincoln Lab sinusoidal coding guys (like xMBE
|
||||
also from MIT) first described this zero phase model, I need to look
|
||||
up the paper.
|
||||
|
||||
3/ Note that this approach could cause some discontinuities in
|
||||
the phase at the edge of synthesis frames, as no attempt is made
|
||||
to make sure that the phase tracks are continuous (the excitation
|
||||
phases are continuous, but not the final phases after filtering
|
||||
by the LPC spectra). Technically this is a bad thing. However
|
||||
this may actually be a good thing, disturbing the phase tracks a
|
||||
bit. More research needed, e.g. test a synthesis model that adds
|
||||
a small delta-W to make phase tracks line up for voiced
|
||||
harmonics.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void phase_synth_zero_order(
|
||||
kiss_fft_cfg fft_fwd_cfg,
|
||||
MODEL *model,
|
||||
float *ex_phase, /* excitation phase of fundamental */
|
||||
COMP A[]
|
||||
)
|
||||
{
|
||||
int m, b;
|
||||
float phi_, new_phi, r;
|
||||
COMP Ex[MAX_AMP+1]; /* excitation samples */
|
||||
COMP A_[MAX_AMP+1]; /* synthesised harmonic samples */
|
||||
COMP H[MAX_AMP+1]; /* LPC freq domain samples */
|
||||
|
||||
r = TWO_PI/(FFT_ENC);
|
||||
|
||||
/* Sample phase at harmonics */
|
||||
|
||||
for(m=1; m<=model->L; m++) {
|
||||
b = (int)(m*model->Wo/r + 0.5);
|
||||
phi_ = -atan2f(A[b].imag, A[b].real);
|
||||
H[m].real = cosf(phi_);
|
||||
H[m].imag = sinf(phi_);
|
||||
}
|
||||
|
||||
/*
|
||||
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+model->Wo)*N/2;
|
||||
*/
|
||||
|
||||
ex_phase[0] += (model->Wo)*N;
|
||||
ex_phase[0] -= TWO_PI*floorf(ex_phase[0]/TWO_PI + 0.5);
|
||||
|
||||
for(m=1; m<=model->L; m++) {
|
||||
|
||||
/* generate excitation */
|
||||
|
||||
if (model->voiced) {
|
||||
|
||||
Ex[m].real = cosf(ex_phase[0]*m);
|
||||
Ex[m].imag = sinf(ex_phase[0]*m);
|
||||
}
|
||||
else {
|
||||
|
||||
/* When a few samples were tested I found that LPC filter
|
||||
phase is not needed in the unvoiced case, but no harm in
|
||||
keeping it.
|
||||
*/
|
||||
float phi = TWO_PI*(float)codec2_rand()/CODEC2_RAND_MAX;
|
||||
Ex[m].real = cosf(phi);
|
||||
Ex[m].imag = sinf(phi);
|
||||
}
|
||||
|
||||
/* filter using LPC filter */
|
||||
|
||||
A_[m].real = H[m].real*Ex[m].real - H[m].imag*Ex[m].imag;
|
||||
A_[m].imag = H[m].imag*Ex[m].real + H[m].real*Ex[m].imag;
|
||||
|
||||
/* modify sinusoidal phase */
|
||||
|
||||
new_phi = atan2f(A_[m].imag, A_[m].real+1E-12);
|
||||
model->phi[m] = new_phi;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: phase.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 1/2/09
|
||||
|
||||
Functions for modelling phase.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __PHASE__
|
||||
#define __PHASE__
|
||||
|
||||
#include "kiss_fft.h"
|
||||
#include "comp.h"
|
||||
|
||||
void phase_synth_zero_order(kiss_fft_cfg fft_dec_cfg,
|
||||
MODEL *model,
|
||||
float *ex_phase,
|
||||
COMP A[]);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/* Generated by pilot_coeff_file() Octave function */
|
||||
|
||||
const float pilot_coeff[]={
|
||||
0.00223001,
|
||||
0.00301037,
|
||||
0.00471258,
|
||||
0.0075934,
|
||||
0.0118145,
|
||||
0.0174153,
|
||||
0.0242969,
|
||||
0.0322204,
|
||||
0.0408199,
|
||||
0.0496286,
|
||||
0.0581172,
|
||||
0.0657392,
|
||||
0.0719806,
|
||||
0.0764066,
|
||||
0.0787022,
|
||||
0.0787022,
|
||||
0.0764066,
|
||||
0.0719806,
|
||||
0.0657392,
|
||||
0.0581172,
|
||||
0.0496286,
|
||||
0.0408199,
|
||||
0.0322204,
|
||||
0.0242969,
|
||||
0.0174153,
|
||||
0.0118145,
|
||||
0.0075934,
|
||||
0.00471258,
|
||||
0.00301037,
|
||||
0.00223001
|
||||
};
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: postfilter.c
|
||||
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.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "comp.h"
|
||||
#include "dump.h"
|
||||
#include "sine.h"
|
||||
#include "postfilter.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
DEFINES
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#define BG_THRESH 40.0 /* only consider low levels signals for bg_est */
|
||||
#define BG_BETA 0.1 /* averaging filter constant */
|
||||
#define BG_MARGIN 6.0 /* harmonics this far above BG noise are
|
||||
randomised. Helped make bg noise less
|
||||
spikey (impulsive) for mmt1, but speech was
|
||||
perhaps a little rougher.
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
postfilter()
|
||||
|
||||
The post filter is designed to help with speech corrupted by
|
||||
background noise. The zero phase model tends to make speech with
|
||||
background noise sound "clicky". With high levels of background
|
||||
noise the low level inter-formant parts of the spectrum will contain
|
||||
noise rather than speech harmonics, so modelling them as voiced
|
||||
(i.e. a continuous, non-random phase track) is inaccurate.
|
||||
|
||||
Some codecs (like MBE) have a mixed voicing model that breaks the
|
||||
spectrum into voiced and unvoiced regions. Several bits/frame
|
||||
(5-12) are required to transmit the frequency selective voicing
|
||||
information. Mixed excitation also requires accurate voicing
|
||||
estimation (parameter estimators always break occasionally under
|
||||
exceptional conditions).
|
||||
|
||||
In our case we use a post filter approach which requires no
|
||||
additional bits to be transmitted. The decoder measures the average
|
||||
level of the background noise during unvoiced frames. If a harmonic
|
||||
is less than this level it is made unvoiced by randomising it's
|
||||
phases.
|
||||
|
||||
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.
|
||||
|
||||
2/ If background noise suddenly dissapears from the source speech does
|
||||
estimate drop quickly? What is noise suddenly re-appears?
|
||||
|
||||
3/ Background noise with a non-flat sepctrum. Current algorithm just
|
||||
comsiders scpetrum as a whole, but this could be broken up into
|
||||
bands, each with their own estimator.
|
||||
|
||||
4/ Males and females with the same level of background noise. Check
|
||||
performance the same. Changing Wo affects width of each band, may
|
||||
affect bg energy estimates.
|
||||
|
||||
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, thresh;
|
||||
|
||||
/* determine average energy across spectrum */
|
||||
|
||||
e = 1E-12;
|
||||
for(m=1; m<=model->L; m++)
|
||||
e += model->A[m]*model->A[m];
|
||||
|
||||
assert(e > 0.0);
|
||||
e = 10.0*log10f(e/model->L);
|
||||
|
||||
/* If beneath threhold, update bg estimate. The idea
|
||||
of the threshold is to prevent updating during high level
|
||||
speech. */
|
||||
|
||||
if ((e < BG_THRESH) && !model->voiced)
|
||||
*bg_est = *bg_est*(1.0 - BG_BETA) + e*BG_BETA;
|
||||
|
||||
/* now mess with phases during voiced frames to make any harmonics
|
||||
less then our background estimate unvoiced.
|
||||
*/
|
||||
|
||||
uv = 0;
|
||||
thresh = powf(10.0, (*bg_est + BG_MARGIN)/20.0);
|
||||
if (model->voiced)
|
||||
for(m=1; m<=model->L; m++)
|
||||
if (model->A[m] < thresh) {
|
||||
model->phi[m] = TWO_PI*(float)codec2_rand()/CODEC2_RAND_MAX;
|
||||
uv++;
|
||||
}
|
||||
|
||||
#ifdef DUMP
|
||||
dump_bg(e, *bg_est, 100.0*uv/model->L);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: postfilter.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 13/09/09
|
||||
|
||||
Postfilter header file.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __POSTFILTER__
|
||||
#define __POSTFILTER__
|
||||
|
||||
void postfilter(MODEL *model, float *bg_est);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,127 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: quantise.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 31/5/92
|
||||
|
||||
Quantisation functions for the sinusoidal coder.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __QUANTISE__
|
||||
#define __QUANTISE__
|
||||
|
||||
#include "kiss_fft.h"
|
||||
#include "comp.h"
|
||||
|
||||
#define WO_BITS 7
|
||||
#define WO_LEVELS (1<<WO_BITS)
|
||||
#define WO_DT_BITS 3
|
||||
|
||||
#define E_BITS 5
|
||||
#define E_LEVELS (1<<E_BITS)
|
||||
#define E_MIN_DB -10.0
|
||||
#define E_MAX_DB 40.0
|
||||
|
||||
#define LSP_SCALAR_INDEXES 10
|
||||
#define LSPD_SCALAR_INDEXES 10
|
||||
#define LSP_PRED_VQ_INDEXES 3
|
||||
#define LSP_DIFF_FREQ_INDEXES 5
|
||||
#define LSP_DIFF_TIME_BITS 7
|
||||
|
||||
#define LSPDT_ALL 0
|
||||
#define LSPDT_LOW 1
|
||||
#define LSPDT_HIGH 2
|
||||
|
||||
#define WO_E_BITS 8
|
||||
|
||||
#define LPCPF_GAMMA 0.5
|
||||
#define LPCPF_BETA 0.2
|
||||
|
||||
void quantise_init();
|
||||
float lpc_model_amplitudes(float Sn[], float w[], MODEL *model, int order,
|
||||
int lsp,float ak[]);
|
||||
void aks_to_M2(kiss_fft_cfg fft_fwd_cfg, float ak[], int order, MODEL *model,
|
||||
float E, float *snr, int dump, int sim_pf,
|
||||
int pf, int bass_boost, float beta, float gamma, COMP Aw[]);
|
||||
|
||||
int encode_Wo(float Wo);
|
||||
float decode_Wo(int index);
|
||||
int encode_Wo_dt(float Wo, float prev_Wo);
|
||||
float decode_Wo_dt(int index, float prev_Wo);
|
||||
void encode_lsps_scalar(int indexes[], float lsp[], int order);
|
||||
void decode_lsps_scalar(float lsp[], int indexes[], int order);
|
||||
void encode_lspds_scalar(int indexes[], float lsp[], int order);
|
||||
void decode_lspds_scalar(float lsp[], int indexes[], int order);
|
||||
void encode_lsps_diff_freq_vq(int indexes[], float lsp[], int order);
|
||||
void decode_lsps_diff_freq_vq(float lsp_[], int indexes[], int order);
|
||||
void encode_lsps_diff_time(int indexes[],
|
||||
float lsp[],
|
||||
float lsp__prev[],
|
||||
int order);
|
||||
void decode_lsps_diff_time(float lsp_[],
|
||||
int indexes[],
|
||||
float lsp__prev[],
|
||||
int order);
|
||||
|
||||
void encode_lsps_vq(int *indexes, float *x, float *xq, int order);
|
||||
void decode_lsps_vq(int *indexes, float *xq, int order);
|
||||
|
||||
long quantise(const float * cb, float vec[], float w[], int k, int m, float *se);
|
||||
void lspvq_quantise(float lsp[], float lsp_[], int order);
|
||||
void lspjnd_quantise(float lsp[], float lsp_[], int order);
|
||||
void lspdt_quantise(float lsps[], float lsps_[], float lsps__prev[], int mode);
|
||||
void lspjvm_quantise(float lsps[], float lsps_[], int order);
|
||||
void lspanssi_quantise(float lsps[], float lsps_[], int order, int mbest_entries);
|
||||
|
||||
void quantise_WoE(MODEL *model, float *e, float xq[]);
|
||||
int encode_WoE(MODEL *model, float e, float xq[]);
|
||||
void decode_WoE(MODEL *model, float *e, float xq[], int n1);
|
||||
|
||||
int encode_energy(float e);
|
||||
float decode_energy(int index);
|
||||
|
||||
void pack(unsigned char * bits, unsigned int *nbit, int index, unsigned int index_bits);
|
||||
void pack_natural_or_gray(unsigned char * bits, unsigned int *nbit, int index, unsigned int index_bits, unsigned int gray);
|
||||
int unpack(const unsigned char * bits, unsigned int *nbit, unsigned int index_bits);
|
||||
int unpack_natural_or_gray(const unsigned char * bits, unsigned int *nbit, unsigned int index_bits, unsigned int gray);
|
||||
|
||||
int lsp_bits(int i);
|
||||
int lspd_bits(int i);
|
||||
int lspdt_bits(int i);
|
||||
int lsp_pred_vq_bits(int i);
|
||||
|
||||
void apply_lpc_correction(MODEL *model);
|
||||
float speech_to_uq_lsps(float lsp[],
|
||||
float ak[],
|
||||
float Sn[],
|
||||
float w[],
|
||||
int order
|
||||
);
|
||||
int check_lsp_order(float lsp[], int lpc_order);
|
||||
void bw_expand_lsps(float lsp[], int order, float min_sep_low, float min_sep_high);
|
||||
void bw_expand_lsps2(float lsp[], int order);
|
||||
void locate_lsps_jnd_steps(float lsp[], int order);
|
||||
float decode_amplitudes(MODEL *model,
|
||||
float ak[],
|
||||
int lsp_indexes[],
|
||||
int energy_index,
|
||||
float lsps[],
|
||||
float *e);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,964 +0,0 @@
|
|||
/* Generated by rn_file() Octave function */
|
||||
|
||||
const float gt_alpha5_root[]={
|
||||
2.86997e-05,
|
||||
2.2286e-05,
|
||||
1.82863e-05,
|
||||
1.42303e-05,
|
||||
1.04905e-05,
|
||||
6.70859e-06,
|
||||
3.05918e-06,
|
||||
-6.22187e-07,
|
||||
-4.22748e-06,
|
||||
-7.85603e-06,
|
||||
-1.14317e-05,
|
||||
-1.50227e-05,
|
||||
-1.85712e-05,
|
||||
-2.21275e-05,
|
||||
-2.56455e-05,
|
||||
-2.91642e-05,
|
||||
-3.26453e-05,
|
||||
-3.61199e-05,
|
||||
-3.95556e-05,
|
||||
-4.29778e-05,
|
||||
-4.63581e-05,
|
||||
-4.97179e-05,
|
||||
-5.3032e-05,
|
||||
-5.63184e-05,
|
||||
-5.95548e-05,
|
||||
-6.27565e-05,
|
||||
-6.59032e-05,
|
||||
-6.90085e-05,
|
||||
-7.20538e-05,
|
||||
-7.50509e-05,
|
||||
-7.7983e-05,
|
||||
-8.08605e-05,
|
||||
-8.36678e-05,
|
||||
-8.64141e-05,
|
||||
-8.9085e-05,
|
||||
-9.16888e-05,
|
||||
-9.42119e-05,
|
||||
-9.66619e-05,
|
||||
-9.9026e-05,
|
||||
-0.000101311,
|
||||
-0.000103505,
|
||||
-0.000105614,
|
||||
-0.000107627,
|
||||
-0.00010955,
|
||||
-0.000111372,
|
||||
-0.000113099,
|
||||
-0.00011472,
|
||||
-0.000116241,
|
||||
-0.000117652,
|
||||
-0.000118959,
|
||||
-0.000120152,
|
||||
-0.000121235,
|
||||
-0.000122201,
|
||||
-0.000123053,
|
||||
-0.000123784,
|
||||
-0.000124397,
|
||||
-0.000124884,
|
||||
-0.00012525,
|
||||
-0.000125487,
|
||||
-0.000125598,
|
||||
-0.000125578,
|
||||
-0.000125428,
|
||||
-0.000125145,
|
||||
-0.000124729,
|
||||
-0.000124185,
|
||||
-0.000123518,
|
||||
-0.000122709,
|
||||
-0.000121766,
|
||||
-0.000120685,
|
||||
-0.000119471,
|
||||
-0.000118119,
|
||||
-0.000116633,
|
||||
-0.000115009,
|
||||
-0.000113251,
|
||||
-0.000111356,
|
||||
-0.000109326,
|
||||
-0.00010716,
|
||||
-0.00010486,
|
||||
-0.000102424,
|
||||
-9.98553e-05,
|
||||
-9.71528e-05,
|
||||
-9.43199e-05,
|
||||
-9.13551e-05,
|
||||
-8.82623e-05,
|
||||
-8.50404e-05,
|
||||
-8.16936e-05,
|
||||
-7.82211e-05,
|
||||
-7.46271e-05,
|
||||
-7.09109e-05,
|
||||
-6.70773e-05,
|
||||
-6.31256e-05,
|
||||
-5.90607e-05,
|
||||
-5.48823e-05,
|
||||
-5.05954e-05,
|
||||
-4.62001e-05,
|
||||
-4.17016e-05,
|
||||
-3.71002e-05,
|
||||
-3.24015e-05,
|
||||
-2.7606e-05,
|
||||
-2.27195e-05,
|
||||
-1.77428e-05,
|
||||
-1.2682e-05,
|
||||
-7.53795e-06,
|
||||
-2.31702e-06,
|
||||
2.97965e-06,
|
||||
8.34567e-06,
|
||||
1.37796e-05,
|
||||
1.9275e-05,
|
||||
2.483e-05,
|
||||
3.04382e-05,
|
||||
3.60975e-05,
|
||||
4.18011e-05,
|
||||
4.75467e-05,
|
||||
5.33273e-05,
|
||||
5.91403e-05,
|
||||
6.49787e-05,
|
||||
7.08393e-05,
|
||||
7.67152e-05,
|
||||
8.26029e-05,
|
||||
8.84957e-05,
|
||||
9.43895e-05,
|
||||
0.000100278,
|
||||
0.000106157,
|
||||
0.00011202,
|
||||
0.000117864,
|
||||
0.000123681,
|
||||
0.000129468,
|
||||
0.000135218,
|
||||
0.000140929,
|
||||
0.000146583,
|
||||
0.000152183,
|
||||
0.000157725,
|
||||
0.000163202,
|
||||
0.000168608,
|
||||
0.000173938,
|
||||
0.000179183,
|
||||
0.00018434,
|
||||
0.0001894,
|
||||
0.00019436,
|
||||
0.000199211,
|
||||
0.000203949,
|
||||
0.000208568,
|
||||
0.000213063,
|
||||
0.000217426,
|
||||
0.000221654,
|
||||
0.00022574,
|
||||
0.000229678,
|
||||
0.000233463,
|
||||
0.000237089,
|
||||
0.000240551,
|
||||
0.000243843,
|
||||
0.000246959,
|
||||
0.000249895,
|
||||
0.000252644,
|
||||
0.000255202,
|
||||
0.000257562,
|
||||
0.000259721,
|
||||
0.000261672,
|
||||
0.000263411,
|
||||
0.000264933,
|
||||
0.000266234,
|
||||
0.000267308,
|
||||
0.000268152,
|
||||
0.00026876,
|
||||
0.000269128,
|
||||
0.000269253,
|
||||
0.000269129,
|
||||
0.000268754,
|
||||
0.000268123,
|
||||
0.000267232,
|
||||
0.000266079,
|
||||
0.000264658,
|
||||
0.000262968,
|
||||
0.000261006,
|
||||
0.000258767,
|
||||
0.000256251,
|
||||
0.000253453,
|
||||
0.000250373,
|
||||
0.000247007,
|
||||
0.000243354,
|
||||
0.000239412,
|
||||
0.00023518,
|
||||
0.000230655,
|
||||
0.000225837,
|
||||
0.000220723,
|
||||
0.000215314,
|
||||
0.000209608,
|
||||
0.000203605,
|
||||
0.000197304,
|
||||
0.000190706,
|
||||
0.000183812,
|
||||
0.000176621,
|
||||
0.000169145,
|
||||
0.000161363,
|
||||
0.000153275,
|
||||
0.000144895,
|
||||
0.000136224,
|
||||
0.000127266,
|
||||
0.00011802,
|
||||
0.000108491,
|
||||
9.8679e-05,
|
||||
8.85877e-05,
|
||||
7.82196e-05,
|
||||
6.7577e-05,
|
||||
5.66636e-05,
|
||||
4.54822e-05,
|
||||
3.40369e-05,
|
||||
2.23311e-05,
|
||||
1.03695e-05,
|
||||
-1.844e-06,
|
||||
-1.43041e-05,
|
||||
-2.70061e-05,
|
||||
-3.99444e-05,
|
||||
-5.31139e-05,
|
||||
-6.65082e-05,
|
||||
-8.01218e-05,
|
||||
-9.39481e-05,
|
||||
-0.000107981,
|
||||
-0.000122213,
|
||||
-0.000136638,
|
||||
-0.000151248,
|
||||
-0.000166036,
|
||||
-0.000180995,
|
||||
-0.000196115,
|
||||
-0.00021139,
|
||||
-0.000226811,
|
||||
-0.000242369,
|
||||
-0.000258056,
|
||||
-0.000273861,
|
||||
-0.000289776,
|
||||
-0.000305792,
|
||||
-0.000321898,
|
||||
-0.000338084,
|
||||
-0.000354342,
|
||||
-0.00037066,
|
||||
-0.000387027,
|
||||
-0.000403434,
|
||||
-0.00041987,
|
||||
-0.000436324,
|
||||
-0.000452784,
|
||||
-0.00046924,
|
||||
-0.00048568,
|
||||
-0.000502091,
|
||||
-0.000518464,
|
||||
-0.000534785,
|
||||
-0.000551043,
|
||||
-0.000567225,
|
||||
-0.000583319,
|
||||
-0.000599314,
|
||||
-0.000615196,
|
||||
-0.000630955,
|
||||
-0.000646575,
|
||||
-0.000662049,
|
||||
-0.000677361,
|
||||
-0.000692506,
|
||||
-0.000707464,
|
||||
-0.00072229,
|
||||
-0.000736922,
|
||||
-0.000751266,
|
||||
-0.000765372,
|
||||
-0.000779217,
|
||||
-0.000792798,
|
||||
-0.000806094,
|
||||
-0.000819098,
|
||||
-0.000831793,
|
||||
-0.000844168,
|
||||
-0.000856207,
|
||||
-0.000867898,
|
||||
-0.000879227,
|
||||
-0.00089018,
|
||||
-0.000900744,
|
||||
-0.000910906,
|
||||
-0.000920652,
|
||||
-0.00092997,
|
||||
-0.000938844,
|
||||
-0.000947263,
|
||||
-0.000955214,
|
||||
-0.000962682,
|
||||
-0.000969654,
|
||||
-0.000976119,
|
||||
-0.000982062,
|
||||
-0.00098747,
|
||||
-0.000992332,
|
||||
-0.000996634,
|
||||
-0.00100036,
|
||||
-0.00100351,
|
||||
-0.00100606,
|
||||
-0.001008,
|
||||
-0.00100932,
|
||||
-0.00101,
|
||||
-0.00101005,
|
||||
-0.00100943,
|
||||
-0.00100816,
|
||||
-0.0010062,
|
||||
-0.00100356,
|
||||
-0.00100021,
|
||||
-0.000996162,
|
||||
-0.000991392,
|
||||
-0.000985892,
|
||||
-0.000979654,
|
||||
-0.000972668,
|
||||
-0.000964925,
|
||||
-0.000956415,
|
||||
-0.000947131,
|
||||
-0.000937065,
|
||||
-0.000926208,
|
||||
-0.000914552,
|
||||
-0.00090209,
|
||||
-0.000888816,
|
||||
-0.000874721,
|
||||
-0.0008598,
|
||||
-0.000844046,
|
||||
-0.000827453,
|
||||
-0.000810015,
|
||||
-0.000791726,
|
||||
-0.000772581,
|
||||
-0.000752576,
|
||||
-0.000731704,
|
||||
-0.000709965,
|
||||
-0.00068735,
|
||||
-0.000663865,
|
||||
-0.000639509,
|
||||
-0.000614269,
|
||||
-0.000588146,
|
||||
-0.000561139,
|
||||
-0.000533246,
|
||||
-0.000504468,
|
||||
-0.000474802,
|
||||
-0.000444251,
|
||||
-0.000412813,
|
||||
-0.00038049,
|
||||
-0.000347281,
|
||||
-0.000313189,
|
||||
-0.000278215,
|
||||
-0.000242361,
|
||||
-0.000205629,
|
||||
-0.000168024,
|
||||
-0.000129546,
|
||||
-9.02024e-05,
|
||||
-4.99954e-05,
|
||||
-8.93026e-06,
|
||||
3.2988e-05,
|
||||
7.57537e-05,
|
||||
0.000119361,
|
||||
0.000163804,
|
||||
0.000209075,
|
||||
0.000255167,
|
||||
0.000302074,
|
||||
0.000349786,
|
||||
0.000398297,
|
||||
0.000447596,
|
||||
0.000497676,
|
||||
0.000548526,
|
||||
0.000600136,
|
||||
0.000652497,
|
||||
0.000705598,
|
||||
0.000759427,
|
||||
0.000813972,
|
||||
0.000869223,
|
||||
0.000925166,
|
||||
0.000981789,
|
||||
0.00103908,
|
||||
0.00109702,
|
||||
0.00115561,
|
||||
0.00121482,
|
||||
0.00127464,
|
||||
0.00133505,
|
||||
0.00139605,
|
||||
0.00145762,
|
||||
0.00151973,
|
||||
0.00158238,
|
||||
0.00164555,
|
||||
0.00170922,
|
||||
0.00177337,
|
||||
0.00183799,
|
||||
0.00190305,
|
||||
0.00196854,
|
||||
0.00203445,
|
||||
0.00210075,
|
||||
0.00216742,
|
||||
0.00223445,
|
||||
0.00230181,
|
||||
0.00236949,
|
||||
0.00243747,
|
||||
0.00250572,
|
||||
0.00257423,
|
||||
0.00264296,
|
||||
0.00271192,
|
||||
0.00278107,
|
||||
0.00285039,
|
||||
0.00291986,
|
||||
0.00298947,
|
||||
0.00305918,
|
||||
0.00312898,
|
||||
0.00319884,
|
||||
0.00326874,
|
||||
0.00333866,
|
||||
0.00340857,
|
||||
0.00347846,
|
||||
0.00354831,
|
||||
0.00361808,
|
||||
0.00368775,
|
||||
0.00375731,
|
||||
0.00382673,
|
||||
0.00389599,
|
||||
0.00396506,
|
||||
0.00403393,
|
||||
0.00410256,
|
||||
0.00417094,
|
||||
0.00423904,
|
||||
0.00430684,
|
||||
0.00437431,
|
||||
0.00444144,
|
||||
0.0045082,
|
||||
0.00457457,
|
||||
0.00464052,
|
||||
0.00470603,
|
||||
0.00477108,
|
||||
0.00483565,
|
||||
0.00489972,
|
||||
0.00496325,
|
||||
0.00502623,
|
||||
0.00508865,
|
||||
0.00515046,
|
||||
0.00521166,
|
||||
0.00527223,
|
||||
0.00533213,
|
||||
0.00539135,
|
||||
0.00544987,
|
||||
0.00550766,
|
||||
0.00556472,
|
||||
0.005621,
|
||||
0.00567651,
|
||||
0.00573121,
|
||||
0.00578508,
|
||||
0.00583811,
|
||||
0.00589028,
|
||||
0.00594157,
|
||||
0.00599196,
|
||||
0.00604143,
|
||||
0.00608996,
|
||||
0.00613754,
|
||||
0.00618415,
|
||||
0.00622977,
|
||||
0.00627439,
|
||||
0.00631798,
|
||||
0.00636054,
|
||||
0.00640204,
|
||||
0.0064425,
|
||||
0.00648186,
|
||||
0.00652009,
|
||||
0.00655722,
|
||||
0.00659322,
|
||||
0.00662808,
|
||||
0.00666179,
|
||||
0.00669433,
|
||||
0.00672571,
|
||||
0.00675589,
|
||||
0.00678488,
|
||||
0.00681266,
|
||||
0.00683921,
|
||||
0.00686454,
|
||||
0.00688863,
|
||||
0.00691147,
|
||||
0.00693305,
|
||||
0.00695336,
|
||||
0.0069724,
|
||||
0.00699016,
|
||||
0.00700663,
|
||||
0.00702181,
|
||||
0.00703569,
|
||||
0.00704826,
|
||||
0.00705952,
|
||||
0.00706947,
|
||||
0.00707809,
|
||||
0.0070854,
|
||||
0.00709138,
|
||||
0.00709604,
|
||||
0.00709937,
|
||||
0.00710136,
|
||||
0.00710203,
|
||||
0.00710136,
|
||||
0.00709937,
|
||||
0.00709604,
|
||||
0.00709138,
|
||||
0.0070854,
|
||||
0.00707809,
|
||||
0.00706947,
|
||||
0.00705952,
|
||||
0.00704826,
|
||||
0.00703569,
|
||||
0.00702181,
|
||||
0.00700663,
|
||||
0.00699016,
|
||||
0.0069724,
|
||||
0.00695336,
|
||||
0.00693305,
|
||||
0.00691147,
|
||||
0.00688863,
|
||||
0.00686454,
|
||||
0.00683921,
|
||||
0.00681266,
|
||||
0.00678488,
|
||||
0.00675589,
|
||||
0.00672571,
|
||||
0.00669433,
|
||||
0.00666179,
|
||||
0.00662808,
|
||||
0.00659322,
|
||||
0.00655722,
|
||||
0.00652009,
|
||||
0.00648186,
|
||||
0.0064425,
|
||||
0.00640204,
|
||||
0.00636054,
|
||||
0.00631798,
|
||||
0.00627439,
|
||||
0.00622977,
|
||||
0.00618415,
|
||||
0.00613754,
|
||||
0.00608996,
|
||||
0.00604143,
|
||||
0.00599196,
|
||||
0.00594157,
|
||||
0.00589028,
|
||||
0.00583811,
|
||||
0.00578508,
|
||||
0.00573121,
|
||||
0.00567651,
|
||||
0.005621,
|
||||
0.00556472,
|
||||
0.00550766,
|
||||
0.00544987,
|
||||
0.00539135,
|
||||
0.00533213,
|
||||
0.00527223,
|
||||
0.00521166,
|
||||
0.00515046,
|
||||
0.00508865,
|
||||
0.00502623,
|
||||
0.00496325,
|
||||
0.00489972,
|
||||
0.00483565,
|
||||
0.00477108,
|
||||
0.00470603,
|
||||
0.00464052,
|
||||
0.00457457,
|
||||
0.0045082,
|
||||
0.00444144,
|
||||
0.00437431,
|
||||
0.00430684,
|
||||
0.00423904,
|
||||
0.00417094,
|
||||
0.00410256,
|
||||
0.00403393,
|
||||
0.00396506,
|
||||
0.00389599,
|
||||
0.00382673,
|
||||
0.00375731,
|
||||
0.00368775,
|
||||
0.00361808,
|
||||
0.00354831,
|
||||
0.00347846,
|
||||
0.00340857,
|
||||
0.00333866,
|
||||
0.00326874,
|
||||
0.00319884,
|
||||
0.00312898,
|
||||
0.00305918,
|
||||
0.00298947,
|
||||
0.00291986,
|
||||
0.00285039,
|
||||
0.00278107,
|
||||
0.00271192,
|
||||
0.00264296,
|
||||
0.00257423,
|
||||
0.00250572,
|
||||
0.00243747,
|
||||
0.00236949,
|
||||
0.00230181,
|
||||
0.00223445,
|
||||
0.00216742,
|
||||
0.00210075,
|
||||
0.00203445,
|
||||
0.00196854,
|
||||
0.00190305,
|
||||
0.00183799,
|
||||
0.00177337,
|
||||
0.00170922,
|
||||
0.00164555,
|
||||
0.00158238,
|
||||
0.00151973,
|
||||
0.00145762,
|
||||
0.00139605,
|
||||
0.00133505,
|
||||
0.00127464,
|
||||
0.00121482,
|
||||
0.00115561,
|
||||
0.00109702,
|
||||
0.00103908,
|
||||
0.000981789,
|
||||
0.000925166,
|
||||
0.000869223,
|
||||
0.000813972,
|
||||
0.000759427,
|
||||
0.000705598,
|
||||
0.000652497,
|
||||
0.000600136,
|
||||
0.000548526,
|
||||
0.000497676,
|
||||
0.000447596,
|
||||
0.000398297,
|
||||
0.000349786,
|
||||
0.000302074,
|
||||
0.000255167,
|
||||
0.000209075,
|
||||
0.000163804,
|
||||
0.000119361,
|
||||
7.57537e-05,
|
||||
3.2988e-05,
|
||||
-8.93026e-06,
|
||||
-4.99954e-05,
|
||||
-9.02024e-05,
|
||||
-0.000129546,
|
||||
-0.000168024,
|
||||
-0.000205629,
|
||||
-0.000242361,
|
||||
-0.000278215,
|
||||
-0.000313189,
|
||||
-0.000347281,
|
||||
-0.00038049,
|
||||
-0.000412813,
|
||||
-0.000444251,
|
||||
-0.000474802,
|
||||
-0.000504468,
|
||||
-0.000533246,
|
||||
-0.000561139,
|
||||
-0.000588146,
|
||||
-0.000614269,
|
||||
-0.000639509,
|
||||
-0.000663865,
|
||||
-0.00068735,
|
||||
-0.000709965,
|
||||
-0.000731704,
|
||||
-0.000752576,
|
||||
-0.000772581,
|
||||
-0.000791726,
|
||||
-0.000810015,
|
||||
-0.000827453,
|
||||
-0.000844046,
|
||||
-0.0008598,
|
||||
-0.000874721,
|
||||
-0.000888816,
|
||||
-0.00090209,
|
||||
-0.000914552,
|
||||
-0.000926208,
|
||||
-0.000937065,
|
||||
-0.000947131,
|
||||
-0.000956415,
|
||||
-0.000964925,
|
||||
-0.000972668,
|
||||
-0.000979654,
|
||||
-0.000985892,
|
||||
-0.000991392,
|
||||
-0.000996162,
|
||||
-0.00100021,
|
||||
-0.00100356,
|
||||
-0.0010062,
|
||||
-0.00100816,
|
||||
-0.00100943,
|
||||
-0.00101005,
|
||||
-0.00101,
|
||||
-0.00100932,
|
||||
-0.001008,
|
||||
-0.00100606,
|
||||
-0.00100351,
|
||||
-0.00100036,
|
||||
-0.000996634,
|
||||
-0.000992332,
|
||||
-0.00098747,
|
||||
-0.000982062,
|
||||
-0.000976119,
|
||||
-0.000969654,
|
||||
-0.000962682,
|
||||
-0.000955214,
|
||||
-0.000947263,
|
||||
-0.000938844,
|
||||
-0.00092997,
|
||||
-0.000920652,
|
||||
-0.000910906,
|
||||
-0.000900744,
|
||||
-0.00089018,
|
||||
-0.000879227,
|
||||
-0.000867898,
|
||||
-0.000856207,
|
||||
-0.000844168,
|
||||
-0.000831793,
|
||||
-0.000819098,
|
||||
-0.000806094,
|
||||
-0.000792798,
|
||||
-0.000779217,
|
||||
-0.000765372,
|
||||
-0.000751266,
|
||||
-0.000736922,
|
||||
-0.00072229,
|
||||
-0.000707464,
|
||||
-0.000692506,
|
||||
-0.000677361,
|
||||
-0.000662049,
|
||||
-0.000646575,
|
||||
-0.000630955,
|
||||
-0.000615196,
|
||||
-0.000599314,
|
||||
-0.000583319,
|
||||
-0.000567225,
|
||||
-0.000551043,
|
||||
-0.000534785,
|
||||
-0.000518464,
|
||||
-0.000502091,
|
||||
-0.00048568,
|
||||
-0.00046924,
|
||||
-0.000452784,
|
||||
-0.000436324,
|
||||
-0.00041987,
|
||||
-0.000403434,
|
||||
-0.000387027,
|
||||
-0.00037066,
|
||||
-0.000354342,
|
||||
-0.000338084,
|
||||
-0.000321898,
|
||||
-0.000305792,
|
||||
-0.000289776,
|
||||
-0.000273861,
|
||||
-0.000258056,
|
||||
-0.000242369,
|
||||
-0.000226811,
|
||||
-0.00021139,
|
||||
-0.000196115,
|
||||
-0.000180995,
|
||||
-0.000166036,
|
||||
-0.000151248,
|
||||
-0.000136638,
|
||||
-0.000122213,
|
||||
-0.000107981,
|
||||
-9.39481e-05,
|
||||
-8.01218e-05,
|
||||
-6.65082e-05,
|
||||
-5.31139e-05,
|
||||
-3.99444e-05,
|
||||
-2.70061e-05,
|
||||
-1.43041e-05,
|
||||
-1.844e-06,
|
||||
1.03695e-05,
|
||||
2.23311e-05,
|
||||
3.40369e-05,
|
||||
4.54822e-05,
|
||||
5.66636e-05,
|
||||
6.7577e-05,
|
||||
7.82196e-05,
|
||||
8.85877e-05,
|
||||
9.8679e-05,
|
||||
0.000108491,
|
||||
0.00011802,
|
||||
0.000127266,
|
||||
0.000136224,
|
||||
0.000144895,
|
||||
0.000153275,
|
||||
0.000161363,
|
||||
0.000169145,
|
||||
0.000176621,
|
||||
0.000183812,
|
||||
0.000190706,
|
||||
0.000197304,
|
||||
0.000203605,
|
||||
0.000209608,
|
||||
0.000215314,
|
||||
0.000220723,
|
||||
0.000225837,
|
||||
0.000230655,
|
||||
0.00023518,
|
||||
0.000239412,
|
||||
0.000243354,
|
||||
0.000247007,
|
||||
0.000250373,
|
||||
0.000253453,
|
||||
0.000256251,
|
||||
0.000258767,
|
||||
0.000261006,
|
||||
0.000262968,
|
||||
0.000264658,
|
||||
0.000266079,
|
||||
0.000267232,
|
||||
0.000268123,
|
||||
0.000268754,
|
||||
0.000269129,
|
||||
0.000269253,
|
||||
0.000269128,
|
||||
0.00026876,
|
||||
0.000268152,
|
||||
0.000267308,
|
||||
0.000266234,
|
||||
0.000264933,
|
||||
0.000263411,
|
||||
0.000261672,
|
||||
0.000259721,
|
||||
0.000257562,
|
||||
0.000255202,
|
||||
0.000252644,
|
||||
0.000249895,
|
||||
0.000246959,
|
||||
0.000243843,
|
||||
0.000240551,
|
||||
0.000237089,
|
||||
0.000233463,
|
||||
0.000229678,
|
||||
0.00022574,
|
||||
0.000221654,
|
||||
0.000217426,
|
||||
0.000213063,
|
||||
0.000208568,
|
||||
0.000203949,
|
||||
0.000199211,
|
||||
0.00019436,
|
||||
0.0001894,
|
||||
0.00018434,
|
||||
0.000179183,
|
||||
0.000173938,
|
||||
0.000168608,
|
||||
0.000163202,
|
||||
0.000157725,
|
||||
0.000152183,
|
||||
0.000146583,
|
||||
0.000140929,
|
||||
0.000135218,
|
||||
0.000129468,
|
||||
0.000123681,
|
||||
0.000117864,
|
||||
0.00011202,
|
||||
0.000106157,
|
||||
0.000100278,
|
||||
9.43895e-05,
|
||||
8.84957e-05,
|
||||
8.26029e-05,
|
||||
7.67152e-05,
|
||||
7.08393e-05,
|
||||
6.49787e-05,
|
||||
5.91403e-05,
|
||||
5.33273e-05,
|
||||
4.75467e-05,
|
||||
4.18011e-05,
|
||||
3.60975e-05,
|
||||
3.04382e-05,
|
||||
2.483e-05,
|
||||
1.9275e-05,
|
||||
1.37796e-05,
|
||||
8.34567e-06,
|
||||
2.97965e-06,
|
||||
-2.31702e-06,
|
||||
-7.53795e-06,
|
||||
-1.2682e-05,
|
||||
-1.77428e-05,
|
||||
-2.27195e-05,
|
||||
-2.7606e-05,
|
||||
-3.24015e-05,
|
||||
-3.71002e-05,
|
||||
-4.17016e-05,
|
||||
-4.62001e-05,
|
||||
-5.05954e-05,
|
||||
-5.48823e-05,
|
||||
-5.90607e-05,
|
||||
-6.31256e-05,
|
||||
-6.70773e-05,
|
||||
-7.09109e-05,
|
||||
-7.46271e-05,
|
||||
-7.82211e-05,
|
||||
-8.16936e-05,
|
||||
-8.50404e-05,
|
||||
-8.82623e-05,
|
||||
-9.13551e-05,
|
||||
-9.43199e-05,
|
||||
-9.71528e-05,
|
||||
-9.98553e-05,
|
||||
-0.000102424,
|
||||
-0.00010486,
|
||||
-0.00010716,
|
||||
-0.000109326,
|
||||
-0.000111356,
|
||||
-0.000113251,
|
||||
-0.000115009,
|
||||
-0.000116633,
|
||||
-0.000118119,
|
||||
-0.000119471,
|
||||
-0.000120685,
|
||||
-0.000121766,
|
||||
-0.000122709,
|
||||
-0.000123518,
|
||||
-0.000124185,
|
||||
-0.000124729,
|
||||
-0.000125145,
|
||||
-0.000125428,
|
||||
-0.000125578,
|
||||
-0.000125598,
|
||||
-0.000125487,
|
||||
-0.00012525,
|
||||
-0.000124884,
|
||||
-0.000124397,
|
||||
-0.000123784,
|
||||
-0.000123053,
|
||||
-0.000122201,
|
||||
-0.000121235,
|
||||
-0.000120152,
|
||||
-0.000118959,
|
||||
-0.000117652,
|
||||
-0.000116241,
|
||||
-0.00011472,
|
||||
-0.000113099,
|
||||
-0.000111372,
|
||||
-0.00010955,
|
||||
-0.000107627,
|
||||
-0.000105614,
|
||||
-0.000103505,
|
||||
-0.000101311,
|
||||
-9.9026e-05,
|
||||
-9.66619e-05,
|
||||
-9.42119e-05,
|
||||
-9.16888e-05,
|
||||
-8.9085e-05,
|
||||
-8.64141e-05,
|
||||
-8.36678e-05,
|
||||
-8.08605e-05,
|
||||
-7.7983e-05,
|
||||
-7.50509e-05,
|
||||
-7.20538e-05,
|
||||
-6.90085e-05,
|
||||
-6.59032e-05,
|
||||
-6.27565e-05,
|
||||
-5.95548e-05,
|
||||
-5.63184e-05,
|
||||
-5.3032e-05,
|
||||
-4.97179e-05,
|
||||
-4.63581e-05,
|
||||
-4.29778e-05,
|
||||
-3.95556e-05,
|
||||
-3.61199e-05,
|
||||
-3.26453e-05,
|
||||
-2.91642e-05,
|
||||
-2.56455e-05,
|
||||
-2.21275e-05,
|
||||
-1.85712e-05,
|
||||
-1.50227e-05,
|
||||
-1.14317e-05,
|
||||
-7.85603e-06,
|
||||
-4.22748e-06,
|
||||
-6.22187e-07,
|
||||
3.05918e-06,
|
||||
6.70859e-06,
|
||||
1.04905e-05,
|
||||
1.42303e-05,
|
||||
1.82863e-05,
|
||||
2.2286e-05
|
||||
};
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/* Generated by rxdec_file() Octave function */
|
||||
|
||||
const float rxdec_coeff[]={
|
||||
-0.00125472,
|
||||
-0.00204605,
|
||||
-0.0019897,
|
||||
0.000163906,
|
||||
0.00490937,
|
||||
0.00986375,
|
||||
0.0096718,
|
||||
-0.000480351,
|
||||
-0.019311,
|
||||
-0.0361822,
|
||||
-0.0341251,
|
||||
0.000827866,
|
||||
0.0690577,
|
||||
0.152812,
|
||||
0.222115,
|
||||
0.249004,
|
||||
0.222115,
|
||||
0.152812,
|
||||
0.0690577,
|
||||
0.000827866,
|
||||
-0.0341251,
|
||||
-0.0361822,
|
||||
-0.019311,
|
||||
-0.000480351,
|
||||
0.0096718,
|
||||
0.00986375,
|
||||
0.00490937,
|
||||
0.000163906,
|
||||
-0.0019897,
|
||||
-0.00204605,
|
||||
-0.00125472
|
||||
};
|
||||
|
|
@ -1,647 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: sine.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 19/8/2010
|
||||
|
||||
Sinusoidal analysis and synthesis functions.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 1990-2010 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
INCLUDES
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "sine.h"
|
||||
#include "kiss_fft.h"
|
||||
|
||||
#define HPF_BETA 0.125
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
HEADERS
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void hs_pitch_refinement(MODEL *model, COMP Sw[], float pmin, float pmax,
|
||||
float pstep);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTIONS
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
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.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void make_analysis_window(kiss_fft_cfg fft_fwd_cfg, float w[], COMP W[])
|
||||
{
|
||||
float m;
|
||||
COMP wshift[FFT_ENC];
|
||||
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.
|
||||
*/
|
||||
|
||||
m = 0.0;
|
||||
for(i=0; i<M/2-NW/2; i++)
|
||||
w[i] = 0.0;
|
||||
for(i=M/2-NW/2,j=0; i<M/2+NW/2; i++,j++) {
|
||||
w[i] = 0.5 - 0.5*cosf(TWO_PI*j/(NW-1));
|
||||
m += w[i]*w[i];
|
||||
}
|
||||
for(i=M/2+NW/2; i<M; i++)
|
||||
w[i] = 0.0;
|
||||
|
||||
/* Normalise - makes freq domain amplitude estimation straight
|
||||
forward */
|
||||
|
||||
m = 1.0/sqrtf(m*FFT_ENC);
|
||||
for(i=0; i<M; i++) {
|
||||
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
|
||||
even about the n=0 time axis if NW is odd. Having the imag part
|
||||
of the DFT W[] makes computation easier.
|
||||
|
||||
0 FFT_ENC-1
|
||||
|-------------------------|
|
||||
|
||||
----\ /----
|
||||
\ /
|
||||
\ / <- shifted version of window w[n]
|
||||
\ /
|
||||
\ /
|
||||
-------
|
||||
|
||||
|---------| |---------|
|
||||
NW/2 NW/2
|
||||
*/
|
||||
|
||||
for(i=0; i<FFT_ENC; i++) {
|
||||
wshift[i].real = 0.0;
|
||||
wshift[i].imag = 0.0;
|
||||
}
|
||||
for(i=0; i<NW/2; i++)
|
||||
wshift[i].real = w[i+M/2];
|
||||
for(i=FFT_ENC-NW/2,j=M/2-NW/2; i<FFT_ENC; i++,j++)
|
||||
wshift[i].real = w[j];
|
||||
|
||||
kiss_fft(fft_fwd_cfg, (kiss_fft_cpx *)wshift, (kiss_fft_cpx *)W);
|
||||
|
||||
/*
|
||||
Re-arrange W[] to be symmetrical about FFT_ENC/2. Makes later
|
||||
analysis convenient.
|
||||
|
||||
Before:
|
||||
|
||||
|
||||
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;
|
||||
W[i].real = W[i+FFT_ENC/2].real;
|
||||
W[i].imag = W[i+FFT_ENC/2].imag;
|
||||
W[i+FFT_ENC/2].real = temp.real;
|
||||
W[i+FFT_ENC/2].imag = temp.imag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
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[])
|
||||
{
|
||||
states[0] = -HPF_BETA*states[0] + x - states[1];
|
||||
states[1] = x;
|
||||
|
||||
return states[0];
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: dft_speech
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 27/5/94
|
||||
|
||||
Finds the DFT of the current speech input speech frame.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void dft_speech(kiss_fft_cfg fft_fwd_cfg, COMP Sw[], float Sn[], float w[])
|
||||
{
|
||||
int i;
|
||||
COMP sw[FFT_ENC];
|
||||
|
||||
for(i=0; i<FFT_ENC; i++) {
|
||||
sw[i].real = 0.0;
|
||||
sw[i].imag = 0.0;
|
||||
}
|
||||
|
||||
/* 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++)
|
||||
sw[i].real = Sn[i+M/2]*w[i+M/2];
|
||||
|
||||
/* move 1st half to end of FFT input vector */
|
||||
|
||||
for(i=0; i<NW/2; i++)
|
||||
sw[FFT_ENC-NW/2+i].real = Sn[i+M/2-NW/2]*w[i+M/2-NW/2];
|
||||
|
||||
kiss_fft(fft_fwd_cfg, (kiss_fft_cpx *)sw, (kiss_fft_cpx *)Sw);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: two_stage_pitch_refinement
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 27/5/94
|
||||
|
||||
Refines the current pitch estimate using the harmonic sum pitch
|
||||
estimation technique.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void two_stage_pitch_refinement(MODEL *model, COMP Sw[])
|
||||
{
|
||||
float pmin,pmax,pstep; /* pitch refinment minimum, maximum and step */
|
||||
|
||||
/* Coarse refinement */
|
||||
|
||||
pmax = TWO_PI/model->Wo + 5;
|
||||
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)
|
||||
model->Wo = TWO_PI/P_MIN;
|
||||
|
||||
model->L = floor(PI/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)
|
||||
{
|
||||
int m; /* loop variable */
|
||||
int b; /* bin for current harmonic centre */
|
||||
float E; /* energy for current pitch*/
|
||||
float Wo; /* current "test" fundamental freq. */
|
||||
float Wom; /* Wo that maximises E */
|
||||
float Em; /* mamimum energy */
|
||||
float r, one_on_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;
|
||||
one_on_r = 1.0/r;
|
||||
|
||||
/* Determine harmonic sum for a range of Wo values */
|
||||
|
||||
for(p=pmin; p<=pmax; p+=pstep) {
|
||||
E = 0.0;
|
||||
Wo = TWO_PI/p;
|
||||
|
||||
/* Sum harmonic magnitudes */
|
||||
for(m=1; m<=model->L; m++) {
|
||||
b = (int)(m*Wo*one_on_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;
|
||||
}
|
||||
}
|
||||
|
||||
model->Wo = Wom;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
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[], int est_phase)
|
||||
{
|
||||
int i,m; /* loop variables */
|
||||
int am,bm; /* bounds of current harmonic */
|
||||
int b; /* DFT bin of centre of current harmonic */
|
||||
float den; /* denominator of amplitude expression */
|
||||
float r, one_on_r; /* number of rads/bin */
|
||||
int offset;
|
||||
COMP Am;
|
||||
|
||||
r = TWO_PI/FFT_ENC;
|
||||
one_on_r = 1.0/r;
|
||||
|
||||
for(m=1; m<=model->L; m++) {
|
||||
den = 0.0;
|
||||
am = (int)((m - 0.5)*model->Wo*one_on_r + 0.5);
|
||||
bm = (int)((m + 0.5)*model->Wo*one_on_r + 0.5);
|
||||
b = (int)(m*model->Wo/r + 0.5);
|
||||
|
||||
/* Estimate ampltude of harmonic */
|
||||
|
||||
den = 0.0;
|
||||
Am.real = Am.imag = 0.0;
|
||||
offset = FFT_ENC/2 - (int)(m*model->Wo*one_on_r + 0.5);
|
||||
for(i=am; i<bm; i++) {
|
||||
den += Sw[i].real*Sw[i].real + Sw[i].imag*Sw[i].imag;
|
||||
Am.real += Sw[i].real*W[i + offset].real;
|
||||
Am.imag += Sw[i].imag*W[i + offset].real;
|
||||
}
|
||||
|
||||
model->A[m] = sqrtf(den);
|
||||
|
||||
if (est_phase) {
|
||||
|
||||
/* Estimate phase of harmonic, this is expensive in CPU for
|
||||
embedded devicesso we make it an option */
|
||||
|
||||
model->phi[m] = atan2(Sw[b].imag,Sw[b].real);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
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(
|
||||
MODEL *model,
|
||||
COMP Sw[],
|
||||
COMP W[],
|
||||
COMP Sw_[], /* DFT of all voiced synthesised signal */
|
||||
/* useful for debugging/dump file */
|
||||
COMP Ew[]) /* DFT of error */
|
||||
{
|
||||
int i,l,al,bl,m; /* loop variables */
|
||||
COMP Am; /* amplitude sample for this band */
|
||||
int offset; /* centers Hw[] about current harmonic */
|
||||
float den; /* denominator of Am expression */
|
||||
float error; /* accumulated error between original and synthesised */
|
||||
float Wo;
|
||||
float sig, snr;
|
||||
float elow, ehigh, eratio;
|
||||
float sixty;
|
||||
|
||||
sig = 1E-4;
|
||||
for(l=1; l<=model->L/4; l++) {
|
||||
sig += model->A[l]*model->A[l];
|
||||
}
|
||||
for(i=0; i<FFT_ENC; i++) {
|
||||
Sw_[i].real = 0.0;
|
||||
Sw_[i].imag = 0.0;
|
||||
Ew[i].real = 0.0;
|
||||
Ew[i].imag = 0.0;
|
||||
}
|
||||
|
||||
Wo = model->Wo;
|
||||
error = 1E-4;
|
||||
|
||||
/* Just test across the harmonics in the first 1000 Hz (L/4) */
|
||||
|
||||
for(l=1; l<=model->L/4; l++) {
|
||||
Am.real = 0.0;
|
||||
Am.imag = 0.0;
|
||||
den = 0.0;
|
||||
al = ceil((l - 0.5)*Wo*FFT_ENC/TWO_PI);
|
||||
bl = ceil((l + 0.5)*Wo*FFT_ENC/TWO_PI);
|
||||
|
||||
/* Estimate amplitude of harmonic assuming harmonic is totally voiced */
|
||||
|
||||
offset = FFT_ENC/2 - l*Wo*FFT_ENC/TWO_PI + 0.5;
|
||||
for(m=al; m<bl; m++) {
|
||||
Am.real += Sw[m].real*W[offset+m].real;
|
||||
Am.imag += Sw[m].imag*W[offset+m].real;
|
||||
den += W[offset+m].real*W[offset+m].real;
|
||||
}
|
||||
|
||||
Am.real = Am.real/den;
|
||||
Am.imag = Am.imag/den;
|
||||
|
||||
/* Determine error between estimated harmonic and original */
|
||||
|
||||
offset = FFT_ENC/2 - l*Wo*FFT_ENC/TWO_PI + 0.5;
|
||||
for(m=al; m<bl; m++) {
|
||||
Sw_[m].real = Am.real*W[offset+m].real;
|
||||
Sw_[m].imag = Am.imag*W[offset+m].real;
|
||||
Ew[m].real = Sw[m].real - Sw_[m].real;
|
||||
Ew[m].imag = Sw[m].imag - Sw_[m].imag;
|
||||
error += Ew[m].real*Ew[m].real;
|
||||
error += Ew[m].imag*Ew[m].imag;
|
||||
}
|
||||
}
|
||||
|
||||
snr = 10.0*log10f(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 freqency to high frequency energy,
|
||||
voiced speech tends to be dominated by low frequency energy,
|
||||
unvoiced by high frequency. This measure can be used to
|
||||
determine if we have made any gross errors.
|
||||
*/
|
||||
|
||||
elow = ehigh = 1E-4;
|
||||
for(l=1; l<=model->L/2; l++) {
|
||||
elow += model->A[l]*model->A[l];
|
||||
}
|
||||
for(l=model->L/2; l<=model->L; l++) {
|
||||
ehigh += model->A[l]*model->A[l];
|
||||
}
|
||||
eratio = 10.0*log10f(elow/ehigh);
|
||||
|
||||
/* Look for Type 1 errors, strongly V speech that has been
|
||||
accidentally declared UV */
|
||||
|
||||
if (model->voiced == 0)
|
||||
if (eratio > 10.0)
|
||||
model->voiced = 1;
|
||||
|
||||
/* Look for Type 2 errors, strongly UV speech that has been
|
||||
accidentally declared V */
|
||||
|
||||
if (model->voiced == 1) {
|
||||
if (eratio < -10.0)
|
||||
model->voiced = 0;
|
||||
|
||||
/* A common source of Type 2 errors is the pitch estimator
|
||||
gives a low (50Hz) estimate for UV speech, which gives a
|
||||
good match with noise due to the close harmoonic spacing.
|
||||
These errors are much more common than people with 50Hz3
|
||||
pitch, so we have just a small eratio threshold. */
|
||||
|
||||
sixty = 60.0*TWO_PI/FS;
|
||||
if ((eratio < -4.0) && (model->Wo <= sixty))
|
||||
model->voiced = 0;
|
||||
}
|
||||
//printf(" v: %d snr: %f eratio: %3.2f %f\n",model->voiced,snr,eratio,dF0);
|
||||
|
||||
return snr;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: make_synthesis_window
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 11/5/94
|
||||
|
||||
Init function that generates the trapezoidal (Parzen) sythesis window.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void make_synthesis_window(float Pn[])
|
||||
{
|
||||
int i;
|
||||
float win;
|
||||
|
||||
/* Generate Parzen window in time domain */
|
||||
|
||||
win = 0.0;
|
||||
for(i=0; i<N/2-TW; i++)
|
||||
Pn[i] = 0.0;
|
||||
win = 0.0;
|
||||
for(i=N/2-TW; i<N/2+TW; win+=1.0/(2*TW), i++ )
|
||||
Pn[i] = win;
|
||||
for(i=N/2+TW; i<3*N/2-TW; i++)
|
||||
Pn[i] = 1.0;
|
||||
win = 1.0;
|
||||
for(i=3*N/2-TW; i<3*N/2+TW; win-=1.0/(2*TW), i++)
|
||||
Pn[i] = win;
|
||||
for(i=3*N/2+TW; i<2*N; i++)
|
||||
Pn[i] = 0.0;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
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(
|
||||
kiss_fft_cfg fft_inv_cfg,
|
||||
float Sn_[], /* time domain synthesised signal */
|
||||
MODEL *model, /* ptr to model parameters for this frame */
|
||||
float Pn[], /* time domain Parzen window */
|
||||
int shift /* flag used to handle transition frames */
|
||||
)
|
||||
{
|
||||
int i,l,j,b; /* loop variables */
|
||||
COMP Sw_[FFT_DEC]; /* DFT of synthesised signal */
|
||||
COMP sw_[FFT_DEC]; /* synthesised signal */
|
||||
|
||||
if (shift) {
|
||||
/* Update memories */
|
||||
for(i=0; i<N-1; i++) {
|
||||
Sn_[i] = Sn_[i+N];
|
||||
}
|
||||
Sn_[N-1] = 0.0;
|
||||
}
|
||||
|
||||
for(i=0; i<FFT_DEC; i++) {
|
||||
Sw_[i].real = 0.0;
|
||||
Sw_[i].imag = 0.0;
|
||||
}
|
||||
|
||||
/*
|
||||
Nov 2010 - found that synthesis using time domain cos() functions
|
||||
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 related to the quantisation of
|
||||
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
|
||||
sort of amplitude modulation at the frame rate.
|
||||
|
||||
Another possibility is using a larger FFT size (1024 or 2048).
|
||||
*/
|
||||
|
||||
#define FFT_SYNTHESIS
|
||||
#ifdef FFT_SYNTHESIS
|
||||
/* Now set up frequency domain synthesised speech */
|
||||
for(l=1; l<=model->L; l++) {
|
||||
//for(l=model->L/2; l<=model->L; l++) {
|
||||
//for(l=1; l<=model->L/4; l++) {
|
||||
b = (int)(l*model->Wo*FFT_DEC/TWO_PI + 0.5);
|
||||
if (b > ((FFT_DEC/2)-1)) {
|
||||
b = (FFT_DEC/2)-1;
|
||||
}
|
||||
Sw_[b].real = model->A[l]*cosf(model->phi[l]);
|
||||
Sw_[b].imag = model->A[l]*sinf(model->phi[l]);
|
||||
Sw_[FFT_DEC-b].real = Sw_[b].real;
|
||||
Sw_[FFT_DEC-b].imag = -Sw_[b].imag;
|
||||
}
|
||||
|
||||
/* Perform inverse DFT */
|
||||
|
||||
kiss_fft(fft_inv_cfg, (kiss_fft_cpx *)Sw_, (kiss_fft_cpx *)sw_);
|
||||
#else
|
||||
/*
|
||||
Direct time domain synthesis using the cos() function. Works
|
||||
well at 10ms and 20ms frames rates. Note synthesis window is
|
||||
still used to handle overlap-add between adjacent frames. This
|
||||
could be simplified as we don't need to synthesise where Pn[]
|
||||
is zero.
|
||||
*/
|
||||
for(l=1; l<=model->L; l++) {
|
||||
for(i=0,j=-N+1; i<N-1; i++,j++) {
|
||||
Sw_[FFT_DEC-N+1+i].real += 2.0*model->A[l]*cos(j*model->Wo*l + model->phi[l]);
|
||||
}
|
||||
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 */
|
||||
|
||||
for(i=0; i<N-1; i++) {
|
||||
Sn_[i] += sw_[FFT_DEC-N+1+i].real*Pn[i];
|
||||
}
|
||||
|
||||
if (shift)
|
||||
for(i=N-1,j=0; i<2*N; i++,j++)
|
||||
Sn_[i] = sw_[j].real*Pn[i];
|
||||
else
|
||||
for(i=N-1,j=0; i<2*N; i++,j++)
|
||||
Sn_[i] += sw_[j].real*Pn[i];
|
||||
}
|
||||
|
||||
|
||||
static unsigned long next = 1;
|
||||
|
||||
int codec2_rand(void) {
|
||||
next = next * 1103515245 + 12345;
|
||||
return((unsigned)(next/65536) % 32768);
|
||||
}
|
||||
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: sine.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 1/11/94
|
||||
|
||||
Header file for sinusoidal analysis and synthesis functions.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef __SINE__
|
||||
#define __SINE__
|
||||
|
||||
#include "defines.h"
|
||||
#include "comp.h"
|
||||
#include "kiss_fft.h"
|
||||
|
||||
void make_analysis_window(kiss_fft_cfg fft_fwd_cfg, float w[], COMP W[]);
|
||||
float hpf(float x, float states[]);
|
||||
void dft_speech(kiss_fft_cfg fft_fwd_cfg, COMP Sw[], float Sn[], float w[]);
|
||||
void two_stage_pitch_refinement(MODEL *model, COMP Sw[]);
|
||||
void estimate_amplitudes(MODEL *model, COMP Sw[], COMP W[], int est_phase);
|
||||
float est_voicing_mbe(MODEL *model, COMP Sw[], COMP W[], COMP Sw_[],COMP Ew[]);
|
||||
void make_synthesis_window(float Pn[]);
|
||||
void synthesise(kiss_fft_cfg fft_inv_cfg, float Sn_[], MODEL *model, float Pn[], int shift);
|
||||
|
||||
#define CODEC2_RAND_MAX 32767
|
||||
int codec2_rand(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,164 +0,0 @@
|
|||
/* Generated by test_bits_file() Octave function */
|
||||
|
||||
const int test_bits[]={
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1
|
||||
};
|
||||
|
|
@ -1,479 +0,0 @@
|
|||
//==========================================================================
|
||||
// Name: varicode.h
|
||||
// Purpose: Varicode encoded and decode functions
|
||||
// Created: Nov 24, 2012
|
||||
// Authors: David Rowe
|
||||
//
|
||||
// To test:
|
||||
// $ gcc varicode.c -o varicode -DVARICODE_UNITTEST -Wall
|
||||
// $ ./varicode
|
||||
//
|
||||
// License:
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2.1,
|
||||
// as published by the Free Software Foundation. This program is
|
||||
// distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
// License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "varicode.h"
|
||||
#include "varicode_table.h"
|
||||
|
||||
|
||||
/*
|
||||
output is an unpacked array of bits of maximum size max_out. Note
|
||||
unpacked arrays are a more suitable form for modulator input.
|
||||
|
||||
Code 1 covers the entire ASCII char set.
|
||||
*/
|
||||
|
||||
int varicode_encode1(short varicode_out[], char ascii_in[], int max_out, int n_in) {
|
||||
int n_out, index, n_zeros, v_len;
|
||||
unsigned short byte1, byte2, packed;
|
||||
|
||||
n_out = 0;
|
||||
|
||||
while(n_in && (n_out < max_out)) {
|
||||
|
||||
assert((unsigned int)(*ascii_in) < 128);
|
||||
|
||||
index = 2*(unsigned int)(*ascii_in);
|
||||
byte1 = varicode_table1[index];
|
||||
byte2 = varicode_table1[index+1];
|
||||
packed = (byte1 << 8) + byte2;
|
||||
|
||||
//printf("n_in: %d ascii_in: %c index: %d packed 0x%x\n", n_in, *ascii_in, index, packed);
|
||||
ascii_in++;
|
||||
|
||||
n_zeros = 0;
|
||||
v_len = 0;
|
||||
while ((n_zeros < 2) && (n_out < max_out) && (v_len <= VARICODE_MAX_BITS)) {
|
||||
if (packed & 0x8000) {
|
||||
*varicode_out = 1;
|
||||
n_zeros = 0;
|
||||
}
|
||||
else {
|
||||
*varicode_out = 0;
|
||||
n_zeros++;
|
||||
}
|
||||
//printf("packed: 0x%x *varicode_out: %d n_zeros: %d v_len: %d\n", packed, *varicode_out, n_zeros,v_len );
|
||||
packed <<= 1;
|
||||
varicode_out++;
|
||||
n_out++;
|
||||
v_len++;
|
||||
}
|
||||
assert(v_len <= VARICODE_MAX_BITS);
|
||||
|
||||
n_in--;
|
||||
}
|
||||
|
||||
return n_out;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Code 2 covers a subset, but is more efficient that Code 1 (282
|
||||
compared to 1315 bits on unittest) Unsupported characters are
|
||||
replaced by spaces. We encode/decode two bits at a time.
|
||||
*/
|
||||
|
||||
int varicode_encode2(short varicode_out[], char ascii_in[], int max_out, int n_in) {
|
||||
int n_out, n_zeros, v_len, i;
|
||||
unsigned short packed;
|
||||
|
||||
n_out = 0;
|
||||
|
||||
while(n_in && (n_out < max_out)) {
|
||||
|
||||
packed = varicode_table2[0]; // default to space if char not found
|
||||
|
||||
// see if our character exists
|
||||
for(i=0; i<sizeof(varicode_table2); i+=2) {
|
||||
if (varicode_table2[i] == *ascii_in)
|
||||
packed = (unsigned short)varicode_table2[i+1] << 8;
|
||||
}
|
||||
|
||||
//printf("n_in: %d ascii_in: %c index: %d packed 0x%x\n", n_in, *ascii_in, index, packed);
|
||||
ascii_in++;
|
||||
|
||||
n_zeros = 0;
|
||||
v_len = 0;
|
||||
while ((n_zeros < 2) && (n_out < max_out) && (v_len <= VARICODE_MAX_BITS)) {
|
||||
if (packed & 0x8000)
|
||||
varicode_out[0] = 1;
|
||||
else
|
||||
varicode_out[0] = 0;
|
||||
|
||||
if (packed & 0x4000)
|
||||
varicode_out[1] = 1;
|
||||
else
|
||||
varicode_out[1] = 0;
|
||||
|
||||
if (packed & 0xc000)
|
||||
n_zeros = 0;
|
||||
else
|
||||
n_zeros += 2;
|
||||
|
||||
//printf("packed: 0x%x *varicode_out: %d n_zeros: %d v_len: %d\n", packed, *varicode_out, n_zeros,v_len );
|
||||
packed <<= 2;
|
||||
varicode_out +=2;
|
||||
n_out += 2;
|
||||
v_len += 2;
|
||||
}
|
||||
assert(v_len <= VARICODE_MAX_BITS);
|
||||
|
||||
n_in--;
|
||||
}
|
||||
|
||||
assert((n_out % 2) == 0); /* outputs two bits at a time */
|
||||
|
||||
return n_out;
|
||||
}
|
||||
|
||||
|
||||
int varicode_encode(short varicode_out[], char ascii_in[], int max_out, int n_in, int code_num) {
|
||||
|
||||
assert((code_num ==1) || (code_num ==2));
|
||||
|
||||
if (code_num == 1)
|
||||
return varicode_encode1(varicode_out, ascii_in, max_out, n_in);
|
||||
else
|
||||
return varicode_encode2(varicode_out, ascii_in, max_out, n_in);
|
||||
}
|
||||
|
||||
|
||||
void varicode_decode_init(struct VARICODE_DEC *dec_states, int code_num)
|
||||
{
|
||||
assert((code_num ==1) || (code_num == 2));
|
||||
|
||||
dec_states->state = 0;
|
||||
dec_states->n_zeros = 0;
|
||||
dec_states->v_len = 0;
|
||||
dec_states->packed = 0;
|
||||
dec_states->code_num = code_num;
|
||||
dec_states->n_in = 0;
|
||||
dec_states->in[0] = dec_states->in[1] = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Code 1 decode function, accepts one bit at a time */
|
||||
|
||||
static int decode_one_bit(struct VARICODE_DEC *s, char *single_ascii, short varicode_in, int long_code)
|
||||
{
|
||||
int found=0, i;
|
||||
unsigned short byte1, byte2;
|
||||
|
||||
//printf("decode_one_bit : state: %d varicode_in: %d packed: 0x%x n_zeros: %d\n",
|
||||
// s->state, varicode_in, s->packed, s->n_zeros);
|
||||
|
||||
if (s->state == 0) {
|
||||
if (!varicode_in)
|
||||
return 0;
|
||||
else
|
||||
s->state = 1;
|
||||
}
|
||||
|
||||
if (s->state == 1) {
|
||||
if (varicode_in) {
|
||||
s->packed |= (0x8000 >> s->v_len);
|
||||
s->n_zeros = 0;
|
||||
}
|
||||
else {
|
||||
s->n_zeros++;
|
||||
}
|
||||
s->v_len++;
|
||||
found = 0;
|
||||
|
||||
/* end of character code */
|
||||
|
||||
if (s->n_zeros == 2) {
|
||||
if (s->v_len) {
|
||||
/* run thru table but note with bit errors we might not actually find a match */
|
||||
|
||||
byte1 = s->packed >> 8;
|
||||
//printf("looking for byte1 : 0x%x ... ", byte1);
|
||||
byte2 = s->packed & 0xff;
|
||||
|
||||
for(i=0; i<128; i++) {
|
||||
if ((byte1 == varicode_table1[2*i]) && (byte2 == varicode_table1[2*i+1])) {
|
||||
found = 1;
|
||||
*single_ascii = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
varicode_decode_init(s, s->code_num);
|
||||
}
|
||||
|
||||
/* code can run too long if we have a bit error */
|
||||
|
||||
if (s->v_len > VARICODE_MAX_BITS)
|
||||
varicode_decode_init(s, s->code_num);
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
/* Code 2 decode function, accepts two bits at a time */
|
||||
|
||||
static int decode_two_bits(struct VARICODE_DEC *s, char *single_ascii, short varicode_in1, short varicode_in2)
|
||||
{
|
||||
int found=0, i;
|
||||
unsigned short byte1;
|
||||
|
||||
if (s->state == 0) {
|
||||
if (!(varicode_in1 || varicode_in2))
|
||||
return 0;
|
||||
else
|
||||
s->state = 1;
|
||||
}
|
||||
|
||||
if (s->state == 1) {
|
||||
if (varicode_in1)
|
||||
s->packed |= (0x8000 >> s->v_len);
|
||||
if (varicode_in2)
|
||||
s->packed |= (0x4000 >> s->v_len);
|
||||
if (varicode_in1 || varicode_in2)
|
||||
s->n_zeros = 0;
|
||||
else
|
||||
s->n_zeros+=2;
|
||||
|
||||
s->v_len+=2;
|
||||
|
||||
found = 0;
|
||||
|
||||
/* end of character code */
|
||||
|
||||
if (s->n_zeros == 2) {
|
||||
if (s->v_len) {
|
||||
/* run thru table but note with bit errors we might not actually find a match */
|
||||
|
||||
byte1 = s->packed >> 8;
|
||||
//printf("looking for byte1 : 0x%x ... ", byte1);
|
||||
for(i=0; i<sizeof(varicode_table2); i+=2) {
|
||||
//printf("byte1: 0x%x 0x%x\n", byte1, (unsigned char)varicode_table2[i+1]);
|
||||
if (byte1 == (unsigned char)varicode_table2[i+1]) {
|
||||
found = 1;
|
||||
*single_ascii = varicode_table2[i];
|
||||
//printf("found: %d i=%d char=%c ", found, i, *single_ascii);
|
||||
}
|
||||
}
|
||||
}
|
||||
varicode_decode_init(s, s->code_num);
|
||||
}
|
||||
|
||||
/* code can run too long if we have a bit error */
|
||||
|
||||
if (s->v_len > VARICODE_MAX_BITS)
|
||||
varicode_decode_init(s, s->code_num);
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
int varicode_decode1(struct VARICODE_DEC *dec_states, char ascii_out[], short varicode_in[], int max_out, int n_in) {
|
||||
int output, n_out;
|
||||
char single_ascii = 0;
|
||||
|
||||
n_out = 0;
|
||||
|
||||
//printf("varicode_decode: n_in: %d\n", n_in);
|
||||
|
||||
while(n_in && (n_out < max_out)) {
|
||||
output = decode_one_bit(dec_states, &single_ascii, varicode_in[0], 0);
|
||||
varicode_in++;
|
||||
n_in--;
|
||||
|
||||
if (output) {
|
||||
*ascii_out++ = single_ascii;
|
||||
n_out++;
|
||||
}
|
||||
}
|
||||
|
||||
return n_out;
|
||||
}
|
||||
|
||||
|
||||
int varicode_decode2(struct VARICODE_DEC *dec_states, char ascii_out[], short varicode_in[], int max_out, int n_in) {
|
||||
int output, n_out;
|
||||
char single_ascii = 0;
|
||||
|
||||
n_out = 0;
|
||||
|
||||
//printf("varicode_decode2: n_in: %d varicode_in[0] %d dec_states->n_in: %d\n", n_in, varicode_in[0], dec_states->n_in);
|
||||
//printf("%d ", varicode_in[0]);
|
||||
while(n_in && (n_out < max_out)) {
|
||||
|
||||
// keep two bit buffer so we can process two at a time
|
||||
|
||||
dec_states->in[0] = dec_states->in[1];
|
||||
dec_states->in[1] = varicode_in[0];
|
||||
dec_states->n_in++;
|
||||
varicode_in++;
|
||||
n_in--;
|
||||
|
||||
if (dec_states->n_in == 2) {
|
||||
output = decode_two_bits(dec_states, &single_ascii, dec_states->in[0], dec_states->in[1]);
|
||||
|
||||
dec_states->n_in = 0;
|
||||
|
||||
if (output) {
|
||||
//printf(" output: %d single_ascii: 0x%x %c\n", output, (int)single_ascii, single_ascii);
|
||||
*ascii_out++ = single_ascii;
|
||||
n_out++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return n_out;
|
||||
}
|
||||
|
||||
|
||||
int varicode_decode(struct VARICODE_DEC *dec_states, char ascii_out[], short varicode_in[], int max_out, int n_in) {
|
||||
if (dec_states->code_num == 1)
|
||||
return varicode_decode1(dec_states, ascii_out, varicode_in, max_out, n_in);
|
||||
else
|
||||
return varicode_decode2(dec_states, ascii_out, varicode_in, max_out, n_in);
|
||||
}
|
||||
|
||||
|
||||
#ifdef VARICODE_UNITTEST
|
||||
void test_varicode(int code_num) {
|
||||
char *ascii_in;
|
||||
short *varicode;
|
||||
int i, n_varicode_bits_out, n_ascii_chars_out, length, half, n_out, j, len;
|
||||
char *ascii_out;
|
||||
struct VARICODE_DEC dec_states;
|
||||
|
||||
if (code_num == 1) {
|
||||
printf("long code:\n");
|
||||
length = sizeof(varicode_table1)/2;
|
||||
}
|
||||
else {
|
||||
printf("short code:\n");
|
||||
length = sizeof(varicode_table2)/2;
|
||||
}
|
||||
//length = 10;
|
||||
ascii_in = (char*)malloc(length);
|
||||
varicode = (short*)malloc(VARICODE_MAX_BITS*sizeof(short)*length);
|
||||
ascii_out = (char*)malloc(length);
|
||||
|
||||
// 1. test all Varicode codes -------------------------------------------------------------
|
||||
|
||||
if (code_num == 1) {
|
||||
for(i=0; i<length; i++)
|
||||
ascii_in[i] = (char)i;
|
||||
}
|
||||
else {
|
||||
for(i=0; i<length; i++)
|
||||
ascii_in[i] = varicode_table2[2*i];
|
||||
}
|
||||
//printf(" ascii_in: %s\n", ascii_in);
|
||||
n_varicode_bits_out = varicode_encode(varicode, ascii_in, VARICODE_MAX_BITS*length, length, code_num);
|
||||
|
||||
printf(" n_varicode_bits_out: %d\n", n_varicode_bits_out);
|
||||
//for(i=0; i<n_varicode_bits_out; i++) {
|
||||
// printf("%d \n", varicode[i]);
|
||||
//}
|
||||
|
||||
// split decode in half to test how it preserves state between calls
|
||||
|
||||
varicode_decode_init(&dec_states, code_num);
|
||||
half = n_varicode_bits_out/2;
|
||||
n_ascii_chars_out = varicode_decode(&dec_states, ascii_out, varicode, length, half);
|
||||
// printf(" n_ascii_chars_out: %d\n", n_ascii_chars_out);
|
||||
|
||||
n_ascii_chars_out += varicode_decode(&dec_states, &ascii_out[n_ascii_chars_out],
|
||||
&varicode[half], length-n_ascii_chars_out, n_varicode_bits_out - half);
|
||||
assert(n_ascii_chars_out == length);
|
||||
|
||||
printf(" n_ascii_chars_out: %d\n", n_ascii_chars_out);
|
||||
printf(" average bits/character: %3.2f\n", (float)n_varicode_bits_out/n_ascii_chars_out);
|
||||
|
||||
//printf("ascii_out: %s\n", ascii_out);
|
||||
|
||||
if (memcmp(ascii_in, ascii_out, length) == 0)
|
||||
printf(" Test 1 Pass\n");
|
||||
else
|
||||
printf(" Test 1 Fail\n");
|
||||
|
||||
// 2. Test some ascii with a run of zeros -----------------------------------------------------
|
||||
|
||||
sprintf(ascii_in, "CQ CQ CQ this is VK5DGR");
|
||||
|
||||
assert(strlen(ascii_in) < length);
|
||||
if (code_num == 2)
|
||||
for(i=0; i<strlen(ascii_in); i++)
|
||||
ascii_in[i] = tolower(ascii_in[i]);
|
||||
|
||||
for(i=0; i<3; i++) {
|
||||
n_varicode_bits_out = varicode_encode(varicode, ascii_in, VARICODE_MAX_BITS*length, strlen(ascii_in), code_num);
|
||||
n_ascii_chars_out = varicode_decode(&dec_states, ascii_out, varicode, length, n_varicode_bits_out);
|
||||
ascii_out[n_ascii_chars_out] = 0;
|
||||
|
||||
printf(" ascii_out: %s\n", ascii_out);
|
||||
if (strcmp(ascii_in, ascii_out) == 0)
|
||||
printf(" Test 2 Pass\n");
|
||||
else
|
||||
printf(" Test 2 Fail\n");
|
||||
|
||||
memset(varicode, 0, sizeof(short)*20);
|
||||
n_ascii_chars_out = varicode_decode(&dec_states, ascii_out, varicode, length, 20);
|
||||
assert(n_ascii_chars_out == 0);
|
||||
}
|
||||
|
||||
// 3. Test receiving one bit at a time -----------------------------------------------------
|
||||
|
||||
sprintf(ascii_in, "s=vk5dgr qth=adelaide");
|
||||
len = strlen(ascii_in);
|
||||
ascii_in[len] = 13;
|
||||
ascii_in[len+1] = 0;
|
||||
|
||||
assert(strlen(ascii_in) < length);
|
||||
if (code_num == 2)
|
||||
for(i=0; i<strlen(ascii_in); i++)
|
||||
ascii_in[i] = tolower(ascii_in[i]);
|
||||
|
||||
for(i=0; i<3; i++) {
|
||||
n_varicode_bits_out = varicode_encode(varicode, ascii_in, VARICODE_MAX_BITS*length, strlen(ascii_in), code_num);
|
||||
printf("n_varicode_bits_out: %d\n", n_varicode_bits_out);
|
||||
|
||||
n_ascii_chars_out = 0;
|
||||
for(j=0; j<n_varicode_bits_out; j++) {
|
||||
n_out = varicode_decode(&dec_states, &ascii_out[n_ascii_chars_out], &varicode[j], 1, 1);
|
||||
if (n_out)
|
||||
n_ascii_chars_out++;
|
||||
}
|
||||
ascii_out[n_ascii_chars_out] = 0;
|
||||
|
||||
printf(" ascii_out: %s\n", ascii_out);
|
||||
if (strcmp(ascii_in, ascii_out) == 0)
|
||||
printf(" Test 3 Pass\n");
|
||||
else
|
||||
printf(" Test 3 Fail\n");
|
||||
}
|
||||
|
||||
free(ascii_in);
|
||||
free(ascii_out);
|
||||
free(varicode);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
test_varicode(1);
|
||||
test_varicode(2);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
//==========================================================================
|
||||
// Name: varicode.h
|
||||
// Purpose: Varicode encoded and decode functions
|
||||
// Created: Nov 24, 2012
|
||||
// Authors: David Rowe
|
||||
//
|
||||
// License:
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2.1,
|
||||
// as published by the Free Software Foundation. This program is
|
||||
// distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
// License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
#ifndef __VARICODE__
|
||||
#define __VARICODE__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
#endif
|
||||
|
||||
#define VARICODE_MAX_BITS (10+2) /* max varicode bits for each ascii character */
|
||||
/* 10 bits for code plus 2 0 bits for inter-character space */
|
||||
|
||||
struct VARICODE_DEC {
|
||||
int state;
|
||||
int n_zeros;
|
||||
int v_len;
|
||||
unsigned short packed;
|
||||
int code_num;
|
||||
int n_in;
|
||||
int in[2];
|
||||
};
|
||||
|
||||
int varicode_encode(short varicode_out[], char ascii_in[], int max_out, int n_in, int code_num);
|
||||
void varicode_decode_init(struct VARICODE_DEC *dec_states, int code_num);
|
||||
int varicode_decode(struct VARICODE_DEC *dec_states, char ascii_out[], short varicode_in[], int max_out, int n_in);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,338 +0,0 @@
|
|||
//==========================================================================
|
||||
// Name: varicode_table.h
|
||||
// Purpose: Varicode look up table
|
||||
// Created: Nov 24, 2012
|
||||
// Authors: Clint Turner, KA7OEI, Peter Martinez, G3PLX
|
||||
//
|
||||
// License:
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2.1,
|
||||
// as published by the Free Software Foundation. This program is
|
||||
// distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
// License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
/* The following table defines the PKS31 varicode. There are 128 entries,
|
||||
corresponding to ASCII characters 0-127 with two bytes for each entry. The bits
|
||||
for the varicode are to be shifted out MSB-first for both bytes, with the first byte
|
||||
in the table being the first one to be sent.
|
||||
|
||||
More than one zero in sequence signifies the end of the character (i.e.
|
||||
two zeroes are the intercharacter sequence, so at least two zeroes should always be
|
||||
sent before the next character is sent.
|
||||
|
||||
This file is constructed with information from the article "PSK31 Fundamentals"
|
||||
by Peter Martinez, G3PLX by Clint Turner, KA7OEI
|
||||
*/
|
||||
unsigned char const varicode_table1[256] = {
|
||||
0b10101010,
|
||||
0b11000000, // 0 NUL
|
||||
0b10110110,
|
||||
0b11000000, // 1 SOH
|
||||
0b10111011,
|
||||
0b01000000, // 2 STX
|
||||
0b11011101,
|
||||
0b11000000, // 3 ETX
|
||||
0b10111010,
|
||||
0b11000000, // 4 EOT
|
||||
0b11010111,
|
||||
0b11000000, // 5 ENQ
|
||||
0b10111011,
|
||||
0b11000000, // 6 ACK
|
||||
0b10111111,
|
||||
0b01000000, // 7 BEL
|
||||
0b10111111,
|
||||
0b11000000, // 8 BS
|
||||
0b11101111,
|
||||
0b00000000, // 9 HT
|
||||
0b11101000,
|
||||
0b00000000, // 10 LF
|
||||
0b11011011,
|
||||
0b11000000, // 11 VT
|
||||
0b10110111,
|
||||
0b01000000, // 12 FF
|
||||
0b11111000,
|
||||
0b00000000, // 13 CR
|
||||
0b11011101,
|
||||
0b01000000, // 14 SO
|
||||
0b11101010,
|
||||
0b11000000, // 15 SI
|
||||
0b10111101,
|
||||
0b11000000, // 16 DLE
|
||||
0b10111101,
|
||||
0b01000000, // 17 DC1
|
||||
0b11101011,
|
||||
0b01000000, // 18 DC2
|
||||
0b11101011,
|
||||
0b11000000, // 19 DC3
|
||||
0b11010110,
|
||||
0b11000000, // 20 DC4
|
||||
0b11011010,
|
||||
0b11000000, // 21 NAK
|
||||
0b11011011,
|
||||
0b01000000, // 22 SYN
|
||||
0b11010101,
|
||||
0b11000000, // 23 ETB
|
||||
0b11011110,
|
||||
0b11000000, // 24 CAN
|
||||
0b11011111,
|
||||
0b01000000, // 25 EM
|
||||
0b11101101,
|
||||
0b11000000, // 26 SUB
|
||||
0b11010101,
|
||||
0b01000000, // 27 ESC
|
||||
0b11010111,
|
||||
0b01000000, // 28 FS
|
||||
0b11101110,
|
||||
0b11000000, // 29 GS
|
||||
0b10111110,
|
||||
0b11000000, // 30 RS
|
||||
0b11011111,
|
||||
0b11000000, // 31 US
|
||||
0b10000000,
|
||||
0b00000000, // 32 SP
|
||||
0b11111111,
|
||||
0b10000000, // 33 !
|
||||
0b10101111,
|
||||
0b10000000, // 34 "
|
||||
0b11111010,
|
||||
0b10000000, // 35 #
|
||||
0b11101101,
|
||||
0b10000000, // 36 $
|
||||
0b10110101,
|
||||
0b01000000, // 37 %
|
||||
0b10101110,
|
||||
0b11000000, // 38 &
|
||||
0b10111111,
|
||||
0b10000000, // 39 '
|
||||
0b11111011,
|
||||
0b00000000, // 40 (
|
||||
0b11110111,
|
||||
0b00000000, // 41 )
|
||||
0b10110111,
|
||||
0b10000000, // 42 *
|
||||
0b11101111,
|
||||
0b10000000, // 43 +
|
||||
0b11101010,
|
||||
0b00000000, // 44 ,
|
||||
0b11010100,
|
||||
0b00000000, // 45 -
|
||||
0b10101110,
|
||||
0b00000000, // 46 .
|
||||
0b11010111,
|
||||
0b10000000, // 47 /
|
||||
0b10110111,
|
||||
0b00000000, // 48 0
|
||||
0b10111101,
|
||||
0b00000000, // 49 1
|
||||
0b11101101,
|
||||
0b00000000, // 50 2
|
||||
0b11111111,
|
||||
0b00000000, // 51 3
|
||||
0b10111011,
|
||||
0b10000000, // 52 4
|
||||
0b10101101,
|
||||
0b10000000, // 53 5
|
||||
0b10110101,
|
||||
0b10000000, // 54 6
|
||||
0b11010110,
|
||||
0b10000000, // 55 7
|
||||
0b11010101,
|
||||
0b10000000, // 56 8
|
||||
0b11011011,
|
||||
0b10000000, // 57 9
|
||||
0b11110101,
|
||||
0b00000000, // 58 :
|
||||
0b11011110,
|
||||
0b10000000, // 59 ;
|
||||
0b11110110,
|
||||
0b10000000, // 60 <
|
||||
0b10101010,
|
||||
0b00000000, // 61 =
|
||||
0b11101011,
|
||||
0b10000000, // 62 >
|
||||
0b10101011,
|
||||
0b11000000, // 63 ?
|
||||
0b10101111,
|
||||
0b01000000, // 64 @
|
||||
0b11111010,
|
||||
0b00000000, // 65 A
|
||||
0b11101011,
|
||||
0b00000000, // 66 B
|
||||
0b10101101,
|
||||
0b00000000, // 67 C
|
||||
0b10110101,
|
||||
0b00000000, // 68 D
|
||||
0b11101110,
|
||||
0b00000000, // 69 E
|
||||
0b11011011,
|
||||
0b00000000, // 70 F
|
||||
0b11111101,
|
||||
0b00000000, // 71 G
|
||||
0b10101010,
|
||||
0b10000000, // 72 H
|
||||
0b11111110,
|
||||
0b00000000, // 73 I
|
||||
0b11111110,
|
||||
0b10000000, // 74 J
|
||||
0b10111110,
|
||||
0b10000000, // 75 K
|
||||
0b11010111,
|
||||
0b00000000, // 76 L
|
||||
0b10111011,
|
||||
0b00000000, // 77 M
|
||||
0b11011101,
|
||||
0b00000000, // 78 N
|
||||
0b10101011,
|
||||
0b00000000, // 79 O
|
||||
0b11010101,
|
||||
0b00000000, // 80 P
|
||||
0b11101110,
|
||||
0b10000000, // 81 Q
|
||||
0b10101111,
|
||||
0b00000000, // 82 R
|
||||
0b11011110,
|
||||
0b00000000, // 83 S
|
||||
0b11011010,
|
||||
0b00000000, // 84 T
|
||||
0b10101011,
|
||||
0b10000000, // 85 U
|
||||
0b11011010,
|
||||
0b10000000, // 86 V
|
||||
0b10101110,
|
||||
0b10000000, // 87 W
|
||||
0b10111010,
|
||||
0b10000000, // 88 X
|
||||
0b10111101,
|
||||
0b10000000, // 89 Y
|
||||
0b10101011,
|
||||
0b01000000, // 90 Z
|
||||
0b11111011,
|
||||
0b10000000, // 91 [
|
||||
0b11110111,
|
||||
0b10000000, // 92 "\"
|
||||
0b11111101,
|
||||
0b10000000, // 93 ]
|
||||
0b10101111,
|
||||
0b11000000, // 94 ^
|
||||
0b10110110,
|
||||
0b10000000, // 95 _ (underline)
|
||||
0b10110111,
|
||||
0b11000000, // 96 `
|
||||
0b10110000,
|
||||
0b00000000, // 97 a
|
||||
0b10111110,
|
||||
0b00000000, // 98 b
|
||||
0b10111100,
|
||||
0b00000000, // 99 c
|
||||
0b10110100,
|
||||
0b00000000, // 100 d
|
||||
0b11000000,
|
||||
0b00000000, // 101 e
|
||||
0b11110100,
|
||||
0b00000000, // 102 f
|
||||
0b10110110,
|
||||
0b00000000, // 103 g
|
||||
0b10101100,
|
||||
0b00000000, // 104 h
|
||||
0b11010000,
|
||||
0b00000000, // 105 i
|
||||
0b11110101,
|
||||
0b10000000, // 106 j
|
||||
0b10111111,
|
||||
0b00000000, // 107 k
|
||||
0b11011000,
|
||||
0b00000000, // 108 l
|
||||
0b11101100,
|
||||
0b00000000, // 109 m
|
||||
0b11110000,
|
||||
0b00000000, // 110 n
|
||||
0b11100000,
|
||||
0b00000000, // 111 o
|
||||
0b11111100,
|
||||
0b00000000, // 112 p
|
||||
0b11011111,
|
||||
0b10000000, // 113 q
|
||||
0b10101000,
|
||||
0b00000000, // 114 r
|
||||
0b10111000,
|
||||
0b00000000, // 115 s
|
||||
0b10100000,
|
||||
0b00000000, // 116 t
|
||||
0b11011100,
|
||||
0b00000000, // 117 u
|
||||
0b11110110,
|
||||
0b00000000, // 118 v
|
||||
0b11010110,
|
||||
0b00000000, // 119 w
|
||||
0b11011111,
|
||||
0b00000000, // 120 x
|
||||
0b10111010,
|
||||
0b00000000, // 121 y
|
||||
0b11101010,
|
||||
0b10000000, // 122 z
|
||||
0b10101101,
|
||||
0b11000000, // 123 {
|
||||
0b11011101,
|
||||
0b10000000, // 124 |
|
||||
0b10101101,
|
||||
0b01000000, // 125 }
|
||||
0b10110101,
|
||||
0b11000000, // 126 ~
|
||||
0b11101101,
|
||||
0b01000000, // 127 (del)
|
||||
};
|
||||
|
||||
// This code was used on FDMDV version 1, and is more compact that Code 1, but only covers a subset
|
||||
// of the ASCII cahacter set
|
||||
|
||||
char const varicode_table2[] = {
|
||||
|
||||
' ' ,0b11000000,
|
||||
13 ,0b01000000, // CR, end of message
|
||||
'=' ,0b10000000,
|
||||
'1' ,0b11110000,
|
||||
'2' ,0b01110000,
|
||||
'3' ,0b10110000,
|
||||
'4' ,0b11010000,
|
||||
'5' ,0b01010000,
|
||||
'6' ,0b10010000,
|
||||
'7' ,0b11100000,
|
||||
'8' ,0b01100000,
|
||||
'9' ,0b10100000,
|
||||
'a' ,0b11111100,
|
||||
'b' ,0b01111100,
|
||||
'c' ,0b10111100,
|
||||
'd' ,0b11011100,
|
||||
'e' ,0b01011100,
|
||||
'f' ,0b10011100,
|
||||
'g' ,0b11101100,
|
||||
'h' ,0b01101100,
|
||||
'i' ,0b10101100,
|
||||
'j' ,0b11110100,
|
||||
'k' ,0b01110100,
|
||||
'l' ,0b10110100,
|
||||
'm' ,0b11010100,
|
||||
'n' ,0b01010100,
|
||||
'o' ,0b10010100,
|
||||
'p' ,0b11100100,
|
||||
'q' ,0b01100100,
|
||||
'r' ,0b10100100,
|
||||
's' ,0b11111000,
|
||||
't' ,0b01111000,
|
||||
'u' ,0b10111000,
|
||||
'v' ,0b11011000,
|
||||
'w' ,0b01011000,
|
||||
'x' ,0b10011000,
|
||||
'y' ,0b11101000,
|
||||
'z' ,0b01101000,
|
||||
'0' ,0b10101000
|
||||
};
|
||||
|
||||
Loading…
Reference in a new issue