Update behavior for alMidiStopSOFT
[openal-soft.git] / OpenAL32 / Include / alMidi.h
blobeb36adcfbb7274220cd5bfd7fd2705d3fa0b5a5f
1 #ifndef ALMIDI_H
2 #define ALMIDI_H
4 #include "alMain.h"
5 #include "evtqueue.h"
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
11 struct MidiSynthVtable;
13 typedef struct MidiSynth {
14 EvtQueue EventQueue;
16 ALuint64 LastEvtTime;
17 ALuint64 NextEvtTime;
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
25 * thread.
27 RWLock Lock;
29 volatile ALfloat Gain;
30 volatile ALenum State;
32 const struct MidiSynthVtable *vtbl;
33 } MidiSynth;
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, \
76 T##_MidiSynth_stop, \
77 T##_MidiSynth_reset, \
78 T##_MidiSynth_update, \
79 T##_MidiSynth_process, \
81 T##_MidiSynth_Delete, \
85 MidiSynth *SynthCreate(ALCdevice *device);
87 #ifdef __cplusplus
89 #endif
91 #endif /* ALMIDI_H */