11 struct MidiSynthVtable
;
13 typedef struct MidiSynth
{
18 ALdouble SamplesSinceLast
;
19 ALdouble SamplesToNext
;
21 ALdouble SamplesPerTick
;
23 /* NOTE: This rwlock is for the state and soundfont. The EventQueue and
24 * related must instead use the device lock as they're used in the mixer
29 volatile ALfloat Gain
;
30 volatile ALenum State
;
32 const struct MidiSynthVtable
*vtbl
;
35 ALfloat
MidiSynth_getGain(const MidiSynth
*self
);
36 ALuint64
MidiSynth_getTime(const MidiSynth
*self
);
39 struct MidiSynthVtable
{
40 void (*const Destruct
)(MidiSynth
*self
);
42 ALboolean (*const isSoundfont
)(MidiSynth
*self
, const char *filename
);
43 ALenum (*const loadSoundfont
)(MidiSynth
*self
, const char *filename
);
45 void (*const setGain
)(MidiSynth
*self
, ALfloat gain
);
46 void (*const setState
)(MidiSynth
*self
, ALenum state
);
48 void (*const stop
)(MidiSynth
*self
);
49 void (*const reset
)(MidiSynth
*self
);
51 void (*const update
)(MidiSynth
*self
, ALCdevice
*device
);
52 void (*const process
)(MidiSynth
*self
, ALuint samples
, ALfloat (*restrict DryBuffer
)[BUFFERSIZE
]);
54 void (*const Delete
)(MidiSynth
*self
);
57 #define DEFINE_MIDISYNTH_VTABLE(T) \
58 DECLARE_THUNK(T, MidiSynth, void, Destruct) \
59 DECLARE_THUNK1(T, MidiSynth, ALboolean, isSoundfont, const char*) \
60 DECLARE_THUNK1(T, MidiSynth, ALenum, loadSoundfont, const char*) \
61 DECLARE_THUNK1(T, MidiSynth, void, setGain, ALfloat) \
62 DECLARE_THUNK1(T, MidiSynth, void, setState, ALenum) \
63 DECLARE_THUNK(T, MidiSynth, void, stop) \
64 DECLARE_THUNK(T, MidiSynth, void, reset) \
65 DECLARE_THUNK1(T, MidiSynth, void, update, ALCdevice*) \
66 DECLARE_THUNK2(T, MidiSynth, void, process, ALuint, ALfloatBUFFERSIZE*restrict) \
67 DECLARE_THUNK(T, MidiSynth, void, Delete) \
69 static const struct MidiSynthVtable T##_MidiSynth_vtable = { \
70 T##_MidiSynth_Destruct, \
72 T##_MidiSynth_isSoundfont, \
73 T##_MidiSynth_loadSoundfont, \
74 T##_MidiSynth_setGain, \
75 T##_MidiSynth_setState, \
77 T##_MidiSynth_reset, \
78 T##_MidiSynth_update, \
79 T##_MidiSynth_process, \
81 T##_MidiSynth_Delete, \
85 MidiSynth
*SynthCreate(ALCdevice
*device
);