diff options
author | Chris Robinson <[email protected]> | 2013-12-23 04:07:53 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2013-12-23 04:07:53 -0800 |
commit | a43b296c60619e20095bdddcdaf0ad8e5ab87549 (patch) | |
tree | 8556b723fb677e70051eb7d248c578b7d3364b55 | |
parent | d7de86966d677366d8514a32be46b3040d9bc902 (diff) |
Add methods to get and set presets on a soundfont
-rw-r--r-- | Alc/ALc.c | 2 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 10 | ||||
-rw-r--r-- | OpenAL32/alSoundfont.c | 93 |
3 files changed, 103 insertions, 2 deletions
@@ -287,6 +287,8 @@ static const ALCfunction alcFunctions[] = { DECL(alSoundfontSamplesSOFT), DECL(alSoundfontMapSamplesSOFT), DECL(alSoundfontUnmapSamplesSOFT), + DECL(alGetSoundfontivSOFT), + DECL(alSoundfontPresetsSOFT), DECL(alGenPresetsSOFT), DECL(alDeletePresetsSOFT), DECL(alIsPresetSOFT), diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 79ccdb60..d5730007 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -33,6 +33,8 @@ #define AL_MIDI_GAIN_SOFT 0x9998 #define AL_MIDI_PRESET_SOFT 0x9997 #define AL_MIDI_BANK_SOFT 0x9996 +#define AL_PRESETS_SIZE_SOFT 0x9995 +#define AL_PRESETS_SOFT 0x9994 #define AL_NOTEOFF_SOFT 0x0080 #define AL_NOTEON_SOFT 0x0090 #define AL_AFTERTOUCH_SOFT 0x00A0 @@ -46,6 +48,8 @@ typedef ALboolean (AL_APIENTRY*LPALISSOUNDFONTSOFT)(ALuint id); typedef void (AL_APIENTRY*LPALSOUNDFONTSAMPLESSOFT)(ALuint sfid, ALenum type, ALsizei count, const ALvoid *samples); typedef ALvoid* (AL_APIENTRY*LPALSOUNDFONTMAPSAMPLESSOFT)(ALuint sfid, ALsizei offset, ALsizei length); typedef void (AL_APIENTRY*LPALSOUNDFONTUNMAPSAMPLESSOFT)(ALuint sfid); +typedef void (AL_APIENTRY*LPALGETSOUNDFONTIVSOFT)(ALuint id, ALenum param, ALint *values); +typedef void (AL_APIENTRY*LPALSOUNDFONTPRESETSSOFT)(ALuint id, ALsizei count, const ALuint *pids); 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); @@ -69,9 +73,11 @@ typedef void (AL_APIENTRY*LPALGETINTEGER64VSOFT)(ALenum pname, ALint64SOFT *valu AL_API void AL_APIENTRY alGenSoundfontsSOFT(ALsizei n, ALuint *ids); AL_API void AL_APIENTRY alDeleteSoundfontsSOFT(ALsizei n, const ALuint *ids); AL_API ALboolean AL_APIENTRY alIsSoundfontSOFT(ALuint id); -AL_API ALvoid AL_APIENTRY alSoundfontSamplesSOFT(ALuint sfid, ALenum type, ALsizei count, const ALvoid *samples); +AL_API void AL_APIENTRY alSoundfontSamplesSOFT(ALuint sfid, ALenum type, ALsizei count, const ALvoid *samples); AL_API ALvoid* AL_APIENTRY alSoundfontMapSamplesSOFT(ALuint sfid, ALsizei offset, ALsizei length); -AL_API ALvoid AL_APIENTRY alSoundfontUnmapSamplesSOFT(ALuint sfid); +AL_API void AL_APIENTRY alSoundfontUnmapSamplesSOFT(ALuint sfid); +AL_API void AL_APIENTRY alGetSoundfontivSOFT(ALuint id, ALenum param, ALint *values); +AL_API void AL_APIENTRY alSoundfontPresetsSOFT(ALuint id, ALsizei count, const ALuint *pids); AL_API void AL_APIENTRY alGenPresetsSOFT(ALsizei n, ALuint *ids); AL_API void AL_APIENTRY alDeletePresetsSOFT(ALsizei n, const ALuint *ids); diff --git a/OpenAL32/alSoundfont.c b/OpenAL32/alSoundfont.c index 12f89094..1ccb7b69 100644 --- a/OpenAL32/alSoundfont.c +++ b/OpenAL32/alSoundfont.c @@ -207,6 +207,99 @@ done: ALCcontext_DecRef(context); } +AL_API void AL_APIENTRY alGetSoundfontivSOFT(ALuint id, ALenum param, ALint *values) +{ + ALCdevice *device; + ALCcontext *context; + ALsoundfont *sfont; + ALsizei i; + + context = GetContextRef(); + if(!context) return; + + device = context->Device; + if(!(sfont=LookupSfont(device, id))) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); + switch(param) + { + case AL_PRESETS_SIZE_SOFT: + values[0] = sfont->NumPresets; + break; + + case AL_PRESETS_SOFT: + for(i = 0;i < sfont->NumPresets;i++) + values[i] = sfont->Presets[i]->id; + break; + + default: + SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); + } + +done: + ALCcontext_DecRef(context); +} + +AL_API void AL_APIENTRY alSoundfontPresetsSOFT(ALuint id, ALsizei count, const ALuint *pids) +{ + ALCdevice *device; + ALCcontext *context; + ALsoundfont *sfont; + ALsfpreset **presets; + ALsizei i; + + context = GetContextRef(); + if(!context) return; + + device = context->Device; + if(!(sfont=LookupSfont(device, id))) + SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); + if(count < 0) + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + + WriteLock(&sfont->Lock); + if(sfont->ref != 0) + { + WriteUnlock(&sfont->Lock); + SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done); + } + + if(count == 0) + presets = NULL; + else + { + presets = calloc(count, sizeof(presets[0])); + if(!presets) + { + WriteUnlock(&sfont->Lock); + SET_ERROR_AND_GOTO(context, AL_OUT_OF_MEMORY, done); + } + + for(i = 0;i < count;i++) + { + if(!(presets[i]=LookupPreset(device, pids[i]))) + { + WriteUnlock(&sfont->Lock); + SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); + } + } + } + + for(i = 0;i < count;i++) + IncrementRef(&presets[i]->ref); + + presets = ExchangePtr((XchgPtr*)&sfont->Presets, presets); + count = ExchangeInt(&sfont->NumPresets, count); + + for(i = 0;i < count;i++) + DecrementRef(&presets[i]->ref); + free(presets); + + WriteUnlock(&sfont->Lock); + +done: + ALCcontext_DecRef(context); +} + /* ReleaseALSoundfonts * |