4 #include "blargg_common.h"
7 #ifdef EMU2413_DLL_EXPORTS
8 #define EMU2413_API __declspec(dllexport)
9 #elif defined(EMU2413_DLL_IMPORTS)
10 #define EMU2413_API __declspec(dllimport)
19 #define AUDIO_MONO_BUFFER_SIZE 1024
21 #define PI 3.14159265358979323846
23 enum OPLL_TONE_ENUM
{OPLL_2413_TONE
=0, OPLL_VRC7_TONE
=1, OPLL_281B_TONE
=2} ;
26 typedef struct __OPLL_PATCH
{
27 e_uint32 TL
,FB
,EG
,ML
,AR
,DR
,SL
,RR
,KR
,KL
,AM
,PM
,WF
;
31 typedef struct __OPLL_SLOT
{
35 e_int32 type
; /* 0 : modulator 1 : carrier */
39 e_int32 output
[2] ; /* Output value of slot */
41 /* for Phase Generator (PG) */
42 e_uint16
*sintbl
; /* Wavetable */
43 e_uint32 phase
; /* Phase */
44 e_uint32 dphase
; /* Phase increment amount */
45 e_uint32 pgout
; /* output */
47 /* for Envelope Generator (EG) */
48 e_int32 fnum
; /* F-Number */
49 e_int32 block
; /* Block */
50 e_int32 volume
; /* Current volume */
51 e_int32 sustine
; /* Sustine 1 = ON, 0 = OFF */
52 e_uint32 tll
; /* Total Level + Key scale level*/
53 e_uint32 rks
; /* Key scale offset (Rks) */
54 e_int32 eg_mode
; /* Current state */
55 e_uint32 eg_phase
; /* Phase */
56 e_uint32 eg_dphase
; /* Phase increment amount */
57 e_uint32 egout
; /* output */
62 #define OPLL_MASK_CH(x) (1<<(x))
63 #define OPLL_MASK_HH (1<<(9))
64 #define OPLL_MASK_CYM (1<<(10))
65 #define OPLL_MASK_TOM (1<<(11))
66 #define OPLL_MASK_SD (1<<(12))
67 #define OPLL_MASK_BD (1<<(13))
68 #define OPLL_MASK_RHYTHM ( OPLL_MASK_HH | OPLL_MASK_CYM | OPLL_MASK_TOM | OPLL_MASK_SD | OPLL_MASK_BD )
71 typedef struct __OPLL
{
76 #ifndef EMU2413_COMPACTION
81 e_int32 sprev
[2],snext
[2];
87 e_int32 slot_on_flag
[18] ;
100 e_uint32 noise_seed
;
103 e_int32 patch_number
[9];
104 e_int32 key_status
[9] ;
110 OPLL_PATCH patch
[19*2] ;
111 e_int32 patch_update
[2] ; /* flag for check patch update */
114 e_uint32 current_mask
;
117 e_uint32 internal_mute
;
118 e_int16 buffer
[AUDIO_MONO_BUFFER_SIZE
];
122 EMU2413_API
void OPLL_new(OPLL
*, e_uint32 clk
, e_uint32 rate
) ;
123 EMU2413_API
void OPLL_delete(OPLL
*) ;
126 EMU2413_API
void OPLL_reset(OPLL
*) ;
127 EMU2413_API
void OPLL_reset_patch(OPLL
*, e_int32
) ;
128 EMU2413_API
void OPLL_set_rate(OPLL
*opll
, e_uint32 r
) ;
129 EMU2413_API
void OPLL_set_quality(OPLL
*opll
, e_uint32 q
) ;
130 EMU2413_API
void OPLL_set_pan(OPLL
*, e_uint32 ch
, e_uint32 pan
);
131 EMU2413_API
void OPLL_set_internal_mute(OPLL
*, e_uint32 mute
);
132 EMU2413_API e_uint32
OPLL_is_internal_muted(OPLL
*);
134 /* Port/Register access */
135 EMU2413_API
void OPLL_writeIO(OPLL
*, e_uint32 reg
, e_uint32 val
); ICODE_ATTR
136 EMU2413_API
void OPLL_writeReg(OPLL
*, e_uint32 reg
, e_uint32 val
); ICODE_ATTR
137 EMU2413_API e_uint32
OPLL_read(OPLL
*, e_uint32 port
);
140 EMU2413_API e_int16
OPLL_calc(OPLL
*) ; ICODE_ATTR
141 EMU2413_API
void OPLL_calc_stereo(OPLL
*, e_int32 out
[2]) ; ICODE_ATTR
142 EMU2413_API e_int16
*OPLL_update_buffer(OPLL
*, e_uint32 length
) ; ICODE_ATTR
145 EMU2413_API
void OPLL_setPatch(OPLL
*, const e_uint8
*dump
) ;
146 EMU2413_API
void OPLL_copyPatch(OPLL
*, e_int32
, OPLL_PATCH
*) ;
147 EMU2413_API
void OPLL_forceRefresh(OPLL
*) ;
149 EMU2413_API
void OPLL_dump2patch(const e_uint8
*dump
, OPLL_PATCH
*patch
) ;
150 EMU2413_API
void OPLL_patch2dump(const OPLL_PATCH
*patch
, e_uint8
*dump
) ;
151 EMU2413_API
void OPLL_getDefaultPatch(e_int32 type
, e_int32 num
, OPLL_PATCH
*) ;
154 EMU2413_API e_uint32
OPLL_setMask(OPLL
*, e_uint32 mask
) ;
155 EMU2413_API e_uint32
OPLL_toggleMask(OPLL
*, e_uint32 mask
) ;
157 #define dump2patch OPLL_dump2patch