• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    INCLUDE FILES
20 ***********************************************************************************/
21 
22 #include "VectorArithmetic.h"
23 
DelayMix_Float(const LVM_FLOAT * src,LVM_FLOAT * delay,LVM_INT16 size,LVM_FLOAT * dst,LVM_INT16 * pOffset,LVM_INT16 n,LVM_INT32 NrChannels)24 void DelayMix_Float(const LVM_FLOAT* src, /* Source 1, to be delayed */
25                     LVM_FLOAT* delay,     /* Delay buffer */
26                     LVM_INT16 size,       /* Delay size */
27                     LVM_FLOAT* dst,       /* Source/destination */
28                     LVM_INT16* pOffset,   /* Delay offset */
29                     LVM_INT16 n,          /* Number of samples */
30                     LVM_INT32 NrChannels) /* Number of channels */
31 {
32     LVM_INT16 i;
33     LVM_INT16 Offset = *pOffset;
34     LVM_FLOAT temp;
35 
36     for (i = 0; i < n; i++) {
37         if (NrChannels == FCC_1) {
38             temp = (LVM_FLOAT)(*dst + (LVM_FLOAT)delay[Offset]) / 2.0f;
39             *dst = temp;
40             dst++;
41 
42             delay[Offset] = *src;
43             Offset++;
44             src++;
45 
46             /* Make the reverb delay buffer a circular buffer */
47             if (Offset >= size) {
48                 Offset = 0;
49             }
50         } else {
51             /* Left channel */
52             temp = (LVM_FLOAT)(*dst + (LVM_FLOAT)delay[Offset]) / 2.0f;
53             *dst = temp;
54             dst++;
55 
56             delay[Offset] = *src;
57             Offset++;
58             src++;
59 
60             /* Right channel */
61             temp = (LVM_FLOAT)(*dst - (LVM_FLOAT)delay[Offset]) / 2.0f;
62             *dst = temp;
63             dst++;
64 
65             delay[Offset] = *src;
66             Offset++;
67             src++;
68 
69             /* Make the reverb delay buffer a circular buffer */
70             if (Offset >= size) {
71                 Offset = 0;
72             }
73         }
74     }
75 
76     /* Update the offset */
77     *pOffset = Offset;
78 
79     return;
80 }
81