aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include/alMidi.h
blob: 24e6675f6e44d808da0d4920b1085a3c2e392291 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#ifndef ALMIDI_H
#define ALMIDI_H

#include "alMain.h"
#include "atomic.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct ALsfmodulator {
    struct {
        ALenum Input;
        ALenum Type;
        ALenum Form;
    } Source[2];
    ALint Amount;
    ALenum TransformOp;
    ALenum Dest;
} ALsfmodulator;

typedef struct ALenvelope {
    ALint DelayTime;
    ALint AttackTime;
    ALint HoldTime;
    ALint DecayTime;
    ALint SustainAttn;
    ALint ReleaseTime;
    ALint KeyToHoldTime;
    ALint KeyToDecayTime;
} ALenvelope;


typedef struct ALfontsound {
    volatile RefCount ref;

    ALint MinKey, MaxKey;
    ALint MinVelocity, MaxVelocity;

    ALint ModLfoToPitch;
    ALint VibratoLfoToPitch;
    ALint ModEnvToPitch;

    ALint FilterCutoff;
    ALint FilterQ;
    ALint ModLfoToFilterCutoff;
    ALint ModEnvToFilterCutoff;
    ALint ModLfoToVolume;

    ALint ChorusSend;
    ALint ReverbSend;

    ALint Pan;

    struct {
        ALint Delay;
        ALint Frequency;
    } ModLfo;
    struct {
        ALint Delay;
        ALint Frequency;
    } VibratoLfo;

    ALenvelope ModEnv;
    ALenvelope VolEnv;

    ALint Attenuation;

    ALint CoarseTuning;
    ALint FineTuning;

    ALenum LoopMode;

    ALint TuningScale;

    ALint ExclusiveClass;

    ALuint Start;
    ALuint End;
    ALuint LoopStart;
    ALuint LoopEnd;
    ALuint SampleRate;
    ALubyte PitchKey;
    ALbyte PitchCorrection;
    ALenum SampleType;
    struct ALfontsound *Link;

    UIntMap ModulatorMap;

    ALuint id;
} ALfontsound;

void ALfontsound_Destruct(ALfontsound *self);
void ALfontsound_setPropi(ALfontsound *self, ALCcontext *context, ALenum param, ALint value);
void ALfontsound_setModStagei(ALfontsound *self, ALCcontext *context, ALsizei stage, ALenum param, ALint value);

ALfontsound *NewFontsound(ALCcontext *context);

inline struct ALfontsound *LookupFontsound(ALCdevice *device, ALuint id)
{ return (struct ALfontsound*)LookupUIntMapKey(&device->FontsoundMap, id); }
inline struct ALfontsound *RemoveFontsound(ALCdevice *device, ALuint id)
{ return (struct ALfontsound*)RemoveUIntMapKey(&device->FontsoundMap, id); }

inline struct ALsfmodulator *LookupModulator(ALfontsound *sound, ALuint id)
{ return (struct ALsfmodulator*)LookupUIntMapKey(&sound->ModulatorMap, id); }
inline struct ALsfmodulator *RemoveModulator(ALfontsound *sound, ALuint id)
{ return (struct ALsfmodulator*)RemoveUIntMapKey(&sound->ModulatorMap, id); }

void ReleaseALFontsounds(ALCdevice *device);


typedef struct ALsfpreset {
    volatile RefCount ref;

    ALint Preset; /* a.k.a. MIDI program number */
    ALint Bank; /* MIDI bank 0...127, or percussion (bank 128) */

    ALfontsound **Sounds;
    ALsizei NumSounds;

    ALuint id;
} ALsfpreset;

ALsfpreset *NewPreset(ALCcontext *context);
void DeletePreset(ALsfpreset *preset, ALCdevice *device);

inline struct ALsfpreset *LookupPreset(ALCdevice *device, ALuint id)
{ return (struct ALsfpreset*)LookupUIntMapKey(&device->PresetMap, id); }
inline struct ALsfpreset *RemovePreset(ALCdevice *device, ALuint id)
{ return (struct ALsfpreset*)RemoveUIntMapKey(&device->PresetMap, id); }

void ReleaseALPresets(ALCdevice *device);


typedef struct ALsoundfont {
    volatile RefCount ref;

    ALsfpreset **Presets;
    ALsizei NumPresets;

    ALshort *Samples;
    ALint NumSamples;

    RWLock Lock;
    volatile ALenum Mapped;

    ALuint id;
} ALsoundfont;

void ALsoundfont_Construct(ALsoundfont *self);
void ALsoundfont_Destruct(ALsoundfont *self);
ALsoundfont *ALsoundfont_getDefSoundfont(ALCcontext *context);
void ALsoundfont_deleteSoundfont(ALsoundfont *self, ALCdevice *device);

inline struct ALsoundfont *LookupSfont(ALCdevice *device, ALuint id)
{ return (struct ALsoundfont*)LookupUIntMapKey(&device->SfontMap, id); }
inline struct ALsoundfont *RemoveSfont(ALCdevice *device, ALuint id)
{ return (struct ALsoundfont*)RemoveUIntMapKey(&device->SfontMap, id); }

void ReleaseALSoundfonts(ALCdevice *device);

#ifdef __cplusplus
}
#endif

#endif /* ALMIDI_H */