2 AHI - Hardware independent audio subsystem
3 Copyright (C) 1996-2005 Martin Blom <martin@blom.org>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, Cambridge,
25 #include "dspechofuncs.h"
28 * Inputs: ahiede_Delay, ahiede_Feedback, ahiede_Mix, ahiede_Cross
33 * FeedbackDO = ahide_Feedback*ahide_Cross
34 * FeedbackDS = ahide_Feedback*(1-ahide_Cross)
35 * FeedbackNO = (1-ahide_Feedback)*ahide_Cross
36 * FeedbackNS = (1-ahide_Feedback)*(1-ahide_Cross)
39 * left in ->---+----------+---------------------| >---->(+)----> left out
41 * FeedbackNO \¯/ \¯/ FeedbackNS |
45 * | +--->(+)-->| T |----+-------| >------+
46 * | | ^ |___| | MixD |/
54 * (+)<--(-----------< |-----+
60 * | (+)<---------< |-----+
68 * +----(--->(+)-->| T |----+-------| >------+
72 * FeedbackNO /_\ /_\ FeedbackNS |
74 * right in ->-------+-----+---------------------| >---->(+)----> right out
80 EchoMono16( LONG loops
,
88 LONG sample
, delaysample
;
99 *buf
++ = ( es
->ahiecho_MixN
* sample
+ es
->ahiecho_MixD
* delaysample
) >> 16;
101 sample
= es
->ahiecho_FeedbackNS
* sample
+
102 es
->ahiecho_FeedbackDS
* (delaysample
+ 1);
104 *dst
++ = sample
>> 16;
116 EchoStereo16( LONG loops
,
124 LONG sample
, sampleL
, sampleR
, delaysampleL
, delaysampleR
;
133 delaysampleL
= *src
++;
135 *buf
++ = ( es
->ahiecho_MixN
* sampleL
+ es
->ahiecho_MixD
* delaysampleL
) >> 16;
138 delaysampleR
= *src
++;
140 *buf
++ = ( es
->ahiecho_MixN
* sampleR
+ es
->ahiecho_MixD
* delaysampleR
) >> 16;
142 sample
= es
->ahiecho_FeedbackDS
* (delaysampleL
+ 1) +
143 es
->ahiecho_FeedbackDO
* (delaysampleR
+ 1) +
144 es
->ahiecho_FeedbackNS
* sampleL
+
145 es
->ahiecho_FeedbackNO
* sampleR
;
147 *dst
++ = sample
>> 16;
149 sample
= es
->ahiecho_FeedbackDO
* (delaysampleL
+ 1) +
150 es
->ahiecho_FeedbackDS
* (delaysampleR
+ 1) +
151 es
->ahiecho_FeedbackNO
* sampleL
+
152 es
->ahiecho_FeedbackNS
* sampleR
;
154 *dst
++ = sample
>> 16;
166 EchoMono32 ( LONG loops
,
174 LONG sample
, delaysample
;
183 delaysample
= *src
++;
185 *buf
++ = es
->ahiecho_MixN
* sample
+ es
->ahiecho_MixD
* delaysample
;
187 sample
= es
->ahiecho_FeedbackNS
* sample
+
188 es
->ahiecho_FeedbackDS
* (delaysample
+ 1);
190 *dst
++ = sample
>> 16;
202 EchoStereo32 ( LONG loops
,
210 LONG sample
, sampleL
, sampleR
, delaysampleL
, delaysampleR
;
218 sampleL
= *buf
>> 16;
219 delaysampleL
= *src
++;
221 *buf
++ = es
->ahiecho_MixN
* sampleL
+ es
->ahiecho_MixD
* delaysampleL
;
223 sampleR
= *buf
>> 16;
224 delaysampleR
= *src
++;
226 *buf
++ = es
->ahiecho_MixN
* sampleR
+ es
->ahiecho_MixD
* delaysampleR
;
228 sample
= es
->ahiecho_FeedbackDS
* (delaysampleL
+ 1) +
229 es
->ahiecho_FeedbackDO
* (delaysampleR
+ 1) +
230 es
->ahiecho_FeedbackNS
* sampleL
+
231 es
->ahiecho_FeedbackNO
* sampleR
;
233 *dst
++ = sample
>> 16;
235 sample
= es
->ahiecho_FeedbackDO
* (delaysampleL
+ 1) +
236 es
->ahiecho_FeedbackDS
* (delaysampleR
+ 1) +
237 es
->ahiecho_FeedbackNO
* sampleL
+
238 es
->ahiecho_FeedbackNS
* sampleR
;
240 *dst
++ = sample
>> 16;
252 EchoMulti32 ( LONG loops
,
260 LONG sample
, sampleL
, sampleR
, delaysampleL
, delaysampleR
;
268 sampleL
= *buf
>> 16;
269 delaysampleL
= *src
++;
271 *buf
++ = es
->ahiecho_MixN
* sampleL
+ es
->ahiecho_MixD
* delaysampleL
;
273 sampleR
= *buf
>> 16;
274 delaysampleR
= *src
++;
276 *buf
++ = es
->ahiecho_MixN
* sampleR
+ es
->ahiecho_MixD
* delaysampleR
;
278 sample
= es
->ahiecho_FeedbackDS
* (delaysampleL
+ 1) +
279 es
->ahiecho_FeedbackDO
* (delaysampleR
+ 1) +
280 es
->ahiecho_FeedbackNS
* sampleL
+
281 es
->ahiecho_FeedbackNO
* sampleR
;
283 *dst
++ = sample
>> 16;
285 sample
= es
->ahiecho_FeedbackDO
* (delaysampleL
+ 1) +
286 es
->ahiecho_FeedbackDS
* (delaysampleR
+ 1) +
287 es
->ahiecho_FeedbackNO
* sampleL
+
288 es
->ahiecho_FeedbackNS
* sampleR
;
290 *dst
++ = sample
>> 16;
292 // Skip unused channels