1 /*---------------------------------------------------------------------------*
2   Project: AUX effects for Revolution AX
3   File:    axfx.h
4 
5   Copyright (C)2006 Nintendo  All Rights Reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Log: axfx.h,v $
14   Revision 1.8  06/16/2006 05:33:58  aka
15   Added AXFXGetHooks().
16 
17   Revision 1.7  06/15/2006 02:25:08  aka
18   Added a macro AXFX_VERSION.
19 
20   Revision 1.6  06/15/2006 01:14:29  aka
21   Revised misspelling.
22 
23   Revision 1.5  06/14/2006 02:55:11  aka
24   Added MIN/MAX defines of each params.
25 
26   Revision 1.4  06/09/2006 12:08:42  aka
27   Added AXFX***GetMemSize***().
28 
29   Revision 1.3  06/08/2006 05:59:20  aka
30   Modified for new AXFX made by Kawamura-san (EAD).
31 
32   $NoKeywords: $
33  *---------------------------------------------------------------------------*/
34 
35 #ifndef __AXFX_H__
36 #define __AXFX_H__
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 
43 /*==========================================================================*
44     lib version
45  *==========================================================================*/
46 
47 #define AXFX_VERSION          0x0200      // Version 2.0
48 
49 
50 /*==========================================================================*
51     memory allocation
52  *==========================================================================*/
53 
54 typedef void*   (*AXFXAlloc) (u32);
55 typedef void    (*AXFXFree)  (void*);
56 
57 void AXFXSetHooks(AXFXAlloc  alloc, AXFXFree  free);
58 void AXFXGetHooks(AXFXAlloc *alloc, AXFXFree *free);
59 
60 
61 /*==========================================================================*
62     buffer update
63  *==========================================================================*/
64 
65 /*----------------------------------------------*
66     for mono, stereo, surround
67  *----------------------------------------------*/
68 
69 typedef struct AXFX_BUFFERUPDATE
70 {
71     s32       *left;
72     s32       *right;
73     s32       *surround;
74 
75 } AXFX_BUFFERUPDATE;
76 
77 
78 /*----------------------------------------------*
79     for Dolby prologic2
80  *----------------------------------------------*/
81 
82 typedef struct AXFX_BUFFERUPDATE_DPL2
83 {
84     s32       *L;
85     s32       *R;
86     s32       *Ls;
87     s32       *Rs;
88 
89 } AXFX_BUFFERUPDATE_DPL2;
90 
91 
92 /*==========================================================================*
93     send bus (for connecting FXs)
94  *==========================================================================*/
95 
96 /*----------------------------------------------*
97     for mono, stereo, surround
98  *----------------------------------------------*/
99 
100 typedef struct AXFX_BUS
101 {
102     s32       *left;
103     s32       *right;
104     s32       *surround;
105 
106 } AXFX_BUS;
107 
108 
109 /*----------------------------------------------*
110     for Dolby prologic2
111  *----------------------------------------------*/
112 
113 typedef struct AXFX_BUS_DPL2
114 {
115     s32       *L;
116     s32       *R;
117     s32       *Ls;
118     s32       *Rs;
119 
120 } AXFX_BUS_DPL2;
121 
122 
123 /*==========================================================================*
124   ==========================================================================
125 
126     High Quality Reverb
127 
128   ==========================================================================
129  *==========================================================================*/
130 
131 /*==========================================================================*
132     expanded version
133  *==========================================================================*/
134 
135 // early reflection type
136 #define AXFX_REVERBHI_EXP_EARLY_MODE_5MS           0
137 #define AXFX_REVERBHI_EXP_EARLY_MODE_10MS          1
138 #define AXFX_REVERBHI_EXP_EARLY_MODE_15MS          2
139 #define AXFX_REVERBHI_EXP_EARLY_MODE_20MS          3
140 #define AXFX_REVERBHI_EXP_EARLY_MODE_25MS          4
141 #define AXFX_REVERBHI_EXP_EARLY_MODE_30MS          5
142 #define AXFX_REVERBHI_EXP_EARLY_MODE_35MS          6
143 #define AXFX_REVERBHI_EXP_EARLY_MODE_40MS          7
144 #define AXFX_REVERBHI_EXP_EARLY_MODE_MAX           8
145 
146 // fused reverb type
147 #define AXFX_REVERBHI_EXP_FUSED_MODE_OLD_AXFX      0
148 #define AXFX_REVERBHI_EXP_FUSED_MODE_METAL_TANK    1
149 #define AXFX_REVERBHI_EXP_FUSED_MODE_SMALL_ROOM    2
150 #define AXFX_REVERBHI_EXP_FUSED_MODE_LARGE_ROOM    3
151 #define AXFX_REVERBHI_EXP_FUSED_MODE_HALL          4
152 #define AXFX_REVERBHI_EXP_FUSED_MODE_CAVERNOUS     5
153 #define AXFX_REVERBHI_EXP_FUSED_MODE_LONGEST       6  // do not use this!
154 #define AXFX_REVERBHI_EXP_FUSED_MODE_MAX           7
155 
156 #define AXFX_REVHI_EXP_MIN_PREDELAYTIMEMAX      0.0f
157 //#define AXFX_REVHI_EXP_MAX_PREDELAYTIMEMAX
158 
159 #define AXFX_REVHI_EXP_MIN_PREDELAYTIME         0.0f
160 //#define AXFX_REVHI_EXP_MAX_PREDELAYTIME
161 
162 #define AXFX_REVHI_EXP_MIN_FUSEDTIME            0.0f
163 //#define AXFX_REVHI_EXP_MAX_FUSEDTIME
164 
165 #define AXFX_REVHI_EXP_MIN_COLORATION           0.0f
166 #define AXFX_REVHI_EXP_MAX_COLORATION           1.0f
167 
168 #define AXFX_REVHI_EXP_MIN_DAMPING              0.0f
169 #define AXFX_REVHI_EXP_MAX_DAMPING              1.0f
170 
171 #define AXFX_REVHI_EXP_MIN_CROSSTALK            0.0f
172 #define AXFX_REVHI_EXP_MAX_CROSSTALK            1.0f
173 
174 #define AXFX_REVHI_EXP_MIN_EARLYGAIN            0.0f
175 #define AXFX_REVHI_EXP_MAX_EARLYGAIN            1.0f
176 
177 #define AXFX_REVHI_EXP_MIN_FUSEDGAIN            0.0f
178 #define AXFX_REVHI_EXP_MAX_FUSEDGAIN            1.0f
179 
180 #define AXFX_REVHI_EXP_MIN_OUTGAIN              0.0f
181 #define AXFX_REVHI_EXP_MAX_OUTGAIN              1.0f
182 
183 #define AXFX_REVHI_EXP_MIN_SENDGAIN             0.0f
184 #define AXFX_REVHI_EXP_MAX_SENDGAIN             1.0f
185 
186 /*----------------------------------------------*
187     for mono, stereo, surround
188  *----------------------------------------------*/
189 
190 typedef struct AXFX_REVERBHI_EXP
191 {
192     // do not touch these!
193     f32       *earlyLine[3];
194     u32        earlyPos[3];
195     u32        earlyLength;
196     u32        earlyMaxLength;
197     f32        earlyCoef[3];
198     f32       *preDelayLine[3];
199     u32        preDelayPos;
200     u32        preDelayLength;
201     u32        preDelayMaxLength;
202     f32       *combLine[3][3];
203     u32        combPos[3];
204     u32        combLength[3];
205     u32        combMaxLength[3];
206     f32        combCoef[3];
207     f32       *allpassLine[3][2];
208     u32        allpassPos[2];
209     u32        allpassLength[2];
210     u32        allpassMaxLength[2];
211     f32       *lastAllpassLine[3];
212     u32        lastAllpassPos[3];
213     u32        lastAllpassLength[3];
214     u32        lastAllpassMaxLength[3];
215     f32        allpassCoef;
216     f32        lastLpfOut[3];
217     f32        lpfCoef;
218     u32        active;
219 
220     // user params
221     u32        earlyMode;        // early reflection mode
222     f32        preDelayTimeMax;  // max of pre delay time of fused reverb (sec)
223     f32        preDelayTime;     // pre delay time of fused reverb (sec)
224     u32        fusedMode;        // fused reverb mode
225     f32        fusedTime;        // fused reverb time (sec)
226     f32        coloration;       // coloration of all-pass filter (0.f - 1.f)
227     f32        damping;          // damping of timbre  (0.f - 1.f)
228     f32        crosstalk;        // crosstalk of each channels
229     f32        earlyGain;        // output gain of early reflection (0.f - 1.f)
230     f32        fusedGain;        // output gain of fused reverb (0.f - 1.f)
231 
232     AXFX_BUS  *busIn;
233     AXFX_BUS  *busOut;
234     f32        outGain;
235     f32        sendGain;
236 
237 } AXFX_REVERBHI_EXP;
238 
239 
240 s32  AXFXReverbHiExpGetMemSize     (AXFX_REVERBHI_EXP *reverb);
241 BOOL AXFXReverbHiExpInit           (AXFX_REVERBHI_EXP *reverb);
242 void AXFXReverbHiExpShutdown       (AXFX_REVERBHI_EXP *reverb);
243 BOOL AXFXReverbHiExpSettings       (AXFX_REVERBHI_EXP *reverb);
244 BOOL AXFXReverbHiExpSettingsUpdate (AXFX_REVERBHI_EXP *reverb);
245 void AXFXReverbHiExpCallback       (AXFX_BUFFERUPDATE *bufferUpdate, AXFX_REVERBHI_EXP *reverb);
246 
247 
248 /*----------------------------------------------*
249     for Dolby prologic2
250  *----------------------------------------------*/
251 
252 typedef struct AXFX_REVERBHI_EXP_DPL2
253 {
254     // do not touch these!
255     f32       *earlyLine[4];
256     u32        earlyPos[3];
257     u32        earlyLength;
258     u32        earlyMaxLength;
259     f32        earlyCoef[3];
260     f32       *preDelayLine[4];
261     u32        preDelayPos;
262     u32        preDelayLength;
263     u32        preDelayMaxLength;
264     f32       *combLine[4][3];
265     u32        combPos[3];
266     u32        combLength[3];
267     u32        combMaxLength[3];
268     f32        combCoef[3];
269     f32       *allpassLine[4][2];
270     u32        allpassPos[2];
271     u32        allpassLength[2];
272     u32        allpassMaxLength[2];
273     f32       *lastAllpassLine[4];
274     u32        lastAllpassPos[4];
275     u32        lastAllpassLength[4];
276     u32        lastAllpassMaxLength[4];
277     f32        allpassCoef;
278     f32        lastLpfOut[4];
279     f32        lpfCoef;
280     u32        active;
281 
282     // user params
283     u32        earlyMode;      // early reflection mode
284     f32        preDelayTimeMax;// pre-delay max time of fused reverb (sec)
285     f32        preDelayTime;   // pre-delay time of fused reverb (sec)
286     u32        fusedMode;      // fused reverb mode
287     f32        fusedTime;      // fused reverb time (sec)
288     f32        coloration;     // coloration of all-pass filter (0.f-1.f)
289     f32        damping;        // damping of timbre  (0.f-1.f)
290     f32        crosstalk;      // crosstalk of each channels
291     f32        earlyGain;      // output gain of early reflection(0.f-1.f)
292     f32        fusedGain;      // output gain of fused reverb (0.f-1.f)
293 
294     AXFX_BUS_DPL2 *busIn;
295     AXFX_BUS_DPL2 *busOut;
296     f32        outGain;
297     f32        sendGain;
298 
299 } AXFX_REVERBHI_EXP_DPL2;
300 
301 
302 s32  AXFXReverbHiExpGetMemSizeDpl2     (AXFX_REVERBHI_EXP_DPL2 *reverb);
303 BOOL AXFXReverbHiExpInitDpl2           (AXFX_REVERBHI_EXP_DPL2 *reverb);
304 void AXFXReverbHiExpShutdownDpl2       (AXFX_REVERBHI_EXP_DPL2 *reverb);
305 BOOL AXFXReverbHiExpSettingsDpl2       (AXFX_REVERBHI_EXP_DPL2 *reverb);
306 BOOL AXFXReverbHiExpSettingsUpdateDpl2 (AXFX_REVERBHI_EXP_DPL2 *reverb);
307 void AXFXReverbHiExpCallbackDpl2       (AXFX_BUFFERUPDATE_DPL2 *bufferUpdate, AXFX_REVERBHI_EXP_DPL2 *reverb);
308 
309 
310 /*==========================================================================*
311     classic version
312  *==========================================================================*/
313 
314 #define AXFX_REVHI_MIN_TIME                     0.0f
315 //#define AXFX_REVHI_MAX_TIME
316 
317 #define AXFX_REVHI_MIN_PREDELAY                 0.0f
318 //#define AXFX_REVHI_MAX_PREDELAY
319 
320 #define AXFX_REVHI_MIN_COLORATION               0.0f
321 #define AXFX_REVHI_MAX_COLORATION               1.0f
322 
323 #define AXFX_REVHI_MIN_DAMPING                  0.0f
324 #define AXFX_REVHI_MAX_DAMPING                  1.0f
325 
326 #define AXFX_REVHI_MIN_MIX                      0.0f
327 #define AXFX_REVHI_MAX_MIX                      1.0f
328 
329 #define AXFX_REVHI_MIN_CROSSTALK                0.0f
330 #define AXFX_REVHI_MAX_CROSSTALK                1.0f
331 
332 /*----------------------------------------------*
333     for mono, stereo, surround
334  *----------------------------------------------*/
335 
336 typedef struct AXFX_REVERBHI
337 {
338     // do not write to these
339     AXFX_REVERBHI_EXP  reverbInner;
340 
341     // user params
342     f32        coloration;
343     f32        mix;
344     f32        time;
345     f32        damping;
346     f32        preDelay;
347     f32        crosstalk;
348 
349 } AXFX_REVERBHI;
350 
351 
352 s32  AXFXReverbHiGetMemSize (AXFX_REVERBHI *reverb);
353 BOOL AXFXReverbHiInit       (AXFX_REVERBHI *reverb);
354 BOOL AXFXReverbHiShutdown   (AXFX_REVERBHI *reverb);
355 BOOL AXFXReverbHiSettings   (AXFX_REVERBHI *reverb);
356 void AXFXReverbHiCallback   (AXFX_BUFFERUPDATE *bufferUpdate, AXFX_REVERBHI *reverb);
357 
358 
359 /*----------------------------------------------*
360     for Dolby prologic2
361  *----------------------------------------------*/
362 
363 typedef struct AXFX_REVERBHI_DPL2
364 {
365     // do not write to these
366     AXFX_REVERBHI_EXP_DPL2  reverbInner;
367 
368     // user params
369     f32        coloration;
370     f32        mix;
371     f32        time;
372     f32        damping;
373     f32        preDelay;
374     f32        crosstalk;
375 
376 } AXFX_REVERBHI_DPL2;
377 
378 
379 s32  AXFXReverbHiGetMemSizeDpl2 (AXFX_REVERBHI_DPL2 *reverb);
380 BOOL AXFXReverbHiInitDpl2       (AXFX_REVERBHI_DPL2 *reverb);
381 BOOL AXFXReverbHiShutdownDpl2   (AXFX_REVERBHI_DPL2 *reverb);
382 BOOL AXFXReverbHiSettingsDpl2   (AXFX_REVERBHI_DPL2 *reverb);
383 void AXFXReverbHiCallbackDpl2   (AXFX_BUFFERUPDATE_DPL2 *bufferUpdate, AXFX_REVERBHI_DPL2 *reverb);
384 
385 
386 /*==========================================================================*
387   ==========================================================================
388 
389     Standard Reverb
390 
391   ==========================================================================
392  *==========================================================================*/
393 
394 /*==========================================================================*
395     expanded version
396  *==========================================================================*/
397 
398 // early reflection type
399 #define AXFX_REVERBSTD_EXP_EARLY_MODE_5MS           0
400 #define AXFX_REVERBSTD_EXP_EARLY_MODE_10MS          1
401 #define AXFX_REVERBSTD_EXP_EARLY_MODE_15MS          2
402 #define AXFX_REVERBSTD_EXP_EARLY_MODE_20MS          3
403 #define AXFX_REVERBSTD_EXP_EARLY_MODE_25MS          4
404 #define AXFX_REVERBSTD_EXP_EARLY_MODE_30MS          5
405 #define AXFX_REVERBSTD_EXP_EARLY_MODE_35MS          6
406 #define AXFX_REVERBSTD_EXP_EARLY_MODE_40MS          7
407 #define AXFX_REVERBSTD_EXP_EARLY_MODE_MAX           8
408 
409 // fused reverb type
410 #define AXFX_REVERBSTD_EXP_FUSED_MODE_OLD_AXFX      0
411 #define AXFX_REVERBSTD_EXP_FUSED_MODE_METAL_TANK    1
412 #define AXFX_REVERBSTD_EXP_FUSED_MODE_SMALL_ROOM    2
413 #define AXFX_REVERBSTD_EXP_FUSED_MODE_LARGE_ROOM    3
414 #define AXFX_REVERBSTD_EXP_FUSED_MODE_HALL          4
415 #define AXFX_REVERBSTD_EXP_FUSED_MODE_CAVERNOUS     5
416 #define AXFX_REVERBSTD_EXP_FUSED_MODE_LONGEST       6  // do not use this!
417 #define AXFX_REVERBSTD_EXP_FUSED_MODE_MAX           7
418 
419 
420 #define AXFX_REVSTD_EXP_MIN_PREDELAYTIMEMAX     0.0f
421 //#define AXFX_REVSTD_EXP_MAX_PREDELAYTIMEMAX
422 
423 #define AXFX_REVSTD_EXP_MIN_PREDELAYTIME        0.0f
424 //#define AXFX_REVSTD_EXP_MAX_PREDELAYTIME
425 
426 #define AXFX_REVSTD_EXP_MIN_FUSEDTIME           0.0f
427 //#define AXFX_REVSTD_EXP_MAX_FUSEDTIME
428 
429 #define AXFX_REVSTD_EXP_MIN_COLORATION          0.0f
430 #define AXFX_REVSTD_EXP_MAX_COLORATION          1.0f
431 
432 #define AXFX_REVSTD_EXP_MIN_DAMPING             0.0f
433 #define AXFX_REVSTD_EXP_MAX_DAMPING             1.0f
434 
435 #define AXFX_REVSTD_EXP_MIN_EARLYGAIN           0.0f
436 #define AXFX_REVSTD_EXP_MAX_EARLYGAIN           1.0f
437 
438 #define AXFX_REVSTD_EXP_MIN_FUSEDGAIN           0.0f
439 #define AXFX_REVSTD_EXP_MAX_FUSEDGAIN           1.0f
440 
441 #define AXFX_REVSTD_EXP_MIN_OUTGAIN             0.0f
442 #define AXFX_REVSTD_EXP_MAX_OUTGAIN             1.0f
443 
444 #define AXFX_REVSTD_EXP_MIN_SENDGAIN            0.0f
445 #define AXFX_REVSTD_EXP_MAX_SENDGAIN            1.0f
446 
447 /*----------------------------------------------*
448     for mono, stereo, surround
449  *----------------------------------------------*/
450 
451 typedef struct AXFX_REVERBSTD_EXP
452 {
453     // do not touch these!
454     f32       *earlyLine[3];
455     u32        earlyPos;
456     u32        earlyLength;
457     u32        earlyMaxLength;
458     f32        earlyCoef;
459     f32       *preDelayLine[3];
460     u32        preDelayPos;
461     u32        preDelayLength;
462     u32        preDelayMaxLength;
463     f32       *combLine[3][2];
464     u32        combPos[2];
465     u32        combLength[2];
466     u32        combMaxLength[2];
467     f32        combCoef[2];
468     f32       *allpassLine[3][2];
469     u32        allpassPos[2];
470     u32        allpassLength[2];
471     u32        allpassMaxLength[2];
472     f32        allpassCoef;
473     f32        lastLpfOut[3];
474     f32        lpfCoef;
475     u32        active;
476 
477     // user params
478     u32        earlyMode;        // early reflection mode
479     f32        preDelayTimeMax;  // pre-delay max time of fused reverb (sec)
480     f32        preDelayTime;     // pre-delay time of fused reverb (sec)
481     u32        fusedMode;        // fused reverb mode
482     f32        fusedTime;        // fused reverb time (sec)
483     f32        coloration;       // coloration of all-pass filter (0.f - 1.f)
484     f32        damping;          // damping of timbre  (0.f - 1.f)
485     f32        earlyGain;        // output gain of early reflection (0.f - 1.f)
486     f32        fusedGain;        // output gain of fused reverb (0.f - 1.f)
487 
488     AXFX_BUS  *busIn;
489     AXFX_BUS  *busOut;
490     f32        outGain;
491     f32        sendGain;
492 
493 } AXFX_REVERBSTD_EXP;
494 
495 
496 s32  AXFXReverbStdExpGetMemSize     (AXFX_REVERBSTD_EXP *reverb);
497 BOOL AXFXReverbStdExpInit           (AXFX_REVERBSTD_EXP *reverb);
498 void AXFXReverbStdExpShutdown       (AXFX_REVERBSTD_EXP *reverb);
499 BOOL AXFXReverbStdExpSettings       (AXFX_REVERBSTD_EXP *reverb);
500 BOOL AXFXReverbStdExpSettingsUpdate (AXFX_REVERBSTD_EXP *reverb);
501 void AXFXReverbStdExpCallback       (AXFX_BUFFERUPDATE *bufferUpdate, AXFX_REVERBSTD_EXP *reverb);
502 
503 
504 /*----------------------------------------------*
505     for Dolby prologic2
506  *----------------------------------------------*/
507 
508 typedef struct AXFX_REVERBSTD_EXP_DPL2
509 {
510     // do not touch these!
511     f32       *earlyLine[4];
512     u32        earlyPos;
513     u32        earlyLength;
514     u32        earlyMaxLength;
515     f32        earlyCoef;
516     f32       *preDelayLine[4];
517     u32        preDelayPos;
518     u32        preDelayLength;
519     u32        preDelayMaxLength;
520     f32       *combLine[4][2];
521     u32        combPos[2];
522     u32        combLength[2];
523     u32        combMaxLength[2];
524     f32        combCoef[2];
525     f32       *allpassLine[4][2];
526     u32        allpassPos[2];
527     u32        allpassLength[2];
528     u32        allpassMaxLength[2];
529     f32        allpassCoef;
530     f32        lastLpfOut[4];
531     f32        lpfCoef;
532     u32        active;
533 
534     // user params
535     u32        earlyMode;      // early reflection mode
536     f32        preDelayTimeMax;// pre-delay max time of fused reverb(sec)
537     f32        preDelayTime;   // pre-delay time of fused reverb (sec)
538     u32        fusedMode;      // fused reverb mode
539     f32        fusedTime;      // fused reverb time (sec)
540     f32        coloration;     // coloration of all-pass filter (0.f-1.f)
541     f32        damping;        // damping of timbre  (0.f-1.f)
542     f32        earlyGain;      // output gain of early reflection(0.f-1.f)
543     f32        fusedGain;      // output gain of fused reverb (0.f-1.f)
544 
545     AXFX_BUS_DPL2 *busIn;
546     AXFX_BUS_DPL2 *busOut;
547     f32        outGain;
548     f32        sendGain;
549 
550 } AXFX_REVERBSTD_EXP_DPL2;
551 
552 
553 s32  AXFXReverbStdExpGetMemSizeDpl2     (AXFX_REVERBSTD_EXP_DPL2 *reverb);
554 BOOL AXFXReverbStdExpInitDpl2           (AXFX_REVERBSTD_EXP_DPL2 *reverb);
555 void AXFXReverbStdExpShutdownDpl2       (AXFX_REVERBSTD_EXP_DPL2 *reverb);
556 BOOL AXFXReverbStdExpSettingsDpl2       (AXFX_REVERBSTD_EXP_DPL2 *reverb);
557 BOOL AXFXReverbStdExpSettingsUpdateDpl2 (AXFX_REVERBSTD_EXP_DPL2 *reverb);
558 void AXFXReverbStdExpCallbackDpl2       (AXFX_BUFFERUPDATE_DPL2 *bufferUpdate, AXFX_REVERBSTD_EXP_DPL2 *reverb);
559 
560 
561 /*==========================================================================*
562     classic version
563  *==========================================================================*/
564 
565 #define AXFX_REVSTD_MIN_TIME                    0.0f
566 //#define AXFX_REVSTD_MAX_TIME
567 
568 #define AXFX_REVSTD_MIN_PREDELAY                0.0f
569 //#define AXFX_REVSTD_MAX_PREDELAY
570 
571 #define AXFX_REVSTD_MIN_COLORATION              0.0f
572 #define AXFX_REVSTD_MAX_COLORATION              1.0f
573 
574 #define AXFX_REVSTD_MIN_DAMPING                 0.0f
575 #define AXFX_REVSTD_MAX_DAMPING                 1.0f
576 
577 #define AXFX_REVSTD_MIN_MIX                     0.0f
578 #define AXFX_REVSTD_MAX_MIX                     1.0f
579 
580 /*----------------------------------------------*
581     for mono, stereo, surround
582  *----------------------------------------------*/
583 
584 typedef struct AXFX_REVERBSTD
585 {
586     AXFX_REVERBSTD_EXP  reverbInner;
587 
588     // user params
589     f32    coloration;
590     f32    mix;
591     f32    time;
592     f32    damping;
593     f32    preDelay;
594 
595 } AXFX_REVERBSTD;
596 
597 
598 s32  AXFXReverbStdGetMemSize (AXFX_REVERBSTD *reverb);
599 BOOL AXFXReverbStdInit       (AXFX_REVERBSTD *reverb);
600 BOOL AXFXReverbStdShutdown   (AXFX_REVERBSTD *reverb);
601 BOOL AXFXReverbStdSettings   (AXFX_REVERBSTD *reverb);
602 void AXFXReverbStdCallback   (AXFX_BUFFERUPDATE *bufferUpdate, AXFX_REVERBSTD *reverb);
603 
604 
605 /*----------------------------------------------*
606     for Dolby prologic2
607  *----------------------------------------------*/
608 
609 typedef struct AXFX_REVERBSTD_DPL2
610 {
611     AXFX_REVERBSTD_EXP_DPL2  reverbInner;
612 
613     // user params
614     f32        coloration;
615     f32        mix;
616     f32        time;
617     f32        damping;
618     f32        preDelay;
619 
620 } AXFX_REVERBSTD_DPL2;
621 
622 
623 s32  AXFXReverbStdGetMemSizeDpl2 (AXFX_REVERBSTD_DPL2 *reverb);
624 BOOL AXFXReverbStdInitDpl2       (AXFX_REVERBSTD_DPL2 *reverb);
625 BOOL AXFXReverbStdShutdownDpl2   (AXFX_REVERBSTD_DPL2 *reverb);
626 BOOL AXFXReverbStdSettingsDpl2   (AXFX_REVERBSTD_DPL2 *reverb);
627 void AXFXReverbStdCallbackDpl2   (AXFX_BUFFERUPDATE_DPL2 *bufferUpdate, AXFX_REVERBSTD_DPL2 *reverb);
628 
629 
630 /*==========================================================================*
631   ==========================================================================
632 
633     Delay
634 
635   ==========================================================================
636  *==========================================================================*/
637 
638 /*==========================================================================*
639     expanded version
640  *==========================================================================*/
641 
642 #define AXFX_DELAY_EXP_MIN_MAXDELAY             0.04f // 0.0f < maxDelay
643 //#define AXFX_DELAY_EXP_MAX_MAXDELAY
644 
645 #define AXFX_DELAY_EXP_MIN_DELAY                0.04f
646 //#define AXFX_DELAY_EXP_MAX_DELAY
647 
648 #define AXFX_DELAY_EXP_MIN_FEEDBACK             0.0f
649 #define AXFX_DELAY_EXP_MAX_FEEDBACK             0.99f // feedback < 1.0f
650 
651 #define AXFX_DELAY_EXP_MIN_LPF                  0.0f
652 #define AXFX_DELAY_EXP_MAX_LPF                  1.0f
653 
654 #define AXFX_DELAY_EXP_MIN_OUTGAIN              0.0f
655 #define AXFX_DELAY_EXP_MAX_OUTGAIN              1.0f
656 
657 #define AXFX_DELAY_EXP_MIN_SENDGAIN             0.0f
658 #define AXFX_DELAY_EXP_MAX_SENDGAIN             1.0f
659 
660 /*----------------------------------------------*
661     for mono, stereo, surround
662  *----------------------------------------------*/
663 
664 typedef struct AXFX_DELAY_EXP
665 {
666     // do not touch these!
667     s32       *lineL;
668     s32       *lineR;
669     s32       *lineS;
670     u32        curPos;
671     u32        length;
672     u32        maxLength;
673     s32        feedbackGain;
674     s32        lastLpfOut[3];
675     s32        lpfCoef;
676     s32        outGainCalc;
677     s32        sendGainCalc;
678     u32        active;
679 
680     // user params
681     f32        maxDelay;  // max delay time (msec) (>0.f)
682     f32        delay;     // delay time (msec) (0.f< - <=maxDelay)
683     f32        feedback;  // feedback gain (0.f - <1.f)
684     f32        lpf;       // LPF param (0.f - 1.f) (cutoff : low - high)
685 
686     AXFX_BUS  *busIn;
687     AXFX_BUS  *busOut;
688     f32        outGain;
689     f32        sendGain;
690 
691 } AXFX_DELAY_EXP;
692 
693 
694 s32  AXFXDelayExpGetMemSize     (AXFX_DELAY_EXP *delay);
695 BOOL AXFXDelayExpInit           (AXFX_DELAY_EXP *delay);
696 void AXFXDelayExpShutdown       (AXFX_DELAY_EXP *delay);
697 BOOL AXFXDelayExpSettings       (AXFX_DELAY_EXP *delay);
698 BOOL AXFXDelayExpSettingsUpdate (AXFX_DELAY_EXP *delay);
699 void AXFXDelayExpCallback       (AXFX_BUFFERUPDATE *bufferUpdate, AXFX_DELAY_EXP *delay);
700 
701 
702 /*----------------------------------------------*
703     for Dolby prologic2
704  *----------------------------------------------*/
705 
706 typedef struct AXFX_DELAY_EXP_DPL2
707 {
708     // do not touch these!
709     s32       *line[4];
710     u32        curPos;
711     u32        length;
712     u32        maxLength;
713     s32        feedbackGain;
714     s32        lastLpfOut[4];
715     s32        lpfCoef;
716     s32        outGainCalc;
717     s32        sendGainCalc;
718     u32        active;
719 
720     // user params
721     f32        maxDelay;  // max delay time (msec) (>0.f)
722     f32        delay;     // delay time (msec) (0.f< - <=maxDelay)
723     f32        feedback;  // feedback gain (0.f - <1.f)
724     f32        lpf;       // LPF param (0.f - 1.f) (cutoff : low - high)
725 
726     AXFX_BUS_DPL2 *busIn;
727     AXFX_BUS_DPL2 *busOut;
728     f32        outGain;
729     f32        sendGain;
730 
731 } AXFX_DELAY_EXP_DPL2;
732 
733 
734 s32  AXFXDelayExpGetMemSizeDpl2     (AXFX_DELAY_EXP_DPL2 *delay);
735 BOOL AXFXDelayExpInitDpl2           (AXFX_DELAY_EXP_DPL2 *delay);
736 void AXFXDelayExpShutdownDpl2       (AXFX_DELAY_EXP_DPL2 *delay);
737 BOOL AXFXDelayExpSettingsDpl2       (AXFX_DELAY_EXP_DPL2 *delay);
738 BOOL AXFXDelayExpSettingsUpdateDpl2 (AXFX_DELAY_EXP_DPL2 *delay);
739 void AXFXDelayExpCallbackDpl2       (AXFX_BUFFERUPDATE_DPL2 *bufferUpdate, AXFX_DELAY_EXP_DPL2 *delay);
740 
741 
742 /*==========================================================================*
743     classic version
744  *==========================================================================*/
745 
746 #define AXFX_DELAY_MIN_DELAY                    1
747 //#define AXFX_DELAY_MAX_DELAY
748 
749 #define AXFX_DELAY_MIN_FEEDBACK                 0
750 #define AXFX_DELAY_MAX_FEEDBACK                99
751 
752 #define AXFX_DELAY_MIN_OUTPUT                   0
753 #define AXFX_DELAY_MAX_OUTPUT                 100
754 
755 /*----------------------------------------------*
756     for mono, stereo, surround
757  *----------------------------------------------*/
758 
759 typedef struct AXFX_DELAY
760 {
761     // do not touch these!
762     s32       *line[3];
763     u32        curPos[3];
764     u32        length[3];
765     s32        feedbackGain[3];
766     s32        outGain[3];
767     u32        active;
768 
769     // user params
770     u32        delay[3];       // Delay buffer length in ms per channel
771     u32        feedback[3];    // Feedback volume in % per channel
772     u32        output[3];      // Output volume in % per channel
773 
774 } AXFX_DELAY;
775 
776 
777 s32  AXFXDelayGetMemSize (AXFX_DELAY *delay);
778 BOOL AXFXDelayInit       (AXFX_DELAY *delay);
779 void AXFXDelayShutdown   (AXFX_DELAY *delay);
780 BOOL AXFXDelaySettings   (AXFX_DELAY *delay);
781 void AXFXDelayCallback   (AXFX_BUFFERUPDATE *bufferUpdate, AXFX_DELAY *delay);
782 
783 
784 /*----------------------------------------------*
785     for Dolby prologic2
786  *----------------------------------------------*/
787 
788 typedef struct AXFX_DELAY_DPL2
789 {
790     // do not touch these!
791     s32       *line[4];
792     u32        curPos[4];
793     u32        length[4];
794     s32        feedbackGain[4];
795     s32        outGain[4];
796     u32        active;
797 
798     // user params
799     u32        delay[4];       // Delay buffer length in ms per channel
800     u32        feedback[4];    // Feedback volume in % per channel
801     u32        output[4];      // Output volume in % per channel
802 
803 } AXFX_DELAY_DPL2;
804 
805 
806 s32  AXFXDelayGetMemSizeDpl2 (AXFX_DELAY_DPL2 *delay);
807 BOOL AXFXDelayInitDpl2       (AXFX_DELAY_DPL2 *delay);
808 void AXFXDelayShutdownDpl2   (AXFX_DELAY_DPL2 *delay);
809 BOOL AXFXDelaySettingsDpl2   (AXFX_DELAY_DPL2 *delay);
810 void AXFXDelayCallbackDpl2   (AXFX_BUFFERUPDATE_DPL2 *bufferUpdate, AXFX_DELAY_DPL2 *delay);
811 
812 
813 /*==========================================================================*
814   ==========================================================================
815 
816     Chorus
817 
818   ==========================================================================
819  *==========================================================================*/
820 
821 /*==========================================================================*
822     expanded version
823  *==========================================================================*/
824 
825 #define AXFX_CHORUS_EXP_MIN_DELAYTIME           0.1f
826 #define AXFX_CHORUS_EXP_MAX_DELAYTIME          50.0f
827 
828 #define AXFX_CHORUS_EXP_MIN_DEAPTH              0.0f
829 #define AXFX_CHORUS_EXP_MAX_DEAPTH              1.0f
830 
831 #define AXFX_CHORUS_EXP_MIN_RATE                0.1f
832 #define AXFX_CHORUS_EXP_MAX_RATE                2.0f
833 
834 #define AXFX_CHORUS_EXP_MIN_FEEDBACK            0.0f
835 #define AXFX_CHORUS_EXP_MAX_FEEDBACK            0.99f // feedback < 1.0f
836 
837 #define AXFX_CHORUS_EXP_MIN_OUTGAIN             0.0f
838 #define AXFX_CHORUS_EXP_MAX_OUTGAIN             1.0f
839 
840 #define AXFX_CHORUS_EXP_MIN_SENDGAIN            0.0f
841 #define AXFX_CHORUS_EXP_MAX_SENDGAIN            1.0f
842 
843 /*----------------------------------------------*
844     for mono, stereo, surround
845  *----------------------------------------------*/
846 
847 typedef struct AXFX_CHORUS_EXP_DELAY
848 {
849     f32       *line[3];
850     u32        inPos;
851     u32        outPos;
852     u32        lastPos;
853     u32        sizeFP;
854     u32        size;
855 
856 } AXFX_CHORUS_EXP_DELAY;
857 
858 
859 typedef struct AXFX_CHORUS_EXP_LFO
860 {
861     s32       *table;
862     s32        phaseAdd;
863     s32        stepSamp;
864     s32        depthSamp;
865     u32        phase;
866     u32        sign;
867     u32        lastNum;
868     s32        lastValue;
869     s32        grad;
870     s32        gradFactor;
871 
872 } AXFX_CHORUS_EXP_LFO;
873 
874 
875 typedef struct AXFX_CHORUS_EXP
876 {
877     // don't touch these
878     AXFX_CHORUS_EXP_DELAY  delay;
879     AXFX_CHORUS_EXP_LFO    lfo;
880     f32        history[3][4];
881     u32        histIndex;
882     u32        active;
883 
884     // user params
885     f32        delayTime;   // 0.1 - 50.f (msec)
886     f32        depth;       // 0.f - 1.f
887     f32        rate;        // 0.1 - 2.f (Hz)
888     f32        feedback;    // 0.f - < 1.f
889 
890     AXFX_BUS  *busIn;
891     AXFX_BUS  *busOut;
892     f32        outGain;
893     f32        sendGain;
894 
895 } AXFX_CHORUS_EXP;
896 
897 
898 s32  AXFXChorusExpGetMemSize     (AXFX_CHORUS_EXP *chorus);
899 BOOL AXFXChorusExpInit           (AXFX_CHORUS_EXP *chorus);
900 BOOL AXFXChorusExpSettings       (AXFX_CHORUS_EXP *chorus);
901 BOOL AXFXChorusExpSettingsUpdate (AXFX_CHORUS_EXP *chorus);
902 void AXFXChorusExpShutdown       (AXFX_CHORUS_EXP *chorus);
903 void AXFXChorusExpCallback       (AXFX_BUFFERUPDATE *bufferUpdate, AXFX_CHORUS_EXP *chorus);
904 
905 
906 /*----------------------------------------------*
907     for Dolby prologic2
908  *----------------------------------------------*/
909 
910 typedef struct AXFX_CHORUS_EXP_DELAY_DPL2
911 {
912     f32       *line[4];
913     u32        inPos;
914     u32        outPos;
915     u32        lastPos;
916     u32        sizeFP;
917     u32        size;
918 
919 } AXFX_CHORUS_EXP_DELAY_DPL2;
920 
921 
922 typedef struct AXFX_CHORUS_EXP_LFO_DPL2
923 {
924     s32       *table;
925     s32        phaseAdd;
926     s32        stepSamp;
927     s32        depthSamp;
928     u32        phase;
929     u32        sign;
930     u32        lastNum;
931     s32        lastValue;
932     s32        grad;
933     s32        gradFactor;
934 
935 } AXFX_CHORUS_EXP_LFO_DPL2;
936 
937 
938 typedef struct AXFX_CHORUS_EXP_DPL2
939 {
940     // don't touch these
941     AXFX_CHORUS_EXP_DELAY_DPL2  delay;
942     AXFX_CHORUS_EXP_LFO_DPL2    lfo;
943     f32        history[4][4];
944     u32        histIndex;
945     u32        active;
946 
947     // user params
948     f32        delayTime;   // 0.1 - 50.f (msec)
949     f32        depth;       // 0.f - 1.f
950     f32        rate;        // 0.1f - 2.f (Hz)
951     f32        feedback;    // 0.f - < 1.f
952 
953     AXFX_BUS_DPL2 *busIn;
954     AXFX_BUS_DPL2 *busOut;
955     f32        outGain;
956     f32        sendGain;
957 
958 } AXFX_CHORUS_EXP_DPL2;
959 
960 
961 s32  AXFXChorusExpGetMemSizeDpl2     (AXFX_CHORUS_EXP_DPL2 *chorus);
962 BOOL AXFXChorusExpInitDpl2           (AXFX_CHORUS_EXP_DPL2 *chorus);
963 BOOL AXFXChorusExpSettingsDpl2       (AXFX_CHORUS_EXP_DPL2 *chorus);
964 BOOL AXFXChorusExpSettingsUpdateDpl2 (AXFX_CHORUS_EXP_DPL2 *chorus);
965 void AXFXChorusExpShutdownDpl2       (AXFX_CHORUS_EXP_DPL2 *chorus);
966 void AXFXChorusExpCallbackDpl2       (AXFX_BUFFERUPDATE_DPL2 *bufferUpdate, AXFX_CHORUS_EXP_DPL2 *chorus);
967 
968 
969 /*==========================================================================*
970     classic version
971  *==========================================================================*/
972 
973 #define AXFX_CHORUS_MIN_DELAY                   1
974 #define AXFX_CHORUS_MAX_DELAY                  50
975 
976 #define AXFX_CHORUS_MIN_VARIATION               0
977 #define AXFX_CHORUS_MAX_VARIATION              50
978 
979 #define AXFX_CHORUS_MIN_PERIOD                500
980 #define AXFX_CHORUS_MAX_PERIOD              10000
981 
982 /*----------------------------------------------*
983     for mono, stereo, surround
984  *----------------------------------------------*/
985 
986 typedef struct AXFX_CHORUS
987 {
988     AXFX_CHORUS_EXP  chorusInner;
989 
990     // user params
991     u32        baseDelay;      // Base delay of chorus effect in ms
992     u32        variation;      // Variation of base delay in ms
993     u32        period;         // Period of varying oscillation in ms
994 
995 } AXFX_CHORUS;
996 
997 
998 s32  AXFXChorusGetMemSize (AXFX_CHORUS *chorus);
999 BOOL AXFXChorusInit       (AXFX_CHORUS *chorus);
1000 BOOL AXFXChorusShutdown   (AXFX_CHORUS *chorus);
1001 BOOL AXFXChorusSettings   (AXFX_CHORUS *chorus);
1002 void AXFXChorusCallback   (AXFX_BUFFERUPDATE *bufferUpdate, AXFX_CHORUS *chorus);
1003 
1004 /*----------------------------------------------*
1005     for Dolby prologic2
1006  *----------------------------------------------*/
1007 
1008 typedef struct AXFX_CHORUS_DPL2
1009 {
1010     AXFX_CHORUS_EXP_DPL2  chorusInner;
1011 
1012     // user params
1013     u32        baseDelay;      // Base delay of chorus effect in ms
1014     u32        variation;      // Variation of base delay in ms
1015     u32        period;         // Period of varying oscillation in ms
1016 
1017 } AXFX_CHORUS_DPL2;
1018 
1019 
1020 s32  AXFXChorusGetMemSizeDpl2 (AXFX_CHORUS_DPL2 *chorus);
1021 BOOL AXFXChorusInitDpl2       (AXFX_CHORUS_DPL2 *chorus);
1022 BOOL AXFXChorusShutdownDpl2   (AXFX_CHORUS_DPL2 *chorus);
1023 BOOL AXFXChorusSettingsDpl2   (AXFX_CHORUS_DPL2 *chorus);
1024 void AXFXChorusCallbackDpl2   (AXFX_BUFFERUPDATE_DPL2 *bufferUpdate, AXFX_CHORUS_DPL2 *chorus);
1025 
1026 
1027 #ifdef __cplusplus
1028 }
1029 #endif
1030 
1031 #endif // __AXFX_H__
1032