fceugx/source/fceultra/boards/emu2413.h

140 lines
2.6 KiB
C
Raw Normal View History

2008-09-02 03:55:12 +02:00
#ifndef _EMU2413_H_
#define _EMU2413_H_
2012-12-14 18:18:20 +01:00
#ifndef INLINE
#if defined(_MSC_VER)
#define INLINE __forceinline
#elif defined(__GNUC__)
#define INLINE __inline__
#elif defined(_MWERKS_)
#define INLINE inline
2008-09-02 03:55:12 +02:00
#else
2012-12-14 18:18:20 +01:00
#define INLINE
#endif
2008-09-02 03:55:12 +02:00
#endif
#ifdef __cplusplus
extern "C" {
#endif
2012-12-14 18:18:20 +01:00
typedef unsigned char uint8 ;
typedef signed char int8 ;
typedef unsigned short uint16 ;
typedef signed short int16 ;
typedef unsigned int uint32 ;
typedef signed int int32 ;
2008-09-02 03:55:12 +02:00
#define PI 3.14159265358979323846
2012-12-14 18:18:20 +01:00
enum { OPLL_VRC7_TONE=0 };
2008-09-02 03:55:12 +02:00
/* voice data */
typedef struct {
2012-12-14 18:18:20 +01:00
uint32 TL, FB, EG, ML, AR, DR, SL, RR, KR, KL, AM, PM, WF;
} OPLL_PATCH;
2008-09-02 03:55:12 +02:00
/* slot */
typedef struct {
2012-12-14 18:18:20 +01:00
OPLL_PATCH patch;
int32 type; /* 0 : modulator 1 : carrier */
/* OUTPUT */
int32 feedback;
int32 output[2]; /* Output value of slot */
/* for Phase Generator (PG) */
uint16 *sintbl; /* Wavetable */
uint32 phase; /* Phase */
uint32 dphase; /* Phase increment amount */
uint32 pgout; /* output */
/* for Envelope Generator (EG) */
int32 fnum; /* F-Number */
int32 block; /* Block */
int32 volume; /* Current volume */
int32 sustine; /* Sustine 1 = ON, 0 = OFF */
uint32 tll; /* Total Level + Key scale level*/
uint32 rks; /* Key scale offset (Rks) */
int32 eg_mode; /* Current state */
uint32 eg_phase; /* Phase */
uint32 eg_dphase; /* Phase increment amount */
uint32 egout; /* output */
} OPLL_SLOT;
2008-09-02 03:55:12 +02:00
/* Mask */
2012-12-14 18:18:20 +01:00
#define OPLL_MASK_CH(x) (1 << (x))
2008-09-02 03:55:12 +02:00
/* opll */
typedef struct {
2012-12-14 18:18:20 +01:00
uint32 adr;
int32 out;
2008-09-02 03:55:12 +02:00
2012-12-14 18:18:20 +01:00
uint32 realstep;
uint32 oplltime;
uint32 opllstep;
int32 prev, next;
2008-09-02 03:55:12 +02:00
2012-12-14 18:18:20 +01:00
/* Register */
uint8 LowFreq[6];
uint8 HiFreq[6];
uint8 InstVol[6];
2008-09-02 03:55:12 +02:00
2012-12-14 18:18:20 +01:00
uint8 CustInst[8];
2008-09-02 03:55:12 +02:00
2012-12-14 18:18:20 +01:00
int32 slot_on_flag[6 * 2];
2008-09-02 03:55:12 +02:00
2012-12-14 18:18:20 +01:00
/* Pitch Modulator */
uint32 pm_phase;
int32 lfo_pm;
2008-09-02 03:55:12 +02:00
2012-12-14 18:18:20 +01:00
/* Amp Modulator */
int32 am_phase;
int32 lfo_am;
2008-09-02 03:55:12 +02:00
2012-12-14 18:18:20 +01:00
uint32 quality;
2008-09-02 03:55:12 +02:00
2012-12-14 18:18:20 +01:00
/* Channel Data */
int32 patch_number[6];
int32 key_status[6];
2008-09-02 03:55:12 +02:00
2012-12-14 18:18:20 +01:00
/* Slot */
OPLL_SLOT slot[6 * 2];
2008-09-02 03:55:12 +02:00
2012-12-14 18:18:20 +01:00
uint32 mask;
} OPLL;
2008-09-02 03:55:12 +02:00
/* Create Object */
2012-12-14 18:18:20 +01:00
OPLL *OPLL_new(uint32 clk, uint32 rate);
void OPLL_delete(OPLL *);
2008-09-02 03:55:12 +02:00
/* Setup */
2012-12-14 18:18:20 +01:00
void OPLL_reset(OPLL *);
void OPLL_set_rate(OPLL *opll, uint32 r);
void OPLL_set_quality(OPLL *opll, uint32 q);
2008-09-02 03:55:12 +02:00
/* Port/Register access */
2012-12-14 18:18:20 +01:00
void OPLL_writeIO(OPLL *, uint32 reg, uint32 val);
void OPLL_writeReg(OPLL *, uint32 reg, uint32 val);
2008-09-02 03:55:12 +02:00
/* Synthsize */
2012-12-14 18:18:20 +01:00
int16 OPLL_calc(OPLL *);
2008-09-02 03:55:12 +02:00
/* Misc */
2012-12-14 18:18:20 +01:00
void OPLL_forceRefresh(OPLL *);
2008-09-02 03:55:12 +02:00
/* Channel Mask */
2012-12-14 18:18:20 +01:00
uint32 OPLL_setMask(OPLL *, uint32 mask);
uint32 OPLL_toggleMask(OPLL *, uint32 mask);
2008-09-02 03:55:12 +02:00
2012-12-14 18:43:51 +01:00
void OPLL_fillbuf(OPLL* opll, int32 *buf, int32 len, int shift);
2008-09-02 03:55:12 +02:00
#ifdef __cplusplus
}
#endif
#endif