Lines Matching +full:diff +full:- +full:channels

3 Date: Sun, 14 Jun 2020 14:11:00 -0600
9 Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
10 ---
11 src/opl.c | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++-
12 src/opl.h | 157 ++----------------------------------------------------
13 2 files changed, 154 insertions(+), 156 deletions(-)
15 diff --git a/src/opl.c b/src/opl.c
17 --- a/src/opl.c
19 @@ -23,12 +23,161 @@
20 * Copyright (C) 1998-2001 Ken Silverman
23 -
30 -#include "opl.h"
55 +#define FIXEDPT 0x10000 // fixed-point calculations using 16+16
56 +#define FIXEDPT_LFO 0x1000000 // fixed-point calculations using 8+24
101 + For OPL2 all 9 channels consist of two operators each, carrier and modulator.
103 + For OPL3 all 18 channels consist either of two operators (2op mode) or four
106 + Only the channels 0,1,2 (first set) and 9,10,11 (second set) can act as
107 + 4op channels. The two additional operators for a channel y come from the
129 + // variables used to provide non-continuous envelopes
130 + Bit32u generator_pos; // for non-standard sample rates we need to determine how many samples ha…
133 + Bit8u step_skip_pos_a; // position of 8-cyclic step skipping (always 2^x to check against mask)
142 +// per-chip variables
183 diff --git a/src/opl.h b/src/opl.h
185 --- a/src/opl.h
187 @@ -25,11 +25,8 @@
191 -
192 -#define fltype double
193 -
194 -#include <stdbool.h>
200 @@ -39,154 +36,6 @@ typedef int16_t Bit16s;
204 -
205 -/*
206 - define attribution that inlines/forces inlining of a function (optional)
207 -*/
208 -#define OPL_INLINE inline
209 -
210 -
211 -#undef NUM_CHANNELS
212 -#if defined(OPLTYPE_IS_OPL3)
213 -#define NUM_CHANNELS 18
214 -#else
215 -#define NUM_CHANNELS 9
216 -#endif
217 -
218 -#define MAXOPERATORS (NUM_CHANNELS*2)
219 -
220 -
221 -#define FL05 ((fltype)0.5)
222 -#define FL2 ((fltype)2.0)
223 -#define PI ((fltype)3.1415926535897932384626433832795)
224 -
225 -
226 -#define FIXEDPT 0x10000 // fixed-point calculations using 16+16
227 -#define FIXEDPT_LFO 0x1000000 // fixed-point calculations using 8+24
228 -
229 -#define WAVEPREC 1024 // waveform precision (10 bits)
230 -
231 -#define INTFREQU ((fltype)(14318180.0 / 288.0)) // clocking of the chip
232 -
233 -
234 -#define OF_TYPE_ATT 0
235 -#define OF_TYPE_DEC 1
236 -#define OF_TYPE_REL 2
237 -#define OF_TYPE_SUS 3
238 -#define OF_TYPE_SUS_NOKEEP 4
239 -#define OF_TYPE_OFF 5
240 -
241 -#define ARC_CONTROL 0x00
242 -#define ARC_TVS_KSR_MUL 0x20
243 -#define ARC_KSL_OUTLEV 0x40
244 -#define ARC_ATTR_DECR 0x60
245 -#define ARC_SUSL_RELR 0x80
246 -#define ARC_FREQ_NUM 0xa0
247 -#define ARC_KON_BNUM 0xb0
248 -#define ARC_PERC_MODE 0xbd
249 -#define ARC_FEEDBACK 0xc0
250 -#define ARC_WAVE_SEL 0xe0
251 -
252 -#define ARC_SECONDSET 0x100 // second operator set for OPL3
253 -
254 -
255 -#define OP_ACT_OFF 0x00
256 -#define OP_ACT_NORMAL 0x01 // regular channel activated (bitmasked)
257 -#define OP_ACT_PERC 0x02 // percussion channel activated (bitmasked)
258 -
259 -#define BLOCKBUF_SIZE 512
260 -
261 -
262 -// vibrato constants
263 -#define VIBTAB_SIZE 8
264 -#define VIBFAC 70/50000 // no braces, integer mul/div
265 -
266 -// tremolo constants and table
267 -#define TREMTAB_SIZE 53
268 -#define TREM_FREQ ((fltype)(3.7)) // tremolo at 3.7hz
269 -
270 -
271 -/* operator struct definition
272 - For OPL2 all 9 channels consist of two operators each, carrier and modulator.
273 - Channel x has operators x as modulator and operators (9+x) as carrier.
274 - For OPL3 all 18 channels consist either of two operators (2op mode) or four
275 - operators (4op mode) which is determined through register4 of the second
276 - adlib register set.
277 - Only the channels 0,1,2 (first set) and 9,10,11 (second set) can act as
278 - 4op channels. The two additional operators for a channel y come from the
279 - 2op channel y+3 so the operatorss y, (9+y), y+3, (9+y)+3 make up a 4op
280 - channel.
281 -*/
282 -typedef struct operator_struct {
283 - Bit32s cval, lastcval; // current output/last output (used for feedback)
284 - Bit32u tcount, wfpos, tinc; // time (position in waveform) and time increment
285 - fltype amp, step_amp; // and amplification (envelope)
286 - fltype vol; // volume
287 - fltype sustain_level; // sustain level
288 - Bit32s mfbi; // feedback amount
289 - fltype a0, a1, a2, a3; // attack rate function coefficients
290 - fltype decaymul, releasemul; // decay/release rate functions
291 - Bit32u op_state; // current state of operator (attack/decay/sustain/release/off)
292 - Bit32u toff;
293 - Bit32s freq_high; // highest three bits of the frequency, used for vibrato calculations
294 - Bit16s* cur_wform; // start of selected waveform
295 - Bit32u cur_wmask; // mask for selected waveform
296 - Bit32u act_state; // activity state (regular, percussion)
297 - bool sus_keep; // keep sustain level when decay finished
298 - bool vibrato,tremolo; // vibrato/tremolo enable bits
299 -
300 - // variables used to provide non-continuous envelopes
301 - Bit32u generator_pos; // for non-standard sample rates we need to determine how many samples ha…
302 - Bits cur_env_step; // current (standardized) sample position
303 - Bits env_step_a,env_step_d,env_step_r; // number of std samples of one step (for attack/decay/rel…
304 - Bit8u step_skip_pos_a; // position of 8-cyclic step skipping (always 2^x to check against mask)
305 - Bits env_step_skip_a; // bitmask that determines if a step is skipped (respective bit is zero t…
306 -
307 -#if defined(OPLTYPE_IS_OPL3)
308 - bool is_4op,is_4op_attached; // base of a 4op channel/part of a 4op channel
309 - Bit32s left_pan,right_pan; // opl3 stereo panning amount
310 -#endif
311 -} op_type;
312 -
313 -// per-chip variables
314 -Bitu chip_num;
315 -op_type op[MAXOPERATORS];
316 -
317 -Bits int_samplerate;
318 -
319 -Bit8u status;
320 -Bit32u opl_index;
321 -#if defined(OPLTYPE_IS_OPL3)
322 -Bit8u adlibreg[512]; // adlib register set (including second set)
323 -Bit8u wave_sel[44]; // waveform selection
324 -#else
325 -Bit8u adlibreg[256]; // adlib register set
326 -Bit8u wave_sel[22]; // waveform selection
327 -#endif
328 -
329 -
330 -// vibrato/tremolo increment/counter
331 -Bit32u vibtab_pos;
332 -Bit32u vibtab_add;
333 -Bit32u tremtab_pos;
334 -Bit32u tremtab_add;
335 -
336 -
337 -// enable an operator
338 -void enable_operator(Bitu regbase, op_type* op_pt, Bit32u act_type);
339 -
340 -// functions to change parameters of an operator
341 -void change_frequency(Bitu chanbase, Bitu regbase, op_type* op_pt);
342 -
343 -void change_attackrate(Bitu regbase, op_type* op_pt);
344 -void change_decayrate(Bitu regbase, op_type* op_pt);
345 -void change_releaserate(Bitu regbase, op_type* op_pt);
346 -void change_sustainlevel(Bitu regbase, op_type* op_pt);
347 -void change_waveform(Bitu regbase, op_type* op_pt);
348 -void change_keepsustain(Bitu regbase, op_type* op_pt);
349 -void change_vibrato(Bitu regbase, op_type* op_pt);
350 -void change_feedback(Bitu chanbase, op_type* op_pt);
351 -
355 @@ -195,8 +44,8 @@ void adlib_getsample(Bit16s* sndptr, Bits numsamples);
359 -#endif /* OPL_H */
360 -