1 #ifndef CYDFX_H
2 #define CYDFX_H
3 
4 /*
5 Copyright (c) 2009-2010 Tero Lindeman (kometbomb)
6 
7 Permission is hereby granted, free of charge, to any person
8 obtaining a copy of this software and associated documentation
9 files (the "Software"), to deal in the Software without
10 restriction, including without limitation the rights to use,
11 copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the
13 Software is furnished to do so, subject to the following
14 conditions:
15 
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 OTHER DEALINGS IN THE SOFTWARE.
27 */
28 
29 #include "cydrvb.h"
30 #include "cydchr.h"
31 #include "cydcrush.h"
32 
33 #define CYD_FX_NAME_LEN 32
34 
35 typedef struct
36 {
37 	Uint32 flags;
38 	CydCrush crush;
39 	CydReverb rvb;
40 	CydChorus chr;
41 } CydFx;
42 
43 /* The following is a non-aligned packed struct for saving in files */
44 typedef struct
45 {
46 	char name[CYD_FX_NAME_LEN + 1];
47 	Uint32 flags; // 4
48 	struct
49 	{
50 		Uint8 bit_drop; // 1
51 	} crush;
52 	struct
53 	{
54 		Uint8 rate, min_delay, max_delay, sep; // 4
55 	} chr;
56 	struct
57 	{
58 		struct { Uint16 delay; Sint16 gain; Uint8 panning; Uint8 flags; } tap[CYDRVB_TAPS];
59 	} rvb;
60 	struct // so we won't fuck up old versions of this struct when freading
61 	{
62 		Uint8 downsample, gain; // 2
63 	} crushex;
64 } __attribute__((__packed__)) CydFxSerialized;
65 
66 #ifdef STEREOOUTPUT
67 void cydfx_output(CydFx *fx, Sint32 fx_l, Sint32 fx_r, Sint32 *left, Sint32 *right);
68 #else
69 Sint32 cydfx_output(CydFx *fx, Sint32 fx_input);
70 #endif
71 void cydfx_init(CydFx *fx, int rate);
72 void cydfx_deinit(CydFx *fx);
73 void cydfx_set(CydFx *fx, const CydFxSerialized *ser);
74 
75 enum
76 {
77 	CYDFX_ENABLE_REVERB = 1,
78 	CYDFX_ENABLE_CRUSH = 2,
79 	CYDFX_ENABLE_CHORUS = 4,
80 	CYDFX_ENABLE_CRUSH_DITHER = 8,
81 };
82 
83 #endif
84