AEReverb.c++
4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*****************************************************************************
* File: AEReverb.c++
*
* AEReverb Class Implementations
*
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "Assets.h"
#include "Mgrs.h"
/*****************************************************************************
*
* Initialization Routines
*
****************************************************************************/
AEReverb::AEReverb()
{
type = AL_FX_NONE;
params = 0;
maxParam = 0;
}
AEReverb::~AEReverb()
{
}
/*****************************************************************************
*
* Asset's Methods
*
****************************************************************************/
#define ms *(((s32)((f32)44.1))&~0x7)
s32 SMALLROOM_PARAMS[26] = {
/* sections length */
3, 100 ms,
/* chorus chorus filter
input output fbcoef ffcoef gain rate depth coef */
0, 54 ms, 9830, -9830, 0, 0, 0, 0,
19 ms, 38 ms, 3276, -3276, 0x3fff, 0, 0, 0,
0, 60 ms, 5000, 0, 0, 0, 0, 0x5000
};
s32 BIGROOM_PARAMS[34] = {
/* sections length */
4, 100 ms,
/* chorus chorus filter
input output fbcoef ffcoef gain rate depth coef */
0, 66 ms, 9830, -9830, 0, 0, 0, 0,
22 ms, 54 ms, 3276, -3276, 0x3fff, 0, 0, 0,
66 ms, 91 ms, 3276, -3276, 0x3fff, 0, 0, 0,
0, 94 ms, 8000, 0, 0, 0, 0, 0x5000
};
s32 ECHO_PARAMS[10] = {
/* sections length */
1, 200 ms,
/* chorus chorus filter
input output fbcoef ffcoef gain rate depth coef */
0, 179 ms, 12000, 0, 0x7fff, 0, 0, 0
};
s32 CHORUS_PARAMS[10] = {
/* sections length */
1, 20 ms,
/* chorus chorus filter
input output fbcoef ffcoef gain rate depth coef */
0, 5 ms, 0x4000, 0, 0x7fff, 7600, 700, 0
};
s32 FLANGE_PARAMS[10] = {
/* sections length */
1, 20 ms,
/* chorus chorus filter
input output fbcoef ffcoef gain rate depth coef */
0, 5 ms, 0, 0x5fff, 0x7fff, 380, 500, 0
};
s32 NULL_PARAMS[10] = {
0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
void AEReverb::SetType(int t)
{
type = t;
switch(t)
{
case AL_FX_SMALLROOM: params = SMALLROOM_PARAMS; break;
case AL_FX_BIGROOM: params = BIGROOM_PARAMS; break;
case AL_FX_CHORUS: params = CHORUS_PARAMS; break;
case AL_FX_FLANGE: params = FLANGE_PARAMS; break;
case AL_FX_ECHO: params = ECHO_PARAMS; break;
default: params = NULL_PARAMS; break;
}
if(params)
maxParam = (params[0] * PARAMS_PER_SECTION) + 2;
}
int AEReverb::GetType(void)
{
return type;
}
void AEReverb::AllocParamBuf(int numSections)
{
maxParam = (numSections * 8) + 2;
params = (s32*)malloc(maxParam * sizeof(s32));
if(!params)
{
maxParam = 0;
printf("Unable to allocate memory for reverb params\n");
}
else
params[0] = numSections;
}
s32* AEReverb::GetParamBuf(void)
{
return params;
}
void AEReverb::SetParam(int index, s32 value)
{
if(index == 0)
printf("Setting number of reverb sections not allowed\n");
else if(index > maxParam)
printf("trying to access invalid index %d\n",index);
else if (!params)
printf("Reverb param buffer not allocated\n");
else
params[index] = value;
}
int AEReverb::GetParam(int index, s32 *value)
{
if(params)
{
*value = params[index];
return(1);
}
return(0);
}