summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libgme/emu2413.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libgme/emu2413.h')
-rw-r--r--lib/rbcodec/codecs/libgme/emu2413.h164
1 files changed, 164 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libgme/emu2413.h b/lib/rbcodec/codecs/libgme/emu2413.h
new file mode 100644
index 0000000000..254f042957
--- /dev/null
+++ b/lib/rbcodec/codecs/libgme/emu2413.h
@@ -0,0 +1,164 @@
1#ifndef _EMU2413_H_
2#define _EMU2413_H_
3
4#include "blargg_common.h"
5#include "emutypes.h"
6
7#ifdef EMU2413_DLL_EXPORTS
8 #define EMU2413_API __declspec(dllexport)
9#elif defined(EMU2413_DLL_IMPORTS)
10 #define EMU2413_API __declspec(dllimport)
11#else
12 #define EMU2413_API
13#endif
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19#define AUDIO_MONO_BUFFER_SIZE 1024
20
21#define PI 3.14159265358979323846
22
23enum OPLL_TONE_ENUM {OPLL_2413_TONE=0, OPLL_VRC7_TONE=1, OPLL_281B_TONE=2} ;
24
25/* voice data */
26typedef struct __OPLL_PATCH {
27 e_uint32 TL,FB,EG,ML,AR,DR,SL,RR,KR,KL,AM,PM,WF ;
28} OPLL_PATCH ;
29
30/* slot */
31typedef struct __OPLL_SLOT {
32
33 OPLL_PATCH *patch;
34
35 e_int32 type ; /* 0 : modulator 1 : carrier */
36
37 /* OUTPUT */
38 e_int32 feedback ;
39 e_int32 output[2] ; /* Output value of slot */
40
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 */
46
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 */
58
59} OPLL_SLOT ;
60
61/* Mask */
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 )
69
70/* opll */
71typedef struct __OPLL {
72
73 e_uint32 adr ;
74 e_int32 out ;
75
76#ifndef EMU2413_COMPACTION
77 e_uint32 realstep ;
78 e_uint32 oplltime ;
79 e_uint32 opllstep ;
80 e_int32 prev, next ;
81 e_int32 sprev[2],snext[2];
82 e_uint32 pan[16];
83#endif
84
85 /* Register */
86 e_uint8 reg[0x40] ;
87 e_int32 slot_on_flag[18] ;
88
89 /* Pitch Modulator */
90 e_uint32 pm_phase ;
91 e_int32 lfo_pm ;
92
93 /* Amp Modulator */
94 e_int32 am_phase ;
95 e_int32 lfo_am ;
96
97 e_uint32 quality;
98
99 /* Noise Generator */
100 e_uint32 noise_seed ;
101
102 /* Channel Data */
103 e_int32 patch_number[9];
104 e_int32 key_status[9] ;
105
106 /* Slot */
107 OPLL_SLOT slot[18] ;
108
109 /* Voice Data */
110 OPLL_PATCH patch[19*2] ;
111 e_int32 patch_update[2] ; /* flag for check patch update */
112
113 e_uint32 mask ;
114 e_uint32 current_mask;
115 e_uint32 status;
116
117 e_uint32 internal_mute;
118 e_int16 buffer[AUDIO_MONO_BUFFER_SIZE];
119} OPLL ;
120
121/* Create Object */
122EMU2413_API void OPLL_new(OPLL *, e_uint32 clk, e_uint32 rate) ;
123EMU2413_API void OPLL_delete(OPLL *) ;
124
125/* Setup */
126EMU2413_API void OPLL_reset(OPLL *) ;
127EMU2413_API void OPLL_reset_patch(OPLL *, e_int32) ;
128EMU2413_API void OPLL_set_rate(OPLL *opll, e_uint32 r) ;
129EMU2413_API void OPLL_set_quality(OPLL *opll, e_uint32 q) ;
130EMU2413_API void OPLL_set_pan(OPLL *, e_uint32 ch, e_uint32 pan);
131EMU2413_API void OPLL_set_internal_mute(OPLL *, e_uint32 mute);
132EMU2413_API e_uint32 OPLL_is_internal_muted(OPLL *);
133
134/* Port/Register access */
135EMU2413_API void OPLL_writeIO(OPLL *, e_uint32 reg, e_uint32 val);
136EMU2413_API void OPLL_writeReg(OPLL *, e_uint32 reg, e_uint32 val);
137EMU2413_API e_uint32 OPLL_read(OPLL *, e_uint32 port);
138
139/* Synthsize */
140EMU2413_API e_int16 OPLL_calc(OPLL *) EMU2413_CALC_ICODE;
141EMU2413_API void OPLL_calc_stereo(OPLL *, e_int32 out[2]) ;
142EMU2413_API e_int16 *OPLL_update_buffer(OPLL *, e_uint32 length) ;
143
144/* Misc */
145EMU2413_API void OPLL_setPatch(OPLL *, const e_uint8 *dump) ;
146EMU2413_API void OPLL_copyPatch(OPLL *, e_int32, OPLL_PATCH *) ;
147EMU2413_API void OPLL_forceRefresh(OPLL *) ;
148/* Utility */
149EMU2413_API void OPLL_dump2patch(const e_uint8 *dump, OPLL_PATCH *patch) ;
150EMU2413_API void OPLL_patch2dump(const OPLL_PATCH *patch, e_uint8 *dump) ;
151EMU2413_API void OPLL_getDefaultPatch(e_int32 type, e_int32 num, OPLL_PATCH *) ;
152
153/* Channel Mask */
154EMU2413_API e_uint32 OPLL_setMask(OPLL *, e_uint32 mask) ;
155EMU2413_API e_uint32 OPLL_toggleMask(OPLL *, e_uint32 mask) ;
156
157#define dump2patch OPLL_dump2patch
158
159#ifdef __cplusplus
160}
161#endif
162
163#endif
164