Home | History | Annotate | Download | only in src
      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 #ifndef __LVC_MIXER_H__
     19 #define __LVC_MIXER_H__
     20 
     21 
     22 #ifdef __cplusplus
     23 extern "C" {
     24 #endif /* __cplusplus */
     25 
     26 
     27 #include "LVM_Types.h"
     28 
     29 /**********************************************************************************
     30    INSTANCE MEMORY TYPE DEFINITION
     31 ***********************************************************************************/
     32 
     33 /* LVMixer3_st structure stores Instance parameters for one audio stream */
     34 #ifdef BUILD_FLOAT
     35 typedef struct
     36 {
     37     LVM_FLOAT       PrivateParams[3];   /* Private Instance params for \
     38                                            Audio Stream shift parameter */
     39     LVM_INT16       CallbackSet;        /* Boolean.  Should be set by calling application \
     40                                            each time the target value is updated */
     41     LVM_INT16       CallbackParam;      /* Parameter that will be used in the calback function */
     42     void            *pCallbackHandle;   /* Pointer to the instance of the callback function */
     43     void            *pGeneralPurpose;   /* Pointer for general purpose usage */
     44     LVM_Callback    pCallBack;          /* Pointer to the callback function */
     45 } LVMixer3_FLOAT_st;
     46 #else
     47 typedef struct
     48 {
     49     LVM_INT32       PrivateParams[4];   /* Private Instance params for Audio Stream */
     50     LVM_INT16       CallbackSet;        /* Boolean.  Should be set by calling application each time the target value is updated */
     51     LVM_INT16       CallbackParam;      /* Parameter that will be used in the calback function */
     52     void            *pCallbackHandle;   /* Pointer to the instance of the callback function */
     53     void            *pGeneralPurpose;   /* Pointer for general purpose usage */
     54     LVM_Callback    pCallBack;          /* Pointer to the callback function */
     55 } LVMixer3_st;
     56 #endif
     57 #ifdef BUILD_FLOAT
     58 typedef struct
     59 {
     60     LVMixer3_FLOAT_st     MixerStream[1];    /* Instance Params for one Audio Stream */
     61 } LVMixer3_1St_FLOAT_st;
     62 #else
     63 typedef struct
     64 {
     65     LVMixer3_st     MixerStream[1];    /* Instance Params for one Audio Stream */
     66 } LVMixer3_1St_st;
     67 #endif
     68 #ifdef BUILD_FLOAT
     69 typedef struct
     70 {
     71     LVMixer3_FLOAT_st     MixerStream[2];    /* Instance Params for two Audio Streams */
     72 } LVMixer3_2St_FLOAT_st;
     73 #else
     74 typedef struct
     75 {
     76     LVMixer3_st     MixerStream[2];    /* Instance Params for two Audio Streams */
     77 } LVMixer3_2St_st;
     78 #endif
     79 #ifndef BUILD_FLOAT
     80 typedef struct
     81 {
     82     LVMixer3_st     MixerStream[3];    /* Instance Params for three Audio Streams */
     83 } LVMixer3_3St_st;
     84 #endif
     85 /**********************************************************************************
     86    FUNCTION PROTOTYPES (HIGH LEVEL FUNCTIONS)
     87 ***********************************************************************************/
     88 
     89 /* Function names should be unique within first 16 characters  */
     90 #define    LVMixer3_MixSoft_1St_D16C31_SAT   LVMixer3_1St_D16C31_SAT_MixSoft
     91 #define    LVMixer3_MixInSoft_D16C31_SAT     LVMixer3_D16C31_SAT_MixInSoft
     92 #define    LVMixer3_MixSoft_2St_D16C31_SAT   LVMixer3_2St_D16C31_SAT_MixSoft
     93 #define    LVMixer3_MixSoft_3St_D16C31_SAT   LVMixer3_3St_D16C31_SAT_MixSoft
     94 
     95 
     96 /*** General functions ************************************************************/
     97 
     98 /**********************************************************************************/
     99 /* This time constant calculation function assumes the mixer will be called with  */
    100 /* large block sizes. When the block size is small, especially if less than 4,    */
    101 /* then the calculation will give an incorrect value for alpha, see the mixer     */
    102 /* documentation for further details.                                             */
    103 /* ********************************************************************************/
    104 #ifdef BUILD_FLOAT
    105 void LVC_Mixer_SetTarget( LVMixer3_FLOAT_st *pStream,
    106                           LVM_FLOAT        TargetGain);
    107 #else
    108 void LVC_Mixer_SetTarget( LVMixer3_st *pStream,
    109                                 LVM_INT32           TargetGain);
    110 #endif
    111 #ifdef BUILD_FLOAT
    112 LVM_FLOAT LVC_Mixer_GetTarget( LVMixer3_FLOAT_st *pStream);
    113 #else
    114 LVM_INT32 LVC_Mixer_GetTarget( LVMixer3_st *pStream);
    115 #endif
    116 
    117 #ifdef BUILD_FLOAT
    118 LVM_FLOAT LVC_Mixer_GetCurrent( LVMixer3_FLOAT_st *pStream);
    119 #else
    120 LVM_INT32 LVC_Mixer_GetCurrent( LVMixer3_st *pStream);
    121 #endif
    122 
    123 #ifdef BUILD_FLOAT
    124 void LVC_Mixer_Init( LVMixer3_FLOAT_st *pStream,
    125                      LVM_FLOAT           TargetGain,
    126                      LVM_FLOAT           CurrentGain);
    127 #else
    128 void LVC_Mixer_Init( LVMixer3_st *pStream,
    129                                 LVM_INT32           TargetGain,
    130                                 LVM_INT32           CurrentGain);
    131 #endif
    132 
    133 #ifdef BUILD_FLOAT
    134 void LVC_Mixer_SetTimeConstant( LVMixer3_FLOAT_st *pStream,
    135                                 LVM_INT32           Tc_millisec,
    136                                 LVM_Fs_en           Fs,
    137                                 LVM_INT16           NumChannels);
    138 #else
    139 void LVC_Mixer_SetTimeConstant( LVMixer3_st *pStream,
    140                                 LVM_INT32           Tc_millisec,
    141                                 LVM_Fs_en           Fs,
    142                                 LVM_INT16           NumChannels);
    143 #endif
    144 
    145 #ifdef BUILD_FLOAT
    146 void LVC_Mixer_VarSlope_SetTimeConstant( LVMixer3_FLOAT_st *pStream,
    147                                          LVM_INT32           Tc_millisec,
    148                                          LVM_Fs_en           Fs,
    149                                          LVM_INT16           NumChannels);
    150 #else
    151 void LVC_Mixer_VarSlope_SetTimeConstant( LVMixer3_st *pStream,
    152                                         LVM_INT32           Tc_millisec,
    153                                         LVM_Fs_en           Fs,
    154                                         LVM_INT16           NumChannels);
    155 #endif
    156 
    157 /*** 16 bit functions *************************************************************/
    158 
    159 #ifdef BUILD_FLOAT
    160 void LVC_MixSoft_1St_D16C31_SAT(LVMixer3_1St_FLOAT_st *pInstance,
    161                                 const LVM_FLOAT       *src,
    162                                       LVM_FLOAT       *dst,
    163                                       LVM_INT16       n);
    164 #ifdef SUPPORT_MC
    165 void LVC_MixSoft_Mc_D16C31_SAT(LVMixer3_1St_FLOAT_st *pInstance,
    166                                const LVM_FLOAT       *src,
    167                                      LVM_FLOAT       *dst,
    168                                      LVM_INT16       NrFrames,
    169                                      LVM_INT16       NrChannels);
    170 #endif
    171 
    172 #else
    173 void LVC_MixSoft_1St_D16C31_SAT( LVMixer3_1St_st *pInstance,
    174                                   const LVM_INT16           *src,
    175                                         LVM_INT16           *dst,
    176                                         LVM_INT16           n);
    177 #endif
    178 
    179 #ifdef BUILD_FLOAT
    180 void LVC_MixInSoft_D16C31_SAT(LVMixer3_1St_FLOAT_st *pInstance,
    181                               const LVM_FLOAT       *src,
    182                                     LVM_FLOAT       *dst,
    183                                     LVM_INT16       n);
    184 #ifdef SUPPORT_MC
    185 void LVC_MixInSoft_Mc_D16C31_SAT(LVMixer3_1St_FLOAT_st *pInstance,
    186                                  const LVM_FLOAT       *src,
    187                                        LVM_FLOAT       *dst,
    188                                        LVM_INT16       NrFrames,
    189                                        LVM_INT16       NrChannels);
    190 #endif
    191 
    192 #else
    193 void LVC_MixInSoft_D16C31_SAT( LVMixer3_1St_st *pInstance,
    194                                         LVM_INT16           *src,
    195                                         LVM_INT16           *dst,
    196                                         LVM_INT16           n);
    197 #endif
    198 
    199 #ifdef BUILD_FLOAT
    200 void LVC_MixSoft_2St_D16C31_SAT(LVMixer3_2St_FLOAT_st *pInstance,
    201                                 const LVM_FLOAT       *src1,
    202                                 const LVM_FLOAT       *src2,
    203                                 LVM_FLOAT             *dst,  /* dst cannot be equal to src2 */
    204                                 LVM_INT16             n);
    205 #ifdef SUPPORT_MC
    206 void LVC_MixSoft_2Mc_D16C31_SAT(LVMixer3_2St_FLOAT_st *pInstance,
    207                                 const LVM_FLOAT       *src1,
    208                                 const LVM_FLOAT       *src2,
    209                                 LVM_FLOAT             *dst,  /* dst cannot be equal to src2 */
    210                                 LVM_INT16             NrFrames,
    211                                 LVM_INT16             NrChannels);
    212 #endif
    213 #else
    214 void LVC_MixSoft_2St_D16C31_SAT( LVMixer3_2St_st *pInstance,
    215                                 const LVM_INT16             *src1,
    216                                       LVM_INT16             *src2,
    217                                       LVM_INT16             *dst,  /* dst cannot be equal to src2 */
    218                                       LVM_INT16             n);
    219 #endif
    220 /**********************************************************************************/
    221 /* For applying different gains to Left and right chennals                        */
    222 /* MixerStream[0] applies to Left channel                                         */
    223 /* MixerStream[1] applies to Right channel                                        */
    224 /* Gain values should not be more that 1.0                                        */
    225 /**********************************************************************************/
    226 #ifdef BUILD_FLOAT
    227 #ifdef SUPPORT_MC
    228 void LVC_MixSoft_1St_MC_float_SAT(LVMixer3_2St_FLOAT_st *pInstance,
    229                                    const   LVM_FLOAT     *src,
    230                                    LVM_FLOAT             *dst,   /* dst can be equal to src */
    231                                    LVM_INT16             NrFrames,
    232                                    LVM_INT32             NrChannels,
    233                                    LVM_INT32             ChMask);
    234 #endif
    235 void LVC_MixSoft_1St_2i_D16C31_SAT(LVMixer3_2St_FLOAT_st *pInstance,
    236                                    const   LVM_FLOAT     *src,
    237                                    LVM_FLOAT             *dst,   /* dst can be equal to src */
    238                                    LVM_INT16             n);     /* Number of stereo samples */
    239 #else
    240 void LVC_MixSoft_1St_2i_D16C31_SAT( LVMixer3_2St_st         *pInstance,
    241                                 const   LVM_INT16           *src,
    242                                         LVM_INT16           *dst,   /* dst can be equal to src */
    243                                         LVM_INT16           n);     /* Number of stereo samples */
    244 #endif
    245 #ifdef __cplusplus
    246 }
    247 #endif /* __cplusplus */
    248 
    249 /**********************************************************************************/
    250 
    251 #endif //#ifndef __LVC_MIXER_H__
    252 
    253