Add methods to get and set a preset object's preset and bank numbers
This commit is contained in:
@@ -290,6 +290,9 @@ static const ALCfunction alcFunctions[] = {
|
||||
DECL(alGenPresetsSOFT),
|
||||
DECL(alDeletePresetsSOFT),
|
||||
DECL(alIsPresetSOFT),
|
||||
DECL(alPresetiSOFT),
|
||||
DECL(alPresetivSOFT),
|
||||
DECL(alGetPresetivSOFT),
|
||||
DECL(alGenInstrumentsSOFT),
|
||||
DECL(alDeleteInstrumentsSOFT),
|
||||
DECL(alIsInstrumentSOFT),
|
||||
|
||||
@@ -425,6 +425,9 @@ void ALsfpreset_Construct(ALsfpreset *self)
|
||||
{
|
||||
self->ref = 0;
|
||||
|
||||
self->Preset = 0;
|
||||
self->Bank = 0;
|
||||
|
||||
self->Zones = NULL;
|
||||
self->NumZones = 0;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user