AeN64DriverFx.c++
4.24 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
//
// AeN64DriverFx.c++
//
// This file contains routines for managing n64 built-in
// effects. The n64 provides five built-in effects that
// require creating and initializing and it also requires
// that all delay values are in samples and aligned to 8 sample
// boundaries.
//
#include <assert.h>
#include <stdlib.h>
#include "AeN64Driver.h"
#include "AeConfig.h"
#include "GioMgr.h" // PARAMS_PER_SECTION
#include "AeAsset.h"
#include "AeAssetBase.h"
#include "GList.h"
#define N_FX_PARAMS 2
//
// chorus chorus filter
// input output fbcoef ffcoef gain rate depth coef
//
int SMALLROOM_PARAMS[26] =
{
3, 100,
0, 54, 9830, -9830, 0, 0, 0, 0,
19, 38, 3276, -3276, 0x3fff, 0, 0, 0,
0, 60, 5000, 0, 0, 0, 0, 0x5000
};
int BIGROOM_PARAMS[34] =
{
4, 100,
0, 66, 9830, -9830, 0, 0, 0, 0,
22, 54, 3276, -3276, 0x3fff, 0, 0, 0,
66, 91, 3276, -3276, 0x3fff, 0, 0, 0,
0, 94, 8000, 0, 0, 0, 0, 0x5000
};
int ECHO_PARAMS[10] =
{
1, 200,
0, 179, 12000, 0, 0x7fff, 0, 0, 0
};
int CHORUS_PARAMS[10] =
{
1, 20,
0, 5, 0x4000, 0, 0x7fff, 7600, 700, 0
};
int FLANGE_PARAMS[10] =
{
1, 20,
0, 5, 0, 0x5fff, 0x7fff, 380, 500, 0
};
void
AeN64Driver::fxCreateBuiltIn (void)
{
AeFxAsset * asset;
asset = new AeFxAsset ("smallroom");
fxParseParamList (asset, SMALLROOM_PARAMS);
fAssetBase->AppendAsset (asset);
asset = new AeFxAsset ("bigroom");
fxParseParamList (asset, BIGROOM_PARAMS);
fAssetBase->AppendAsset (asset);
asset = new AeFxAsset ("chorus");
fxParseParamList (asset, CHORUS_PARAMS);
fAssetBase->AppendAsset (asset);
asset = new AeFxAsset ("flange");
fxParseParamList (asset, FLANGE_PARAMS);
fAssetBase->AppendAsset (asset);
asset = new AeFxAsset ("echo");
fxParseParamList (asset, ECHO_PARAMS);
fAssetBase->AppendAsset (asset);
}
void
AeN64Driver::fxParseParamList (AeFxAsset * fxAsset, int * params)
{
AeFxSxnAsset * sxnAsset;
int nSections;
int i;
int * p;
p = params;
nSections = *p++;
fxAsset->SetLength (*p++);
for (i=0; i<nSections; i++)
{
sxnAsset = new AeFxSxnAsset ("");
fxAsset->AppendChild (sxnAsset);
p = fxSxnParseParamList (sxnAsset, p);
}
}
void
AeN64Driver::fxBuildParamList (AeFxAsset * fxAsset, int ** pParams, int * nParams)
{
GList<AeAsset *> * childList;
AeAsset * asset;
int nSections;
int * p;
int i;
childList = ((AeContainerAsset *)fxAsset)->GetChildList ();
assert (childList);
nSections = childList->GetNum ();
*nParams = (N_FX_PARAMS + nSections * PARAMS_PER_SECTION);
if (*pParams = (int *)malloc (*nParams * sizeof (int)))
{
p = *pParams;
*p++ = nSections;
*p++ = msec2alignedsamples (fxAsset->GetLength ());
childList->Start (i);
while (childList->Next (i, asset))
p = fxSxnBuildParamList ((AeFxSxnAsset *)asset, p);
}
}
int *
AeN64Driver::fxSxnParseParamList (AeFxSxnAsset * sxnAsset, int * params)
{
sxnAsset->SetInput (*params++);
sxnAsset->SetOutput (*params++);
sxnAsset->SetFBCoef (*params++);
sxnAsset->SetFFCoef (*params++);
sxnAsset->SetGain (*params++);
sxnAsset->SetChorusRate (*params++);
sxnAsset->SetChorusDepth (*params++);
sxnAsset->SetFilterCoef (*params++);
return params;
}
int *
AeN64Driver::fxSxnBuildParamList (AeFxSxnAsset * asset, int * params)
{
*params++ = msec2alignedsamples (asset->GetInput ());
*params++ = msec2alignedsamples (asset->GetOutput ());
*params++ = asset->GetFBCoef ();
*params++ = asset->GetFFCoef ();
*params++ = asset->GetGain ();
*params++ = asset->GetChorusRate ();
*params++ = asset->GetChorusDepth ();
*params++ = asset->GetFilterCoef ();
return params;
}
int
AeN64Driver::msec2alignedsamples (int msec)
{
assert (fConfig);
long outputRate = fConfig->GetOutputRate ();
return ((long)msec * outputRate / 1000) & ~0x7;
}