diff options
author | Chris Robinson <[email protected]> | 2013-12-23 03:23:42 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2013-12-23 03:23:42 -0800 |
commit | d7de86966d677366d8514a32be46b3040d9bc902 (patch) | |
tree | 81bc0fd23772a09179ed7973ae3835e70c0bf49e /OpenAL32 | |
parent | 0df5eb90ea0d244050f71c5f71167c46cbc17355 (diff) |
Add methods to get and set a preset object's preset and bank numbers
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alMain.h | 9 | ||||
-rw-r--r-- | OpenAL32/Include/alMidi.h | 4 | ||||
-rw-r--r-- | OpenAL32/alPreset.c | 100 |
3 files changed, 111 insertions, 2 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 039807de..79ccdb60 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -31,6 +31,8 @@ #define ALC_SOFT_midi_interface 1 #define AL_MIDI_CLOCK_SOFT 0x9999 #define AL_MIDI_GAIN_SOFT 0x9998 +#define AL_MIDI_PRESET_SOFT 0x9997 +#define AL_MIDI_BANK_SOFT 0x9996 #define AL_NOTEOFF_SOFT 0x0080 #define AL_NOTEON_SOFT 0x0090 #define AL_AFTERTOUCH_SOFT 0x00A0 @@ -47,6 +49,9 @@ typedef void (AL_APIENTRY*LPALSOUNDFONTUNMAPSAMPLESSOFT)(ALuint sfid); typedef void (AL_APIENTRY*LPALGENPRESETSSOFT)(ALsizei n, ALuint *ids); typedef void (AL_APIENTRY*LPALDELETEPRESETSSOFT)(ALsizei n, const ALuint *ids); typedef ALboolean (AL_APIENTRY*LPALISPRESETSOFT)(ALuint id); +typedef void (AL_APIENTRY*LPALPRESETISOFT)(ALuint id, ALenum param, ALint value); +typedef void (AL_APIENTRY*LPALPRESETIVSOFT)(ALuint id, ALenum param, const ALint *values); +typedef void (AL_APIENTRY*LPALGETPRESETIVSOFT)(ALuint id, ALenum param, ALint *values); typedef void (AL_APIENTRY*LPALGENINSTRUMENTSSOFT)(ALsizei n, ALuint *ids); typedef void (AL_APIENTRY*LPALDELETEINSTRUMENTSSOFT)(ALsizei n, const ALuint *ids); typedef ALboolean (AL_APIENTRY*LPALISINSTRUMENTSOFT)(ALuint id); @@ -71,6 +76,10 @@ AL_API ALvoid AL_APIENTRY alSoundfontUnmapSamplesSOFT(ALuint sfid); AL_API void AL_APIENTRY alGenPresetsSOFT(ALsizei n, ALuint *ids); AL_API void AL_APIENTRY alDeletePresetsSOFT(ALsizei n, const ALuint *ids); AL_API ALboolean AL_APIENTRY alIsPresetSOFT(ALuint id); +AL_API void AL_APIENTRY alPresetiSOFT(ALuint id, ALenum param, ALint value); +AL_API void AL_APIENTRY alPresetivSOFT(ALuint id, ALenum param, const ALint *values); +AL_API void AL_APIENTRY alGetPresetivSOFT(ALuint id, ALenum param, ALint *values); + AL_API void AL_APIENTRY alGenInstrumentsSOFT(ALsizei n, ALuint *ids); AL_API void AL_APIENTRY alDeleteInstrumentsSOFT(ALsizei n, const ALuint *ids); AL_API ALboolean AL_APIENTRY alIsInstrumentSOFT(ALuint id); diff --git a/OpenAL32/Include/alMidi.h b/OpenAL32/Include/alMidi.h index fffb1174..b37a6546 100644 --- a/OpenAL32/Include/alMidi.h +++ b/OpenAL32/Include/alMidi.h @@ -87,8 +87,8 @@ void ReleaseALInstruments(ALCdevice *device); typedef struct ALsfpreset { volatile RefCount ref; - ALint Program; - ALint Bank; + ALint Preset; /* a.k.a. MIDI program number */ + ALint Bank; /* MIDI bank 0...127, or percussion (bank 128) */ ALsfzone *Zones; ALsizei NumZones; diff --git a/OpenAL32/alPreset.c b/OpenAL32/alPreset.c index 873d9ad1..c01f4e80 100644 --- a/OpenAL32/alPreset.c +++ b/OpenAL32/alPreset.c @@ -117,6 +117,106 @@ AL_API ALboolean AL_APIENTRY alIsPresetSOFT(ALuint id) return ret; } +AL_API void AL_APIENTRY alPresetiSOFT(ALuint id, ALenum param, ALint value) +{ + ALCdevice *device; + ALCcontext *context; + ALsfpreset *preset; + + context = GetContextRef(); + if(!context) return; + + device = context->Device; + if((preset=LookupPreset(device, id)) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); + if(preset->ref != 0) + SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done); + switch(param) + { + case AL_MIDI_PRESET_SOFT: + if(!(value >= 0 && value <= 127)) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + preset->Preset = value; + break; + + case AL_MIDI_BANK_SOFT: + if(!(value >= 0 && value <= 128)) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + preset->Bank = value; + break; + + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); + } + +done: + ALCcontext_DecRef(context); +} + +AL_API void AL_APIENTRY alPresetivSOFT(ALuint id, ALenum param, const ALint *values) +{ + ALCdevice *device; + ALCcontext *context; + ALsfpreset *preset; + + switch(param) + { + case AL_MIDI_PRESET_SOFT: + case AL_MIDI_BANK_SOFT: + alPresetiSOFT(id, param, values[0]); + return; + } + + context = GetContextRef(); + if(!context) return; + + device = context->Device; + if((preset=LookupPreset(device, id)) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); + if(preset->ref != 0) + SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done); + switch(param) + { + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); + } + +done: + ALCcontext_DecRef(context); +} + +AL_API void AL_APIENTRY alGetPresetivSOFT(ALuint id, ALenum param, ALint *values) +{ + ALCdevice *device; + ALCcontext *context; + ALsfpreset *preset; + + context = GetContextRef(); + if(!context) return; + + device = context->Device; + if((preset=LookupPreset(device, id)) == NULL) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); + if(preset->ref != 0) + SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done); + switch(param) + { + case AL_MIDI_PRESET_SOFT: + values[0] = preset->Preset; + break; + + case AL_MIDI_BANK_SOFT: + values[0] = preset->Bank; + break; + + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); + } + +done: + ALCcontext_DecRef(context); +} + /* ReleaseALPresets * |