Home | History | Annotate | Download | only in lib
      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     LVM_UINT16                  LPF;                    /* Low pass filter, in Hz */
    111     LVM_UINT16                  HPF;                    /* High pass filter, in Hz */
    112     LVM_UINT16                  T60;                    /* Decay time constant, in ms */
    113     LVM_UINT16                  Density;                /* Echo density, 0 to 100 for minimum to maximum density */
    114     LVM_UINT16                  Damping;                /* Damping */
    115     LVM_UINT16                  RoomSize;               /* Simulated room size, 1 to 100 for minimum to maximum size */
    116 
    117 } LVREV_ControlParams_st;
    118 
    119 
    120 /* Instance Parameter structure */
    121 typedef struct
    122 {
    123     /* General */
    124     LVM_UINT16                  MaxBlockSize;           /* Maximum processing block size */
    125 
    126     /* Reverb */
    127     LVM_Format_en               SourceFormat;           /* Source data formats to support */
    128     LVREV_NumDelayLines_en      NumDelays;              /* The number of delay lines, 1, 2 or 4 */
    129 
    130 } LVREV_InstanceParams_st;
    131 
    132 
    133 /****************************************************************************************/
    134 /*                                                                                      */
    135 /*  Function Prototypes                                                                 */
    136 /*                                                                                      */
    137 /****************************************************************************************/
    138 
    139 /****************************************************************************************/
    140 /*                                                                                      */
    141 /* FUNCTION:                LVREV_GetMemoryTable                                        */
    142 /*                                                                                      */
    143 /* DESCRIPTION:                                                                         */
    144 /*  This function is used to obtain the LVREV module memory requirements to support     */
    145 /*  memory allocation. It can also be used to return the memory base address provided   */
    146 /*  during memory allocation to support freeing of memory when the LVREV module is no   */
    147 /*  longer required. It is called in two ways:                                          */
    148 /*                                                                                      */
    149 /*  hInstance = NULL                Returns the memory requirements                     */
    150 /*  hInstance = Instance handle     Returns the memory requirements and allocated       */
    151 /*                                  base addresses.                                     */
    152 /*                                                                                      */
    153 /*  When this function is called with hInstance = NULL the memory base address pointers */
    154 /*  will be NULL on return.                                                             */
    155 /*                                                                                      */
    156 /*  When the function is called for freeing memory, hInstance = Instance Handle the     */
    157 /*  memory table returns the allocated memory and base addresses used during            */
    158 /*  initialisation.                                                                     */
    159 /*                                                                                      */
    160 /* PARAMETERS:                                                                          */
    161 /*  hInstance               Instance Handle                                             */
    162 /*  pMemoryTable            Pointer to an empty memory table                            */
    163 /*  pInstanceParams         Pointer to the instance parameters                          */
    164 /*                                                                                      */
    165 /* RETURNS:                                                                             */
    166 /*  LVREV_SUCCESS           Succeeded                                                   */
    167 /*  LVREV_NULLADDRESS       When pMemoryTable is NULL                                   */
    168 /*  LVREV_NULLADDRESS       When requesting memory requirements and pInstanceParams     */
    169 /*                          is NULL                                                     */
    170 /*                                                                                      */
    171 /* NOTES:                                                                               */
    172 /*  1.  This function may be interrupted by the LVREV_Process function                  */
    173 /*                                                                                      */
    174 /****************************************************************************************/
    175 LVREV_ReturnStatus_en LVREV_GetMemoryTable(LVREV_Handle_t           hInstance,
    176                                            LVREV_MemoryTable_st     *pMemoryTable,
    177                                            LVREV_InstanceParams_st  *pInstanceParams);
    178 
    179 
    180 /****************************************************************************************/
    181 /*                                                                                      */
    182 /* FUNCTION:                LVREV_GetInstanceHandle                                     */
    183 /*                                                                                      */
    184 /* DESCRIPTION:                                                                         */
    185 /*  This function is used to create a LVREV module instance. It returns the created     */
    186 /*  instance handle through phInstance. All parameters are set to invalid values, the   */
    187 /*  LVREV_SetControlParameters function must be called with a set of valid control      */
    188 /*  parameters before the LVREV_Process function can be called.                         */
    189 /*                                                                                      */
    190 /*  The memory allocation must be provided by the application by filling in the memory  */
    191 /*  region base addresses in the memory table before calling this function.             */
    192 /*                                                                                      */
    193 /* PARAMETERS:                                                                          */
    194 /*  phInstance              Pointer to the instance handle                              */
    195 /*  pMemoryTable            Pointer to the memory definition table                      */
    196 /*  pInstanceParams         Pointer to the instance parameters                          */
    197 /*                                                                                      */
    198 /* RETURNS:                                                                             */
    199 /*  LVREV_SUCCESS           Succeeded                                                   */
    200 /*  LVREV_NULLADDRESS       When phInstance or pMemoryTable or pInstanceParams is NULL  */
    201 /*  LVREV_NULLADDRESS       When one of the memory regions has a NULL pointer           */
    202 /*                                                                                      */
    203 /* NOTES:                                                                               */
    204 /*                                                                                      */
    205 /****************************************************************************************/
    206 LVREV_ReturnStatus_en LVREV_GetInstanceHandle(LVREV_Handle_t            *phInstance,
    207                                               LVREV_MemoryTable_st      *pMemoryTable,
    208                                               LVREV_InstanceParams_st   *pInstanceParams);
    209 
    210 
    211 /****************************************************************************************/
    212 /*                                                                                      */
    213 /* FUNCTION:                LVXX_GetControlParameters                                   */
    214 /*                                                                                      */
    215 /* DESCRIPTION:                                                                         */
    216 /*  Request the LVREV module control parameters. The current parameter set is returned  */
    217 /*  via the parameter pointer.                                                          */
    218 /*                                                                                      */
    219 /* PARAMETERS:                                                                          */
    220 /*  hInstance               Instance handle                                             */
    221 /*  pControlParams          Pointer to an empty parameter structure                     */
    222 /*                                                                                      */
    223 /* RETURNS:                                                                             */
    224 /*  LVREV_SUCCESS           Succeeded                                                   */
    225 /*  LVREV_NULLADDRESS       When hInstance or pControlParams is NULL                    */
    226 /*                                                                                      */
    227 /* NOTES:                                                                               */
    228 /*  1.  This function may be interrupted by the LVREV_Process function                  */
    229 /*                                                                                      */
    230 /****************************************************************************************/
    231 LVREV_ReturnStatus_en LVREV_GetControlParameters(LVREV_Handle_t           hInstance,
    232                                                  LVREV_ControlParams_st   *pControlParams);
    233 
    234 
    235 /****************************************************************************************/
    236 /*                                                                                      */
    237 /* FUNCTION:                LVREV_SetControlParameters                                  */
    238 /*                                                                                      */
    239 /* DESCRIPTION:                                                                         */
    240 /*  Sets or changes the LVREV module parameters.                                        */
    241 /*                                                                                      */
    242 /* PARAMETERS:                                                                          */
    243 /*  hInstance               Instance handle                                             */
    244 /*  pNewParams              Pointer to a parameter structure                            */
    245 /*                                                                                      */
    246 /* RETURNS:                                                                             */
    247 /*  LVREV_SUCCESS           Succeeded                                                   */
    248 /*  LVREV_NULLADDRESS       When hInstance or pNewParams is NULL                        */
    249 /*                                                                                      */
    250 /* NOTES:                                                                               */
    251 /*  1.  This function may be interrupted by the LVREV_Process function                  */
    252 /*                                                                                      */
    253 /****************************************************************************************/
    254 LVREV_ReturnStatus_en LVREV_SetControlParameters(LVREV_Handle_t           hInstance,
    255                                                  LVREV_ControlParams_st   *pNewParams);
    256 
    257 
    258 /****************************************************************************************/
    259 /*                                                                                      */
    260 /* FUNCTION:                LVREV_ClearAudioBuffers                                     */
    261 /*                                                                                      */
    262 /* DESCRIPTION:                                                                         */
    263 /*  This function is used to clear the internal audio buffers of the module.            */
    264 /*                                                                                      */
    265 /* PARAMETERS:                                                                          */
    266 /*  hInstance               Instance handle                                             */
    267 /*                                                                                      */
    268 /* RETURNS:                                                                             */
    269 /*  LVREV_SUCCESS          Initialisation succeeded                                     */
    270 /*  LVREV_NULLADDRESS      Instance is NULL                                             */
    271 /*                                                                                      */
    272 /* NOTES:                                                                               */
    273 /*  1. This function must not be interrupted by the LVREV_Process function              */
    274 /*                                                                                      */
    275 /****************************************************************************************/
    276 LVREV_ReturnStatus_en LVREV_ClearAudioBuffers(LVREV_Handle_t  hInstance);
    277 
    278 
    279 /****************************************************************************************/
    280 /*                                                                                      */
    281 /* FUNCTION:                LVREV_Process                                               */
    282 /*                                                                                      */
    283 /* DESCRIPTION:                                                                         */
    284 /*  Process function for the LVREV module.                                              */
    285 /*                                                                                      */
    286 /* PARAMETERS:                                                                          */
    287 /*  hInstance               Instance handle                                             */
    288 /*  pInData                 Pointer to the input data                                   */
    289 /*  pOutData                Pointer to the output data                                  */
    290 /*  NumSamples              Number of samples in the input buffer                       */
    291 /*                                                                                      */
    292 /* RETURNS:                                                                             */
    293 /*  LVREV_SUCCESS           Succeeded                                                   */
    294 /*  LVREV_INVALIDNUMSAMPLES NumSamples was larger than the maximum block size           */
    295 /*                                                                                      */
    296 /* NOTES:                                                                               */
    297 /*  1. The input and output buffers must be 32-bit aligned                              */
    298 /*                                                                                      */
    299 /****************************************************************************************/
    300 LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t      hInstance,
    301                                     const LVM_INT32     *pInData,
    302                                     LVM_INT32           *pOutData,
    303                                     const LVM_UINT16          NumSamples);
    304 
    305 
    306 #ifdef __cplusplus
    307 }
    308 #endif /* __cplusplus */
    309 
    310 #endif      /* __LVREV_H__ */
    311 
    312 /* End of file */
    313