Add methods to get and set presets on a soundfont
This commit is contained in:
parent
d7de86966d
commit
a43b296c60
@ -287,6 +287,8 @@ static const ALCfunction alcFunctions[] = {
|
||||
DECL(alSoundfontSamplesSOFT),
|
||||
DECL(alSoundfontMapSamplesSOFT),
|
||||
DECL(alSoundfontUnmapSamplesSOFT),
|
||||
DECL(alGetSoundfontivSOFT),
|
||||
DECL(alSoundfontPresetsSOFT),
|
||||
DECL(alGenPresetsSOFT),
|
||||
DECL(alDeletePresetsSOFT),
|
||||
DECL(alIsPresetSOFT),
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user