diff options
| author | erdgeist@erdgeist.org <erdgeist@bauklotz.fritz.box> | 2019-07-04 23:26:09 +0200 |
|---|---|---|
| committer | erdgeist@erdgeist.org <erdgeist@bauklotz.fritz.box> | 2019-07-04 23:26:09 +0200 |
| commit | f02dfce6e6c34b3d8a7b8a0e784b506178e331fa (patch) | |
| tree | 45556e6104242d4702689760433d7321ae74ec17 /defines.h | |
stripdown of version 0.9
Diffstat (limited to 'defines.h')
| -rw-r--r-- | defines.h | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/defines.h b/defines.h new file mode 100644 index 0000000..dcd1841 --- /dev/null +++ b/defines.h | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | /*---------------------------------------------------------------------------*\ | ||
| 2 | |||
| 3 | FILE........: defines.h | ||
| 4 | AUTHOR......: David Rowe | ||
| 5 | DATE CREATED: 23/4/93 | ||
| 6 | |||
| 7 | Defines and structures used throughout the codec. | ||
| 8 | |||
| 9 | \*---------------------------------------------------------------------------*/ | ||
| 10 | |||
| 11 | /* | ||
| 12 | Copyright (C) 2009 David Rowe | ||
| 13 | |||
| 14 | All rights reserved. | ||
| 15 | |||
| 16 | This program is free software; you can redistribute it and/or modify | ||
| 17 | it under the terms of the GNU Lesser General Public License version 2.1, as | ||
| 18 | published by the Free Software Foundation. This program is | ||
| 19 | distributed in the hope that it will be useful, but WITHOUT ANY | ||
| 20 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 21 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | ||
| 22 | License for more details. | ||
| 23 | |||
| 24 | You should have received a copy of the GNU Lesser General Public License | ||
| 25 | along with this program; if not, see <http://www.gnu.org/licenses/>. | ||
| 26 | */ | ||
| 27 | |||
| 28 | #ifndef __DEFINES__ | ||
| 29 | #define __DEFINES__ | ||
| 30 | |||
| 31 | /*---------------------------------------------------------------------------*\ | ||
| 32 | |||
| 33 | DEFINES | ||
| 34 | |||
| 35 | \*---------------------------------------------------------------------------*/ | ||
| 36 | |||
| 37 | /* General defines */ | ||
| 38 | |||
| 39 | #define N_S 0.01 /* internal proc frame length in secs */ | ||
| 40 | #define TW_S 0.005 /* trapezoidal synth window overlap */ | ||
| 41 | #define MAX_AMP 160 /* maximum number of harmonics */ | ||
| 42 | #ifndef PI | ||
| 43 | #define PI 3.141592654 /* mathematical constant */ | ||
| 44 | #endif | ||
| 45 | #define TWO_PI 6.283185307 /* mathematical constant */ | ||
| 46 | #define MAX_STR 2048 /* maximum string size */ | ||
| 47 | |||
| 48 | #define FFT_ENC 512 /* size of FFT used for encoder */ | ||
| 49 | #define FFT_DEC 512 /* size of FFT used in decoder */ | ||
| 50 | #define V_THRESH 6.0 /* voicing threshold in dB */ | ||
| 51 | #define LPC_ORD 10 /* LPC order */ | ||
| 52 | #define LPC_ORD_LOW 6 /* LPC order for lower rates */ | ||
| 53 | |||
| 54 | /* Pitch estimation defines */ | ||
| 55 | |||
| 56 | #define M_PITCH_S 0.0400 /* pitch analysis window in s */ | ||
| 57 | #define P_MIN_S 0.0025 /* minimum pitch period in s */ | ||
| 58 | #define P_MAX_S 0.0200 /* maximum pitch period in s */ | ||
| 59 | |||
| 60 | /*---------------------------------------------------------------------------*\ | ||
| 61 | |||
| 62 | TYPEDEFS | ||
| 63 | |||
| 64 | \*---------------------------------------------------------------------------*/ | ||
| 65 | |||
| 66 | /* Structure to hold constants calculated at run time based on sample rate */ | ||
| 67 | |||
| 68 | typedef struct { | ||
| 69 | int Fs; /* sample rate of this instance */ | ||
| 70 | int n_samp; /* number of samples per 10ms frame at Fs */ | ||
| 71 | int max_amp; /* maximum number of harmonics */ | ||
| 72 | int m_pitch; /* pitch estimation window size in samples */ | ||
| 73 | int p_min; /* minimum pitch period in samples */ | ||
| 74 | int p_max; /* maximum pitch period in samples */ | ||
| 75 | float Wo_min; | ||
| 76 | float Wo_max; | ||
| 77 | int nw; /* analysis window size in samples */ | ||
| 78 | int tw; /* trapezoidal synthesis window overlap */ | ||
| 79 | } C2CONST; | ||
| 80 | |||
| 81 | /* Structure to hold model parameters for one frame */ | ||
| 82 | |||
| 83 | typedef struct { | ||
| 84 | float Wo; /* fundamental frequency estimate in radians */ | ||
| 85 | int L; /* number of harmonics */ | ||
| 86 | float A[MAX_AMP+1]; /* amplitiude of each harmonic */ | ||
| 87 | float phi[MAX_AMP+1]; /* phase of each harmonic */ | ||
| 88 | int voiced; /* non-zero if this frame is voiced */ | ||
| 89 | } MODEL; | ||
| 90 | |||
| 91 | /* describes each codebook */ | ||
| 92 | |||
| 93 | struct lsp_codebook { | ||
| 94 | int k; /* dimension of vector */ | ||
| 95 | int log2m; /* number of bits in m */ | ||
| 96 | int m; /* elements in codebook */ | ||
| 97 | #ifdef __EMBEDDED /* make sure stored in flash */ | ||
| 98 | const float *cb; /* The elements */ | ||
| 99 | #else | ||
| 100 | float *cb; /* The elements */ | ||
| 101 | #endif | ||
| 102 | }; | ||
| 103 | |||
| 104 | extern const struct lsp_codebook lsp_cb[]; | ||
| 105 | extern const struct lsp_codebook lsp_cbd[]; | ||
| 106 | extern const struct lsp_codebook lsp_cbvq[]; | ||
| 107 | extern const struct lsp_codebook lsp_cbjnd[]; | ||
| 108 | extern const struct lsp_codebook lsp_cbdt[]; | ||
| 109 | extern const struct lsp_codebook lsp_cbjvm[]; | ||
| 110 | extern const struct lsp_codebook lsp_cbvqanssi[]; | ||
| 111 | extern const struct lsp_codebook mel_cb[]; | ||
| 112 | extern const struct lsp_codebook ge_cb[]; | ||
| 113 | extern const struct lsp_codebook lspmelvq_cb[]; | ||
| 114 | extern const struct lsp_codebook newamp1vq_cb[]; | ||
| 115 | extern const struct lsp_codebook newamp1_energy_cb[]; | ||
| 116 | extern const struct lsp_codebook newamp2vq_cb[]; | ||
| 117 | extern const struct lsp_codebook newamp2_energy_cb[]; | ||
| 118 | |||
| 119 | #ifdef _GNU_SOURCE | ||
| 120 | #define POW10F(x) exp10f((x)) | ||
| 121 | #else | ||
| 122 | #define POW10F(x) expf(2.302585092994046f*(x)) | ||
| 123 | #endif | ||
| 124 | |||
| 125 | #endif | ||
