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