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
|
// license:???
// copyright-holders:Keith Wilkins
#pragma once
#ifndef __DISC_FLTH__
#define __DISC_FLT_H__
/***********************************************************************
*
* MAME - Discrete sound system emulation library
*
* Written by Keith Wilkins (mame@esplexo.co.uk)
*
* (c) K.Wilkins 2000
*
* Coding started in November 2000
*
* Additions/bugfix February 2003 - Derrick Renaud, F.Palazzolo, K.Wilkins
* Discrete parallel tasks 2009 - Couriersud
* Discrete classes 2010 - Couriersud
*
***********************************************************************/
#include "discrete.h"
struct discrete_filter_coeff
{
double x1, x2; /* x[k-1], x[k-2], previous 2 input values */
double y1, y2; /* y[k-1], y[k-2], previous 2 output values */
double a1, a2; /* digital filter coefficients, denominator */
double b0, b1, b2; /* digital filter coefficients, numerator */
};
DISCRETE_CLASS_STEP_RESET(dst_filter1, 1,
/* uses x1, y1, a1, b0, b1 */
struct discrete_filter_coeff m_fc;
);
DISCRETE_CLASS_STEP_RESET(dst_filter2, 1,
struct discrete_filter_coeff m_fc;
);
DISCRETE_CLASS_STEP_RESET(dst_sallen_key, 1,
struct discrete_filter_coeff m_fc;
);
DISCRETE_CLASS_STEP_RESET(dst_crfilter, 1,
double m_vCap;
double m_rc;
double m_exponent;
UINT8 m_has_rc_nodes;
//UINT8 m_is_fast;
);
DISCRETE_CLASS_STEP_RESET(dst_op_amp_filt, 1,
int m_type; /* What kind of filter */
int m_is_norton; /* 1 = Norton op-amps */
double m_vRef;
double m_vP;
double m_vN;
double m_rTotal; /* All input resistance in parallel. */
double m_iFixed; /* Current supplied by r3 & r4 if used. */
double m_exponentC1;
double m_exponentC2;
double m_exponentC3;
double m_rRatio; /* divide ratio of resistance network */
double m_vC1; /* Charge on C1 */
double m_vC1b; /* Charge on C1, part of C1 charge if needed */
double m_vC2; /* Charge on C2 */
double m_vC3; /* Charge on C2 */
double m_gain; /* Gain of the filter */
struct discrete_filter_coeff m_fc;
);
DISCRETE_CLASS_STEP_RESET(dst_rc_circuit_1, 1,
double m_v_cap;
double m_v_charge_1_2;
double m_v_drop;
double m_exp_1;
double m_exp_1_2;
double m_exp_2;
);
DISCRETE_CLASS_STEP_RESET(dst_rcdisc, 1,
int m_state;
double m_t; /* time */
double m_exponent0;
);
DISCRETE_CLASS_STEP_RESET(dst_rcdisc2, 1,
int m_state;
double m_v_out;
double m_t; /* time */
double m_exponent0;
double m_exponent1;
);
DISCRETE_CLASS_STEP_RESET(dst_rcdisc3, 1,
int m_state;
double m_v_out;
double m_t; /* time */
double m_exponent0;
double m_exponent1;
double m_v_diode; /* rcdisc3 */
);
DISCRETE_CLASS_STEP_RESET(dst_rcdisc4, 1,
int m_type;
double m_max_out;
double m_vC1;
double m_v[2];
double m_exp[2];
);
DISCRETE_CLASS_STEP_RESET(dst_rcdisc5, 1,
int m_state;
double m_t; /* time */
double m_exponent0;
double m_v_cap; /* rcdisc5 */
);
DISCRETE_CLASS_STEP_RESET(dst_rcintegrate, 1,
int m_type;
double m_gain_r1_r2;
double m_f; /* r2,r3 gain */
double m_vCap;
double m_vCE;
double m_exponent0;
double m_exponent1;
double m_exp_exponent0;
double m_exp_exponent1;
double m_c_exp0;
double m_c_exp1;
double m_EM_IC_0_7;
);
DISCRETE_CLASS_STEP_RESET(dst_rcdisc_mod, 1,
double m_v_cap;
double m_exp_low[2];
double m_exp_high[4];
double m_gain[2];
double m_vd_gain[4];
);
DISCRETE_CLASS_STEP_RESET(dst_rcfilter, 1,
double m_v_out;
double m_vCap;
double m_rc;
double m_exponent;
UINT8 m_has_rc_nodes;
UINT8 m_is_fast;
);
DISCRETE_CLASS_STEP_RESET(dst_rcfilter_sw, 1,
double m_vCap[4];
double m_exp[4];
double m_exp0; /* fast case bit 0 */
double m_exp1; /* fast case bit 1 */
double m_factor; /* fast case */
double m_f1[16];
double m_f2[16];
);
DISCRETE_CLASS_STEP_RESET(dst_rcdiscN, 1,
double m_x1; /* x[k-1], previous input value */
double m_y1; /* y[k-1], previous output value */
double m_a1; /* digital filter coefficients, denominator */
//double m_b[2]; /* digital filter coefficients, numerator */
);
DISCRETE_CLASS_STEP_RESET(dst_rcdisc2N, 1,
struct discrete_filter_coeff m_fc0;
struct discrete_filter_coeff m_fc1;
double m_x1;
double m_y1;
);
#endif /* __DISC_FLT_H__ */
|