1 /*---------------------------------------------------------------------------*\
2 
3   FILE........: newamp1.h
4   AUTHOR......: David Rowe
5   DATE CREATED: Jan 2017
6 
7   Quantisation functions for the sinusoidal coder, using "newamp1"
8   algorithm that resamples variable rate L [Am} to a fixed rate K then
9   VQs.
10 
11 \*---------------------------------------------------------------------------*/
12 
13 /*
14   Copyright David Rowe 2017
15 
16   All rights reserved.
17 
18   This program is free software; you can redistribute it and/or modify
19   it under the terms of the GNU Lesser General Public License version 2.1, as
20   published by the Free Software Foundation.  This program is
21   distributed in the hope that it will be useful, but WITHOUT ANY
22   WARRANTY; without even the implied warranty of MERCHANTABILITY or
23   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
24   License for more details.
25 
26   You should have received a copy of the GNU Lesser General Public License
27   along with this program; if not, see <http://www.gnu.org/licenses/>.
28 */
29 
30 #ifndef __NEWAMP1__
31 #define __NEWAMP1__
32 
33 #define NEWAMP1_N_INDEXES    4   /* Number of indexes to pack: vq1, vq2, energy, Wo */
34 #define NEWAMP1_PHASE_NFFT 128   /* size of FFT used for phase synthesis            */
35 #define NEWAMP1_K           20   /* rate K vector length                            */
36 #define NEWAMP1_VQ_MBEST_DEPTH 5 /* how many candidates we keep for each stage of mbest search */
37 
38 
39 #include "codec2_fft.h"
40 #include "comp.h"
41 
42 void interp_para(float y[], float xp[], float yp[], int np, float x[], int n);
43 float ftomel(float fHz);
44 void mel_sample_freqs_kHz(float rate_K_sample_freqs_kHz[], int K, float mel_start, float mel_end);
45 void resample_const_rate_f(C2CONST *c2const, MODEL *model, float rate_K_vec[], float rate_K_sample_freqs_kHz[], int K);
46 float rate_K_mbest_encode(int *indexes, float *x, float *xq, int ndim, int mbest_entries);
47 void post_filter_newamp1(float vec[], float sample_freq_kHz[], int K, float pf_gain);
48 void interp_Wo_v(float Wo_[], int L_[], int voicing_[], float Wo1, float Wo2, int voicing1, int voicing2);
49 void resample_rate_L(C2CONST *c2const, MODEL *model, float rate_K_vec[], float rate_K_sample_freqs_kHz[], int K);
50 void determine_phase(C2CONST *c2const, COMP H[], MODEL *model, int Nfft, codec2_fft_cfg fwd_cfg, codec2_fft_cfg inv_cfg);
51 void determine_autoc(C2CONST *c2const, float Rk[], int order, MODEL *model, int Nfft, codec2_fft_cfg fwd_cfg, codec2_fft_cfg inv_cfg);
52 void newamp1_model_to_indexes(C2CONST *c2const,
53                               int    indexes[],
54                               MODEL *model,
55                               float  rate_K_vec[],
56                               float  rate_K_sample_freqs_kHz[],
57                               int    K,
58                               float *mean,
59                               float  rate_K_vec_no_mean[],
60                               float  rate_K_vec_no_mean_[],
61                               float *se,
62                               float *eq,
63                               int    eq_en);
64 void newamp1_indexes_to_rate_K_vec(float  rate_K_vec_[],
65                                    float  rate_K_vec_no_mean_[],
66                                    float  rate_K_sample_freqs_kHz[],
67                                    int    K,
68                                    float *mean_,
69                                    int    indexes[],
70                                    float user_rate_K_vec_no_mean_[],
71                                    int post_filter_en);
72 void newamp1_interpolate(float interpolated_surface_[], float left_vec[], float right_vec[], int K);
73 void newamp1_eq(float rate_K_vec_no_mean[], float eq[], int K, int eq_en);
74 void newamp1_indexes_to_model(C2CONST *c2const,
75                               MODEL  model_[],
76                               COMP   H[],
77                               float  interpolated_surface_[],
78                               float  prev_rate_K_vec_[],
79                               float  *Wo_left,
80                               int    *voicing_left,
81                               float  rate_K_sample_freqs_kHz[],
82                               int    K,
83                               codec2_fft_cfg fwd_cfg,
84                               codec2_fft_cfg inv_cfg,
85                               int    indexes[],
86                               float user_rate_K_vec_no_mean_[],
87                               int post_filter_en);
88 
89 #endif
90