1 #ifndef _SFC_H\r
2 #define _SFC_H\r
3 \r
4 /** \r
5 * @file sfc.h\r
6 * @brief Contains external API for the Sample Frequency Converter (SFC) module.\r
7 *\r
8 * Copyright (c) 2007 \96 2013 Texas Instruments Incorporated
9 *
10 * All rights reserved not granted herein.
11 *
12 * Limited License.
13 *
14 * Texas Instruments Incorporated grants a world-wide, royalty-free,
15 * non-exclusive license under copyrights and patents it now or hereafter owns
16 * or controls to make, have made, use, import, offer to sell and sell
17 * ("Utilize") this software subject to the terms herein. With respect to the
18 * foregoing patent license, such license is granted solely to the extent that
19 * any such patent is necessary to Utilize the software alone. The patent
20 * license shall not apply to any combinations which include this software,
21 * other than combinations with devices manufactured by or for TI (\93TI
22 * Devices\94). No hardware patent is licensed hereunder.
23 *
24 * Redistributions must preserve existing copyright notices and reproduce this
25 * license (including the above copyright notice and the disclaimer and (if
26 * applicable) source code license limitations below) in the documentation
27 * and/or other materials provided with the distribution
28 *
29 * Redistribution and use in binary form, without modification, are permitted
30 * provided that the following conditions are met:
31 *
32 * * No reverse engineering, decompilation, or disassembly of this software
33 * is permitted with respect to any software provided in binary form.
34 *
35 * * any redistribution and use are licensed by TI for use only with TI
36 * Devices.
37 *
38 * * Nothing shall obligate TI to provide you with source code for the
39 * software licensed and provided to you in object code.
40 *
41 * If software source code is provided to you, modification and redistribution
42 * of the source code are permitted provided that the following conditions are
43 * met:
44 *
45 * * any redistribution and use of the source code, including any resulting
46 * derivative works, are licensed by TI for use only with TI Devices.
47 *
48 * * any redistribution and use of any object code compiled from the source
49 * code and any resulting derivative works, are licensed by TI for use only
50 * with TI Devices.
51 *
52 * Neither the name of Texas Instruments Incorporated nor the names of its
53 * suppliers may be used to endorse or promote products derived from this
54 * software without specific prior written permission.
55 *
56 * DISCLAIMER.
57 *
58 * THIS SOFTWARE IS PROVIDED BY TI AND TI\92S LICENSORS "AS IS" AND ANY EXPRESS
59 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
60 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
61 * DISCLAIMED. IN NO EVENT SHALL TI AND TI\92S LICENSORS BE LIABLE FOR ANY
62 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
63 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
64 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
65 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
68 * DAMAGE. \r
69 */\r
70 \r
71 #include <ti/mas/types/types.h> /* DSP types */\r
72 \r
73 /**\r
74 * \r
75 * @defgroup SFC Source Frequency Converter (SFC) \r
76 */\r
77 \r
78 /** @ingroup SFC */\r
79 /* @{ */\r
80 \r
81 /**\r
82 * @name External APIs for SFC\r
83 *\r
84 */\r
85 /* @{ */\r
86 /**\r
87 * @brief Sample frequency converter sfcDecimationBy2 performs decimation by 2.\r
88 *\r
89 * @param[in] filt_len Length of the decimation filter. It MUST be integer\r
90 * multiple of 4 plus 1, ie., 4*k+1. This parameter \r
91 * is ignored if parameter coeffs is NULL. \r
92 * @param[in] frame_len_in Length of the data frame to be processed. \r
93 * @param[in] delay_line Filter delay line. It must have filt_len-1 samples \r
94 * from previous frames and frame_len_in samples from\r
95 * current frame. The samples in this buffer must\r
96 * be packed as illustrated below:\r
97 * @verbatim\r
98 | previous frames | current frame | \r
99 x(n-N+1), ..., x(n-M), x(n-M+1), ..., x(n)\r
100 where N=M+L-1, M is input frame length, L is filter length.\r
101 \endverbatim\r
102 * @param[in] coeffs Left half of the decimation filter coefficients \r
103 * including the center. Total number of coefficients\r
104 * provided by user must be (filt_len+1)/2.\r
105 * The decimation filter must be a symetric FIR filter\r
106 * with length filt_len. The gain of the filter must be \r
107 * less than or equal to 0dB. If this pointer is NULL, \r
108 * the \ref sfc_default_filter will be used.\r
109 * @param[out] sig_out Output signal after decimation. Number of output \r
110 * samples is frame_len_in/2.\r
111 */ \r
112 void sfcDecimationBy2(linSample *delay_line, linSample *sig_out, \r
113 const Fract *coeffs, tint filt_len, tint frame_len_in);\r
114 \r
115 /**\r
116 * @brief Sample frequency converter sfcInterpolationBy2 performs \r
117 * interpolation by 2.\r
118 *\r
119 * @param[in] filt_len Length of the interpolation filter. It MUST be \r
120 * integer multiple of 4 plus 1, ie., 4*k+1. This \r
121 * parameter is ignored if parameter coeffs is NULL. \r
122 * @param[in] frame_len_in Length of the data frame to be processed. \r
123 * @param[in] delay_line Filter delay line. It must have (filt_len-1)/2\r
124 * samples from previous frames and frame_len_in \r
125 * samples from current frame. The samples in this \r
126 * buffer must be packed as illustrated below:\r
127 * @verbatim\r
128 | previous frames | current frame | \r
129 x(n-N+1), ..., x(n-M), x(n-M+1), ..., x(n)\r
130 where N=M+(L-1)/2, M is input frame length, L is filter length.\r
131 \endverbatim\r
132 * @param[in] coeffs Left half of the interpolation filter coefficients \r
133 * including the center. Total number of coefficients\r
134 * provided by user must be (filt_len+1)/2.\r
135 * The interpolation filter must be a symetric FIR filter\r
136 * with length filt_len. The gain of the filter must be \r
137 * less than or equal to 0dB. If this pointer is NULL, \r
138 * the \ref sfc_default_filter will be used.\r
139 * @param[out] sig_out Output signal after interpolation. Number of output \r
140 * samples is frame_len_in*2.\r
141 */ \r
142 void sfcInterpolationBy2(linSample *delay_line, linSample *sig_out, \r
143 const Fract *coeffs, tint filt_len, tint frame_len_in);\r
144 /* @} */\r
145 \r
146 /** @defgroup sfc_default_filter SFC Default Filter\r
147 * \r
148 * @brief Default decimation/interpolation filter coefficients. This filter \r
149 * will be used if the user doesn't provide coefficients for \r
150 * decimation/interpolation. \r
151 *\r
152 * This filter has cutoff frequency at 0.426 PI, or 3.4kHz for 16kHz \r
153 * sampling frequency. It has 59dB out-of-band rejection above 0.548 PI, \r
154 * or 4.34kHz for 16kHz sampling frequency. \r
155 *\r
156 * @verbatim\r
157 Fract sfc_decim_interp_filt[sfc_NUM_DEF_COEFS] = {\r
158 9,\r
159 105,\r
160 108,\r
161 -105,\r
162 -251,\r
163 74,\r
164 479,\r
165 85,\r
166 -766,\r
167 -463,\r
168 1075,\r
169 1224,\r
170 -1354,\r
171 -2891,\r
172 1548,\r
173 10171,\r
174 14672 -> center coefficient\r
175 \endverbatim\r
176 */\r
177 /* @{ */\r
178 #define sfc_DEF_FILT_LEN 33\r
179 #define sfc_NUM_DEF_COEFS (sfc_DEF_FILT_LEN+1)/2\r
180 extern const Fract sfc_def_decim_interp_filt[sfc_NUM_DEF_COEFS];\r
181 /* @} */\r
182 \r
183 /* @} */ /* ingroup SFC */\r
184 #endif\r
185 /* Nothing past this point */\r