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