• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2004-2010 NXP Software
3  * Copyright (C) 2010 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /****************************************************************************************/
19 /*                                                                                      */
20 /*  Header file for the application layer interface of the LVREV module                 */
21 /*                                                                                      */
22 /*  This files includes all definitions, types, structures and function prototypes      */
23 /*  required by the calling layer. All other types, structures and functions are        */
24 /*  private.                                                                            */
25 /*                                                                                      */
26 /****************************************************************************************/
27 
28 #ifndef __LVREV_H__
29 #define __LVREV_H__
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /* __cplusplus */
34 
35 
36 /****************************************************************************************/
37 /*                                                                                      */
38 /*  Includes                                                                            */
39 /*                                                                                      */
40 /****************************************************************************************/
41 #include "LVM_Types.h"
42 
43 
44 /****************************************************************************************/
45 /*                                                                                      */
46 /*  Definitions                                                                         */
47 /*                                                                                      */
48 /****************************************************************************************/
49 /* General */
50 #define LVREV_BLOCKSIZE_MULTIPLE                1       /* Processing block size multiple */
51 #define LVREV_MAX_T60                        7000       /* Maximum decay time is 7000ms */
52 
53 /* Memory table*/
54 #define LVREV_NR_MEMORY_REGIONS                 4       /* Number of memory regions */
55 
56 
57 /****************************************************************************************/
58 /*                                                                                      */
59 /*  Types                                                                               */
60 /*                                                                                      */
61 /****************************************************************************************/
62 /* Instance handle */
63 typedef void *LVREV_Handle_t;
64 
65 
66 /* Status return values */
67 typedef enum
68 {
69     LVREV_SUCCESS            = 0,                       /* Successful return from a routine */
70     LVREV_NULLADDRESS        = 1,                       /* NULL allocation address */
71     LVREV_OUTOFRANGE         = 2,                       /* Out of range control parameter */
72     LVREV_INVALIDNUMSAMPLES  = 3,                       /* Invalid number of samples */
73     LVREV_RETURNSTATUS_DUMMY = LVM_MAXENUM
74 } LVREV_ReturnStatus_en;
75 
76 
77 /* Reverb delay lines */
78 typedef enum
79 {
80     LVREV_DELAYLINES_1     = 1,                         /* One delay line */
81     LVREV_DELAYLINES_2     = 2,                         /* Two delay lines */
82     LVREV_DELAYLINES_4     = 4,                         /* Four delay lines */
83     LVREV_DELAYLINES_DUMMY = LVM_MAXENUM
84 } LVREV_NumDelayLines_en;
85 
86 
87 /****************************************************************************************/
88 /*                                                                                      */
89 /*  Structures                                                                          */
90 /*                                                                                      */
91 /****************************************************************************************/
92 
93 /* Memory table containing the region definitions */
94 typedef struct
95 {
96     LVM_MemoryRegion_st        Region[LVREV_NR_MEMORY_REGIONS];  /* One definition for each region */
97 } LVREV_MemoryTable_st;
98 
99 
100 /* Control Parameter structure */
101 typedef struct
102 {
103     /* General parameters */
104     LVM_Mode_en                 OperatingMode;          /* Operating mode */
105     LVM_Fs_en                   SampleRate;             /* Sample rate */
106     LVM_Format_en               SourceFormat;           /* Source data format */
107 
108     /* Parameters for REV */
109     LVM_UINT16                  Level;                  /* Level, 0 to 100 representing percentage of reverb */
110 #ifndef HIGHER_FS
111     LVM_UINT16                  LPF;                    /* Low pass filter, in Hz */
112     LVM_UINT16                  HPF;                    /* High pass filter, in Hz */
113 #else
114     LVM_UINT32                  LPF;                    /* Low pass filter, in Hz */
115     LVM_UINT32                  HPF;                    /* High pass filter, in Hz */
116 #endif
117 
118     LVM_UINT16                  T60;                    /* Decay time constant, in ms */
119     LVM_UINT16                  Density;                /* Echo density, 0 to 100 for minimum to maximum density */
120     LVM_UINT16                  Damping;                /* Damping */
121     LVM_UINT16                  RoomSize;               /* Simulated room size, 1 to 100 for minimum to maximum size */
122 
123 } LVREV_ControlParams_st;
124 
125 
126 /* Instance Parameter structure */
127 typedef struct
128 {
129     /* General */
130     LVM_UINT16                  MaxBlockSize;           /* Maximum processing block size */
131 
132     /* Reverb */
133     LVM_Format_en               SourceFormat;           /* Source data formats to support */
134     LVREV_NumDelayLines_en      NumDelays;              /* The number of delay lines, 1, 2 or 4 */
135 
136 } LVREV_InstanceParams_st;
137 
138 
139 /****************************************************************************************/
140 /*                                                                                      */
141 /*  Function Prototypes                                                                 */
142 /*                                                                                      */
143 /****************************************************************************************/
144 
145 /****************************************************************************************/
146 /*                                                                                      */
147 /* FUNCTION:                LVREV_GetMemoryTable                                        */
148 /*                                                                                      */
149 /* DESCRIPTION:                                                                         */
150 /*  This function is used to obtain the LVREV module memory requirements to support     */
151 /*  memory allocation. It can also be used to return the memory base address provided   */
152 /*  during memory allocation to support freeing of memory when the LVREV module is no   */
153 /*  longer required. It is called in two ways:                                          */
154 /*                                                                                      */
155 /*  hInstance = NULL                Returns the memory requirements                     */
156 /*  hInstance = Instance handle     Returns the memory requirements and allocated       */
157 /*                                  base addresses.                                     */
158 /*                                                                                      */
159 /*  When this function is called with hInstance = NULL the memory base address pointers */
160 /*  will be NULL on return.                                                             */
161 /*                                                                                      */
162 /*  When the function is called for freeing memory, hInstance = Instance Handle the     */
163 /*  memory table returns the allocated memory and base addresses used during            */
164 /*  initialisation.                                                                     */
165 /*                                                                                      */
166 /* PARAMETERS:                                                                          */
167 /*  hInstance               Instance Handle                                             */
168 /*  pMemoryTable            Pointer to an empty memory table                            */
169 /*  pInstanceParams         Pointer to the instance parameters                          */
170 /*                                                                                      */
171 /* RETURNS:                                                                             */
172 /*  LVREV_SUCCESS           Succeeded                                                   */
173 /*  LVREV_NULLADDRESS       When pMemoryTable is NULL                                   */
174 /*  LVREV_NULLADDRESS       When requesting memory requirements and pInstanceParams     */
175 /*                          is NULL                                                     */
176 /*                                                                                      */
177 /* NOTES:                                                                               */
178 /*  1.  This function may be interrupted by the LVREV_Process function                  */
179 /*                                                                                      */
180 /****************************************************************************************/
181 LVREV_ReturnStatus_en LVREV_GetMemoryTable(LVREV_Handle_t           hInstance,
182                                            LVREV_MemoryTable_st     *pMemoryTable,
183                                            LVREV_InstanceParams_st  *pInstanceParams);
184 
185 
186 /****************************************************************************************/
187 /*                                                                                      */
188 /* FUNCTION:                LVREV_GetInstanceHandle                                     */
189 /*                                                                                      */
190 /* DESCRIPTION:                                                                         */
191 /*  This function is used to create a LVREV module instance. It returns the created     */
192 /*  instance handle through phInstance. All parameters are set to invalid values, the   */
193 /*  LVREV_SetControlParameters function must be called with a set of valid control      */
194 /*  parameters before the LVREV_Process function can be called.                         */
195 /*                                                                                      */
196 /*  The memory allocation must be provided by the application by filling in the memory  */
197 /*  region base addresses in the memory table before calling this function.             */
198 /*                                                                                      */
199 /* PARAMETERS:                                                                          */
200 /*  phInstance              Pointer to the instance handle                              */
201 /*  pMemoryTable            Pointer to the memory definition table                      */
202 /*  pInstanceParams         Pointer to the instance parameters                          */
203 /*                                                                                      */
204 /* RETURNS:                                                                             */
205 /*  LVREV_SUCCESS           Succeeded                                                   */
206 /*  LVREV_NULLADDRESS       When phInstance or pMemoryTable or pInstanceParams is NULL  */
207 /*  LVREV_NULLADDRESS       When one of the memory regions has a NULL pointer           */
208 /*                                                                                      */
209 /* NOTES:                                                                               */
210 /*                                                                                      */
211 /****************************************************************************************/
212 LVREV_ReturnStatus_en LVREV_GetInstanceHandle(LVREV_Handle_t            *phInstance,
213                                               LVREV_MemoryTable_st      *pMemoryTable,
214                                               LVREV_InstanceParams_st   *pInstanceParams);
215 
216 
217 /****************************************************************************************/
218 /*                                                                                      */
219 /* FUNCTION:                LVXX_GetControlParameters                                   */
220 /*                                                                                      */
221 /* DESCRIPTION:                                                                         */
222 /*  Request the LVREV module control parameters. The current parameter set is returned  */
223 /*  via the parameter pointer.                                                          */
224 /*                                                                                      */
225 /* PARAMETERS:                                                                          */
226 /*  hInstance               Instance handle                                             */
227 /*  pControlParams          Pointer to an empty parameter structure                     */
228 /*                                                                                      */
229 /* RETURNS:                                                                             */
230 /*  LVREV_SUCCESS           Succeeded                                                   */
231 /*  LVREV_NULLADDRESS       When hInstance or pControlParams is NULL                    */
232 /*                                                                                      */
233 /* NOTES:                                                                               */
234 /*  1.  This function may be interrupted by the LVREV_Process function                  */
235 /*                                                                                      */
236 /****************************************************************************************/
237 LVREV_ReturnStatus_en LVREV_GetControlParameters(LVREV_Handle_t           hInstance,
238                                                  LVREV_ControlParams_st   *pControlParams);
239 
240 
241 /****************************************************************************************/
242 /*                                                                                      */
243 /* FUNCTION:                LVREV_SetControlParameters                                  */
244 /*                                                                                      */
245 /* DESCRIPTION:                                                                         */
246 /*  Sets or changes the LVREV module parameters.                                        */
247 /*                                                                                      */
248 /* PARAMETERS:                                                                          */
249 /*  hInstance               Instance handle                                             */
250 /*  pNewParams              Pointer to a parameter structure                            */
251 /*                                                                                      */
252 /* RETURNS:                                                                             */
253 /*  LVREV_SUCCESS           Succeeded                                                   */
254 /*  LVREV_NULLADDRESS       When hInstance or pNewParams is NULL                        */
255 /*                                                                                      */
256 /* NOTES:                                                                               */
257 /*  1.  This function may be interrupted by the LVREV_Process function                  */
258 /*                                                                                      */
259 /****************************************************************************************/
260 LVREV_ReturnStatus_en LVREV_SetControlParameters(LVREV_Handle_t           hInstance,
261                                                  LVREV_ControlParams_st   *pNewParams);
262 
263 
264 /****************************************************************************************/
265 /*                                                                                      */
266 /* FUNCTION:                LVREV_ClearAudioBuffers                                     */
267 /*                                                                                      */
268 /* DESCRIPTION:                                                                         */
269 /*  This function is used to clear the internal audio buffers of the module.            */
270 /*                                                                                      */
271 /* PARAMETERS:                                                                          */
272 /*  hInstance               Instance handle                                             */
273 /*                                                                                      */
274 /* RETURNS:                                                                             */
275 /*  LVREV_SUCCESS          Initialisation succeeded                                     */
276 /*  LVREV_NULLADDRESS      Instance is NULL                                             */
277 /*                                                                                      */
278 /* NOTES:                                                                               */
279 /*  1. This function must not be interrupted by the LVREV_Process function              */
280 /*                                                                                      */
281 /****************************************************************************************/
282 LVREV_ReturnStatus_en LVREV_ClearAudioBuffers(LVREV_Handle_t  hInstance);
283 
284 
285 /****************************************************************************************/
286 /*                                                                                      */
287 /* FUNCTION:                LVREV_Process                                               */
288 /*                                                                                      */
289 /* DESCRIPTION:                                                                         */
290 /*  Process function for the LVREV module.                                              */
291 /*                                                                                      */
292 /* PARAMETERS:                                                                          */
293 /*  hInstance               Instance handle                                             */
294 /*  pInData                 Pointer to the input data                                   */
295 /*  pOutData                Pointer to the output data                                  */
296 /*  NumSamples              Number of samples in the input buffer                       */
297 /*                                                                                      */
298 /* RETURNS:                                                                             */
299 /*  LVREV_SUCCESS           Succeeded                                                   */
300 /*  LVREV_INVALIDNUMSAMPLES NumSamples was larger than the maximum block size           */
301 /*                                                                                      */
302 /* NOTES:                                                                               */
303 /*  1. The input and output buffers must be 32-bit aligned                              */
304 /*                                                                                      */
305 /****************************************************************************************/
306 #ifdef BUILD_FLOAT
307 LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t      hInstance,
308                                     const LVM_FLOAT     *pInData,
309                                     LVM_FLOAT           *pOutData,
310                                     const LVM_UINT16          NumSamples);
311 #else
312 LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t      hInstance,
313                                     const LVM_INT32     *pInData,
314                                     LVM_INT32           *pOutData,
315                                     const LVM_UINT16          NumSamples);
316 #endif
317 
318 #ifdef __cplusplus
319 }
320 #endif /* __cplusplus */
321 
322 #endif      /* __LVREV_H__ */
323 
324 /* End of file */
325