• 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 /****************************************************************************************/
32 /*                                                                                      */
33 /*  Includes                                                                            */
34 /*                                                                                      */
35 /****************************************************************************************/
36 #include "LVM_Types.h"
37 
38 /****************************************************************************************/
39 /*                                                                                      */
40 /*  Definitions                                                                         */
41 /*                                                                                      */
42 /****************************************************************************************/
43 /* General */
44 #define LVREV_BLOCKSIZE_MULTIPLE 1 /* Processing block size multiple */
45 #define LVREV_MAX_T60 7000         /* Maximum decay time is 7000ms */
46 
47 /* Memory table*/
48 #define LVREV_NR_MEMORY_REGIONS 4 /* Number of memory regions */
49 
50 /****************************************************************************************/
51 /*                                                                                      */
52 /*  Types                                                                               */
53 /*                                                                                      */
54 /****************************************************************************************/
55 /* Instance handle */
56 typedef void* LVREV_Handle_t;
57 
58 /* Status return values */
59 typedef enum {
60     LVREV_SUCCESS = 0,           /* Successful return from a routine */
61     LVREV_NULLADDRESS = 1,       /* NULL allocation address */
62     LVREV_OUTOFRANGE = 2,        /* Out of range control parameter */
63     LVREV_INVALIDNUMSAMPLES = 3, /* Invalid number of samples */
64     LVREV_RETURNSTATUS_DUMMY = LVM_MAXENUM
65 } LVREV_ReturnStatus_en;
66 
67 /* Reverb delay lines */
68 typedef enum {
69     LVREV_DELAYLINES_1 = 1, /* One delay line */
70     LVREV_DELAYLINES_2 = 2, /* Two delay lines */
71     LVREV_DELAYLINES_4 = 4, /* Four delay lines */
72     LVREV_DELAYLINES_DUMMY = LVM_MAXENUM
73 } LVREV_NumDelayLines_en;
74 
75 /****************************************************************************************/
76 /*                                                                                      */
77 /*  Structures                                                                          */
78 /*                                                                                      */
79 /****************************************************************************************/
80 
81 /* Control Parameter structure */
82 typedef struct {
83     /* General parameters */
84     LVM_Mode_en OperatingMode;  /* Operating mode */
85     LVM_Fs_en SampleRate;       /* Sample rate */
86     LVM_Format_en SourceFormat; /* Source data format */
87 
88     /* Parameters for REV */
89     LVM_UINT16 Level; /* Level, 0 to 100 representing percentage of reverb */
90     LVM_UINT32 LPF;   /* Low pass filter, in Hz */
91     LVM_UINT32 HPF;   /* High pass filter, in Hz */
92 
93     LVM_UINT16 T60;      /* Decay time constant, in ms */
94     LVM_UINT16 Density;  /* Echo density, 0 to 100 for minimum to maximum density */
95     LVM_UINT16 Damping;  /* Damping */
96     LVM_UINT16 RoomSize; /* Simulated room size, 1 to 100 for minimum to maximum size */
97 
98 } LVREV_ControlParams_st;
99 
100 /* Instance Parameter structure */
101 typedef struct {
102     /* General */
103     LVM_UINT16 MaxBlockSize; /* Maximum processing block size */
104 
105     /* Reverb */
106     LVM_Format_en SourceFormat;       /* Source data formats to support */
107     LVREV_NumDelayLines_en NumDelays; /* The number of delay lines, 1, 2 or 4 */
108 
109 } LVREV_InstanceParams_st;
110 
111 /****************************************************************************************/
112 /*                                                                                      */
113 /*  Function Prototypes                                                                 */
114 /*                                                                                      */
115 /****************************************************************************************/
116 
117 /****************************************************************************************/
118 /*                                                                                      */
119 /* FUNCTION:                LVREV_GetInstanceHandle                                     */
120 /*                                                                                      */
121 /* DESCRIPTION:                                                                         */
122 /*  This function is used to create a LVREV module instance. It returns the created     */
123 /*  instance handle through phInstance. All parameters are set to invalid values, the   */
124 /*  LVREV_SetControlParameters function must be called with a set of valid control      */
125 /*  parameters before the LVREV_Process function can be called.                         */
126 /*                                                                                      */
127 /*  The memory allocation must be provided by the application by filling in the memory  */
128 /*  region base addresses in the memory table before calling this function.             */
129 /*                                                                                      */
130 /* PARAMETERS:                                                                          */
131 /*  phInstance              Pointer to the instance handle                              */
132 /*  pInstanceParams         Pointer to the instance parameters                          */
133 /*                                                                                      */
134 /* RETURNS:                                                                             */
135 /*  LVREV_SUCCESS           Succeeded                                                   */
136 /*  LVREV_NULLADDRESS       When phInstance or pMemoryTable or pInstanceParams is NULL  */
137 /*  LVREV_NULLADDRESS       When one of the memory regions has a NULL pointer           */
138 /*                                                                                      */
139 /* NOTES:                                                                               */
140 /*                                                                                      */
141 /****************************************************************************************/
142 LVREV_ReturnStatus_en LVREV_GetInstanceHandle(LVREV_Handle_t* phInstance,
143                                               LVREV_InstanceParams_st* pInstanceParams);
144 
145 /****************************************************************************************/
146 /*                                                                                      */
147 /* FUNCTION:                LVREV_FreeInstance                                          */
148 /*                                                                                      */
149 /* DESCRIPTION:                                                                         */
150 /*  This function is used to free the internal allocations of the module.               */
151 /*                                                                                      */
152 /* PARAMETERS:                                                                          */
153 /*  hInstance               Instance handle                                             */
154 /*                                                                                      */
155 /* RETURNS:                                                                             */
156 /*  LVREV_SUCCESS          free instance succeeded                                      */
157 /*  LVREV_NULLADDRESS      Instance is NULL                                             */
158 /*                                                                                      */
159 /****************************************************************************************/
160 LVREV_ReturnStatus_en LVREV_FreeInstance(LVREV_Handle_t hInstance);
161 
162 /****************************************************************************************/
163 /*                                                                                      */
164 /* FUNCTION:                LVXX_GetControlParameters                                   */
165 /*                                                                                      */
166 /* DESCRIPTION:                                                                         */
167 /*  Request the LVREV module control parameters. The current parameter set is returned  */
168 /*  via the parameter pointer.                                                          */
169 /*                                                                                      */
170 /* PARAMETERS:                                                                          */
171 /*  hInstance               Instance handle                                             */
172 /*  pControlParams          Pointer to an empty parameter structure                     */
173 /*                                                                                      */
174 /* RETURNS:                                                                             */
175 /*  LVREV_SUCCESS           Succeeded                                                   */
176 /*  LVREV_NULLADDRESS       When hInstance or pControlParams is NULL                    */
177 /*                                                                                      */
178 /* NOTES:                                                                               */
179 /*  1.  This function may be interrupted by the LVREV_Process function                  */
180 /*                                                                                      */
181 /****************************************************************************************/
182 LVREV_ReturnStatus_en LVREV_GetControlParameters(LVREV_Handle_t hInstance,
183                                                  LVREV_ControlParams_st* pControlParams);
184 
185 /****************************************************************************************/
186 /*                                                                                      */
187 /* FUNCTION:                LVREV_SetControlParameters                                  */
188 /*                                                                                      */
189 /* DESCRIPTION:                                                                         */
190 /*  Sets or changes the LVREV module parameters.                                        */
191 /*                                                                                      */
192 /* PARAMETERS:                                                                          */
193 /*  hInstance               Instance handle                                             */
194 /*  pNewParams              Pointer to a parameter structure                            */
195 /*                                                                                      */
196 /* RETURNS:                                                                             */
197 /*  LVREV_SUCCESS           Succeeded                                                   */
198 /*  LVREV_NULLADDRESS       When hInstance or pNewParams is NULL                        */
199 /*                                                                                      */
200 /* NOTES:                                                                               */
201 /*  1.  This function may be interrupted by the LVREV_Process function                  */
202 /*                                                                                      */
203 /****************************************************************************************/
204 LVREV_ReturnStatus_en LVREV_SetControlParameters(LVREV_Handle_t hInstance,
205                                                  LVREV_ControlParams_st* pNewParams);
206 
207 /****************************************************************************************/
208 /*                                                                                      */
209 /* FUNCTION:                LVREV_ClearAudioBuffers                                     */
210 /*                                                                                      */
211 /* DESCRIPTION:                                                                         */
212 /*  This function is used to clear the internal audio buffers of the module.            */
213 /*                                                                                      */
214 /* PARAMETERS:                                                                          */
215 /*  hInstance               Instance handle                                             */
216 /*                                                                                      */
217 /* RETURNS:                                                                             */
218 /*  LVREV_SUCCESS          Initialisation succeeded                                     */
219 /*  LVREV_NULLADDRESS      Instance is NULL                                             */
220 /*                                                                                      */
221 /* NOTES:                                                                               */
222 /*  1. This function must not be interrupted by the LVREV_Process function              */
223 /*                                                                                      */
224 /****************************************************************************************/
225 LVREV_ReturnStatus_en LVREV_ClearAudioBuffers(LVREV_Handle_t hInstance);
226 
227 /****************************************************************************************/
228 /*                                                                                      */
229 /* FUNCTION:                LVREV_Process                                               */
230 /*                                                                                      */
231 /* DESCRIPTION:                                                                         */
232 /*  Process function for the LVREV module.                                              */
233 /*                                                                                      */
234 /* PARAMETERS:                                                                          */
235 /*  hInstance               Instance handle                                             */
236 /*  pInData                 Pointer to the input data                                   */
237 /*  pOutData                Pointer to the output data                                  */
238 /*  NumSamples              Number of samples in the input buffer                       */
239 /*                                                                                      */
240 /* RETURNS:                                                                             */
241 /*  LVREV_SUCCESS           Succeeded                                                   */
242 /*  LVREV_INVALIDNUMSAMPLES NumSamples was larger than the maximum block size           */
243 /*                                                                                      */
244 /* NOTES:                                                                               */
245 /*  1. The input and output buffers must be 32-bit aligned                              */
246 /*                                                                                      */
247 /****************************************************************************************/
248 LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t hInstance, const LVM_FLOAT* pInData,
249                                     LVM_FLOAT* pOutData, const LVM_UINT16 NumSamples);
250 
251 #endif /* __LVREV_H__ */
252 
253 /* End of file */
254