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 #else
165 void LVC_MixSoft_1St_D16C31_SAT( LVMixer3_1St_st *pInstance,
166                                   const LVM_INT16           *src,
167                                         LVM_INT16           *dst,
168                                         LVM_INT16           n);
169 #endif
170 
171 #ifdef BUILD_FLOAT
172 void LVC_MixInSoft_D16C31_SAT( LVMixer3_1St_FLOAT_st *pInstance,
173                                LVM_FLOAT           *src,
174                                LVM_FLOAT           *dst,
175                                LVM_INT16           n);
176 #else
177 void LVC_MixInSoft_D16C31_SAT( LVMixer3_1St_st *pInstance,
178                                         LVM_INT16           *src,
179                                         LVM_INT16           *dst,
180                                         LVM_INT16           n);
181 #endif
182 
183 #ifdef BUILD_FLOAT
184 void LVC_MixSoft_2St_D16C31_SAT( LVMixer3_2St_FLOAT_st *pInstance,
185                                  const LVM_FLOAT             *src1,
186                                  LVM_FLOAT             *src2,
187                                  LVM_FLOAT             *dst,  /* dst cannot be equal to src2 */
188                                  LVM_INT16             n);
189 #else
190 void LVC_MixSoft_2St_D16C31_SAT( LVMixer3_2St_st *pInstance,
191                                 const LVM_INT16             *src1,
192                                       LVM_INT16             *src2,
193                                       LVM_INT16             *dst,  /* dst cannot be equal to src2 */
194                                       LVM_INT16             n);
195 #endif
196 /**********************************************************************************/
197 /* For applying different gains to Left and right chennals                        */
198 /* MixerStream[0] applies to Left channel                                         */
199 /* MixerStream[1] applies to Right channel                                        */
200 /* Gain values should not be more that 1.0                                        */
201 /**********************************************************************************/
202 #ifdef BUILD_FLOAT
203 void LVC_MixSoft_1St_2i_D16C31_SAT( LVMixer3_2St_FLOAT_st         *pInstance,
204                                     const   LVM_FLOAT           *src,
205                                     LVM_FLOAT           *dst,   /* dst can be equal to src */
206                                     LVM_INT16           n);     /* Number of stereo samples */
207 #else
208 void LVC_MixSoft_1St_2i_D16C31_SAT( LVMixer3_2St_st         *pInstance,
209                                 const   LVM_INT16           *src,
210                                         LVM_INT16           *dst,   /* dst can be equal to src */
211                                         LVM_INT16           n);     /* Number of stereo samples */
212 #endif
213 #ifdef __cplusplus
214 }
215 #endif /* __cplusplus */
216 
217 /**********************************************************************************/
218 
219 #endif //#ifndef __LVC_MIXER_H__
220 
221