diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2025-08-15 12:42:40 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2025-08-15 12:42:40 +0200 |
| commit | 30325d24d107dbf133da39f7c96d1510fd1c9449 (patch) | |
| tree | 932baa5b2a4475821f16dccf9e3e05011daa6d92 /defines.h | |
| parent | 9022d768021bbe15c7815cc6f8b64218b46f0e10 (diff) | |
Bump to codec2 version 1.2.0erdgeist-bump-to-1.2.0
Diffstat (limited to 'defines.h')
| -rw-r--r-- | defines.h | 89 |
1 files changed, 43 insertions, 46 deletions
| @@ -30,96 +30,93 @@ | |||
| 30 | 30 | ||
| 31 | /*---------------------------------------------------------------------------*\ | 31 | /*---------------------------------------------------------------------------*\ |
| 32 | 32 | ||
| 33 | DEFINES | 33 | DEFINES |
| 34 | 34 | ||
| 35 | \*---------------------------------------------------------------------------*/ | 35 | \*---------------------------------------------------------------------------*/ |
| 36 | 36 | ||
| 37 | /* General defines */ | 37 | /* General defines */ |
| 38 | 38 | ||
| 39 | #define N_S 0.01 /* internal proc frame length in secs */ | 39 | #define N_S 0.01 /* internal proc frame length in secs */ |
| 40 | #define TW_S 0.005 /* trapezoidal synth window overlap */ | 40 | #define TW_S 0.005 /* trapezoidal synth window overlap */ |
| 41 | #define MAX_AMP 160 /* maximum number of harmonics */ | 41 | #define MAX_AMP 160 /* maximum number of harmonics */ |
| 42 | #ifndef PI | 42 | #ifndef PI |
| 43 | #define PI 3.141592654 /* mathematical constant */ | 43 | #define PI 3.141592654 /* mathematical constant */ |
| 44 | #endif | 44 | #endif |
| 45 | #define TWO_PI 6.283185307 /* mathematical constant */ | 45 | #ifndef M_PI |
| 46 | #define MAX_STR 2048 /* maximum string size */ | 46 | #define M_PI 3.14159265358979323846f |
| 47 | #endif | ||
| 48 | #define TWO_PI 6.283185307 /* mathematical constant */ | ||
| 49 | #define MAX_STR 2048 /* maximum string size */ | ||
| 47 | 50 | ||
| 48 | #define FFT_ENC 512 /* size of FFT used for encoder */ | 51 | #define FFT_ENC 512 /* size of FFT used for encoder */ |
| 49 | #define FFT_DEC 512 /* size of FFT used in decoder */ | 52 | #define FFT_DEC 512 /* size of FFT used in decoder */ |
| 50 | #define V_THRESH 6.0 /* voicing threshold in dB */ | 53 | #define V_THRESH 6.0 /* voicing threshold in dB */ |
| 51 | #define LPC_ORD 10 /* LPC order */ | 54 | #define LPC_ORD 10 /* LPC order */ |
| 52 | #define LPC_ORD_LOW 6 /* LPC order for lower rates */ | 55 | #define LPC_ORD_LOW 6 /* LPC order for lower rates */ |
| 53 | 56 | ||
| 54 | /* Pitch estimation defines */ | 57 | /* Pitch estimation defines */ |
| 55 | 58 | ||
| 56 | #define M_PITCH_S 0.0400 /* pitch analysis window in s */ | 59 | #define M_PITCH_S 0.0400 /* pitch analysis window in s */ |
| 57 | #define P_MIN_S 0.0025 /* minimum pitch period in s */ | 60 | #define P_MIN_S 0.0025 /* minimum pitch period in s */ |
| 58 | #define P_MAX_S 0.0200 /* maximum pitch period in s */ | 61 | #define P_MAX_S 0.0200 /* maximum pitch period in s */ |
| 59 | 62 | ||
| 60 | /*---------------------------------------------------------------------------*\ | 63 | /*---------------------------------------------------------------------------*\ |
| 61 | 64 | ||
| 62 | TYPEDEFS | 65 | TYPEDEFS |
| 63 | 66 | ||
| 64 | \*---------------------------------------------------------------------------*/ | 67 | \*---------------------------------------------------------------------------*/ |
| 65 | 68 | ||
| 66 | /* Structure to hold constants calculated at run time based on sample rate */ | 69 | /* Structure to hold constants calculated at run time based on sample rate */ |
| 67 | 70 | ||
| 68 | typedef struct { | 71 | typedef struct { |
| 69 | int Fs; /* sample rate of this instance */ | 72 | int Fs; /* sample rate of this instance */ |
| 70 | int n_samp; /* number of samples per 10ms frame at Fs */ | 73 | int n_samp; /* number of samples per 10ms frame at Fs */ |
| 71 | int max_amp; /* maximum number of harmonics */ | 74 | int max_amp; /* maximum number of harmonics */ |
| 72 | int m_pitch; /* pitch estimation window size in samples */ | 75 | int m_pitch; /* pitch estimation window size in samples */ |
| 73 | int p_min; /* minimum pitch period in samples */ | 76 | int p_min; /* minimum pitch period in samples */ |
| 74 | int p_max; /* maximum pitch period in samples */ | 77 | int p_max; /* maximum pitch period in samples */ |
| 75 | float Wo_min; | 78 | float Wo_min; |
| 76 | float Wo_max; | 79 | float Wo_max; |
| 77 | int nw; /* analysis window size in samples */ | 80 | int nw; /* analysis window size in samples */ |
| 78 | int tw; /* trapezoidal synthesis window overlap */ | 81 | int tw; /* trapezoidal synthesis window overlap */ |
| 79 | } C2CONST; | 82 | } C2CONST; |
| 80 | 83 | ||
| 81 | /* Structure to hold model parameters for one frame */ | 84 | /* Structure to hold model parameters for one frame */ |
| 82 | 85 | ||
| 83 | typedef struct { | 86 | typedef struct { |
| 84 | float Wo; /* fundamental frequency estimate in radians */ | 87 | float Wo; /* fundamental frequency estimate in radians */ |
| 85 | int L; /* number of harmonics */ | 88 | int L; /* number of harmonics */ |
| 86 | float A[MAX_AMP+1]; /* amplitiude of each harmonic */ | 89 | float A[MAX_AMP + 1]; /* amplitiude of each harmonic */ |
| 87 | float phi[MAX_AMP+1]; /* phase of each harmonic */ | 90 | float phi[MAX_AMP + 1]; /* phase of each harmonic */ |
| 88 | int voiced; /* non-zero if this frame is voiced */ | 91 | int voiced; /* non-zero if this frame is voiced */ |
| 89 | } MODEL; | 92 | } MODEL; |
| 90 | 93 | ||
| 91 | /* describes each codebook */ | 94 | /* describes each codebook */ |
| 92 | 95 | ||
| 93 | struct lsp_codebook { | 96 | struct lsp_codebook { |
| 94 | int k; /* dimension of vector */ | 97 | int k; /* dimension of vector */ |
| 95 | int log2m; /* number of bits in m */ | 98 | int log2m; /* number of bits in m */ |
| 96 | int m; /* elements in codebook */ | 99 | int m; /* elements in codebook */ |
| 97 | #ifdef __EMBEDDED /* make sure stored in flash */ | 100 | #ifdef __EMBEDDED__ /* make sure stored in flash */ |
| 98 | const float *cb; /* The elements */ | 101 | const float *cb; /* The elements */ |
| 99 | #else | 102 | #else |
| 100 | float *cb; /* The elements */ | 103 | float *cb; /* The elements */ |
| 101 | #endif | 104 | #endif |
| 102 | }; | 105 | }; |
| 103 | 106 | ||
| 104 | extern const struct lsp_codebook lsp_cb[]; | 107 | extern const struct lsp_codebook lsp_cb[]; |
| 105 | extern const struct lsp_codebook lsp_cbd[]; | 108 | extern const struct lsp_codebook lsp_cbd[]; |
| 106 | extern const struct lsp_codebook lsp_cbvq[]; | 109 | extern const struct lsp_codebook lsp_cbjmv[]; |
| 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[]; | 110 | extern const struct lsp_codebook ge_cb[]; |
| 113 | extern const struct lsp_codebook lspmelvq_cb[]; | ||
| 114 | extern const struct lsp_codebook newamp1vq_cb[]; | 111 | extern const struct lsp_codebook newamp1vq_cb[]; |
| 115 | extern const struct lsp_codebook newamp1_energy_cb[]; | 112 | extern const struct lsp_codebook newamp1_energy_cb[]; |
| 116 | extern const struct lsp_codebook newamp2vq_cb[]; | 113 | extern const struct lsp_codebook newamp2vq_cb[]; |
| 117 | extern const struct lsp_codebook newamp2_energy_cb[]; | 114 | extern const struct lsp_codebook newamp2_energy_cb[]; |
| 118 | 115 | ||
| 119 | #ifdef _GNU_SOURCE | 116 | #ifdef _GNU_SOURCE |
| 120 | #define POW10F(x) exp10f((x)) | 117 | #define POW10F(x) exp10f((x)) |
| 121 | #else | 118 | #else |
| 122 | #define POW10F(x) expf(2.302585092994046f*(x)) | 119 | #define POW10F(x) expf(2.302585092994046f * (x)) |
| 123 | #endif | 120 | #endif |
| 124 | 121 | ||
| 125 | #endif | 122 | #endif |
