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 #include "LVM_Types.h" 22 23 /********************************************************************************** 24 INSTANCE MEMORY TYPE DEFINITION 25 ***********************************************************************************/ 26 27 /* LVMixer3_st structure stores Instance parameters for one audio stream */ 28 typedef struct 29 { 30 LVM_FLOAT PrivateParams[3]; /* Private Instance params for \ 31 Audio Stream shift parameter */ 32 LVM_INT16 CallbackSet; /* Boolean. Should be set by calling application \ 33 each time the target value is updated */ 34 LVM_INT16 CallbackParam; /* Parameter that will be used in the calback function */ 35 void *pCallbackHandle; /* Pointer to the instance of the callback function */ 36 void *pGeneralPurpose; /* Pointer for general purpose usage */ 37 LVM_Callback pCallBack; /* Pointer to the callback function */ 38 } LVMixer3_FLOAT_st; 39 typedef struct 40 { 41 LVMixer3_FLOAT_st MixerStream[1]; /* Instance Params for one Audio Stream */ 42 } LVMixer3_1St_FLOAT_st; 43 typedef struct 44 { 45 LVMixer3_FLOAT_st MixerStream[2]; /* Instance Params for two Audio Streams */ 46 } LVMixer3_2St_FLOAT_st; 47 /********************************************************************************** 48 FUNCTION PROTOTYPES (HIGH LEVEL FUNCTIONS) 49 ***********************************************************************************/ 50 51 /* Function names should be unique within first 16 characters */ 52 #define LVMixer3_MixSoft_1St_D16C31_SAT LVMixer3_1St_D16C31_SAT_MixSoft 53 #define LVMixer3_MixInSoft_D16C31_SAT LVMixer3_D16C31_SAT_MixInSoft 54 #define LVMixer3_MixSoft_2St_D16C31_SAT LVMixer3_2St_D16C31_SAT_MixSoft 55 #define LVMixer3_MixSoft_3St_D16C31_SAT LVMixer3_3St_D16C31_SAT_MixSoft 56 57 /*** General functions ************************************************************/ 58 59 /**********************************************************************************/ 60 /* This time constant calculation function assumes the mixer will be called with */ 61 /* large block sizes. When the block size is small, especially if less than 4, */ 62 /* then the calculation will give an incorrect value for alpha, see the mixer */ 63 /* documentation for further details. */ 64 /* ********************************************************************************/ 65 void LVC_Mixer_SetTarget( LVMixer3_FLOAT_st *pStream, 66 LVM_FLOAT TargetGain); 67 LVM_FLOAT LVC_Mixer_GetTarget( LVMixer3_FLOAT_st *pStream); 68 69 LVM_FLOAT LVC_Mixer_GetCurrent( LVMixer3_FLOAT_st *pStream); 70 71 void LVC_Mixer_Init( LVMixer3_FLOAT_st *pStream, 72 LVM_FLOAT TargetGain, 73 LVM_FLOAT CurrentGain); 74 75 void LVC_Mixer_SetTimeConstant( LVMixer3_FLOAT_st *pStream, 76 LVM_INT32 Tc_millisec, 77 LVM_Fs_en Fs, 78 LVM_INT16 NumChannels); 79 80 void LVC_Mixer_VarSlope_SetTimeConstant( LVMixer3_FLOAT_st *pStream, 81 LVM_INT32 Tc_millisec, 82 LVM_Fs_en Fs, 83 LVM_INT16 NumChannels); 84 85 /*** 16 bit functions *************************************************************/ 86 87 void LVC_MixSoft_1St_D16C31_SAT(LVMixer3_1St_FLOAT_st *pInstance, 88 const LVM_FLOAT *src, 89 LVM_FLOAT *dst, 90 LVM_INT16 n); 91 #ifdef SUPPORT_MC 92 void LVC_MixSoft_Mc_D16C31_SAT(LVMixer3_1St_FLOAT_st *pInstance, 93 const LVM_FLOAT *src, 94 LVM_FLOAT *dst, 95 LVM_INT16 NrFrames, 96 LVM_INT16 NrChannels); 97 #endif 98 99 void LVC_MixInSoft_D16C31_SAT(LVMixer3_1St_FLOAT_st *pInstance, 100 const LVM_FLOAT *src, 101 LVM_FLOAT *dst, 102 LVM_INT16 n); 103 #ifdef SUPPORT_MC 104 void LVC_MixInSoft_Mc_D16C31_SAT(LVMixer3_1St_FLOAT_st *pInstance, 105 const LVM_FLOAT *src, 106 LVM_FLOAT *dst, 107 LVM_INT16 NrFrames, 108 LVM_INT16 NrChannels); 109 #endif 110 111 void LVC_MixSoft_2St_D16C31_SAT(LVMixer3_2St_FLOAT_st *pInstance, 112 const LVM_FLOAT *src1, 113 const LVM_FLOAT *src2, 114 LVM_FLOAT *dst, /* dst cannot be equal to src2 */ 115 LVM_INT16 n); 116 #ifdef SUPPORT_MC 117 void LVC_MixSoft_2Mc_D16C31_SAT(LVMixer3_2St_FLOAT_st *pInstance, 118 const LVM_FLOAT *src1, 119 const LVM_FLOAT *src2, 120 LVM_FLOAT *dst, /* dst cannot be equal to src2 */ 121 LVM_INT16 NrFrames, 122 LVM_INT16 NrChannels); 123 #endif 124 /**********************************************************************************/ 125 /* For applying different gains to Left and right chennals */ 126 /* MixerStream[0] applies to Left channel */ 127 /* MixerStream[1] applies to Right channel */ 128 /* Gain values should not be more that 1.0 */ 129 /**********************************************************************************/ 130 #ifdef SUPPORT_MC 131 void LVC_MixSoft_1St_MC_float_SAT(LVMixer3_2St_FLOAT_st *pInstance, 132 const LVM_FLOAT *src, 133 LVM_FLOAT *dst, /* dst can be equal to src */ 134 LVM_INT16 NrFrames, 135 LVM_INT32 NrChannels, 136 LVM_INT32 ChMask); 137 #endif 138 void LVC_MixSoft_1St_2i_D16C31_SAT(LVMixer3_2St_FLOAT_st *pInstance, 139 const LVM_FLOAT *src, 140 LVM_FLOAT *dst, /* dst can be equal to src */ 141 LVM_INT16 n); /* Number of stereo samples */ 142 143 /**********************************************************************************/ 144 145 #endif //#ifndef __LVC_MIXER_H__ 146 147