Add volume envelope properties

This commit is contained in:
Chris Robinson 2013-12-29 02:14:10 -08:00
parent 4659669a74
commit fc928bb75a
6 changed files with 116 additions and 8 deletions

View File

@ -295,6 +295,15 @@ void ALfontsound_Construct(ALfontsound *self)
self->MinVelocity = 0; self->MinVelocity = 0;
self->MaxVelocity = 127; self->MaxVelocity = 127;
self->VolEnv.DelayTime = -12000;
self->VolEnv.AttackTime = -12000;
self->VolEnv.HoldTime = -12000;
self->VolEnv.DecayTime = -12000;
self->VolEnv.SustainVol = 0;
self->VolEnv.ReleaseTime = -12000;
self->VolEnv.KeyToHoldTime = 0;
self->VolEnv.KeyToDecayTime = 0;
self->Start = 0; self->Start = 0;
self->End = 0; self->End = 0;
self->LoopStart = 0; self->LoopStart = 0;

View File

@ -163,6 +163,14 @@ static int FPreset_noteOn(fluid_preset_t *preset, fluid_synth_t *synth, int chan
if(voice == NULL) if(voice == NULL)
return FLUID_FAILED; return FLUID_FAILED;
fluid_voice_gen_set(voice, 33, sound->VolEnv.DelayTime);
fluid_voice_gen_set(voice, 34, sound->VolEnv.AttackTime);
fluid_voice_gen_set(voice, 35, sound->VolEnv.HoldTime);
fluid_voice_gen_set(voice, 36, sound->VolEnv.DecayTime);
fluid_voice_gen_set(voice, 37, sound->VolEnv.SustainVol);
fluid_voice_gen_set(voice, 38, sound->VolEnv.ReleaseTime);
fluid_voice_gen_set(voice, 39, sound->VolEnv.KeyToHoldTime);
fluid_voice_gen_set(voice, 40, sound->VolEnv.KeyToDecayTime);
fluid_voice_gen_set(voice, 54, sound->LoopMode); fluid_voice_gen_set(voice, 54, sound->LoopMode);
for(m = 0;m < sample->NumMods;m++) for(m = 0;m < sample->NumMods;m++)
fluid_voice_add_mod(voice, &sample->Mods[m], FLUID_VOICE_OVERWRITE); fluid_voice_add_mod(voice, &sample->Mods[m], FLUID_VOICE_OVERWRITE);

View File

@ -827,14 +827,14 @@ static void fillZone(ALuint id, const GenModList *zone)
0, /* 30 - releaseModEnv */ 0, /* 30 - releaseModEnv */
0, /* 31 - keynumToModEnvHold */ 0, /* 31 - keynumToModEnvHold */
0, /* 32 - keynumToModEnvDecay */ 0, /* 32 - keynumToModEnvDecay */
0, /* 33 - delayVolEnv */ AL_VOLUME_ENV_DELAYTIME_SOFT, /* 33 - delayVolEnv */
0, /* 34 - attackVolEnv */ AL_VOLUME_ENV_ATTACKTIME_SOFT, /* 34 - attackVolEnv */
0, /* 35 - holdVolEnv */ AL_VOLUME_ENV_HOLDTIME_SOFT, /* 35 - holdVolEnv */
0, /* 36 - decayVolEnv */ AL_VOLUME_ENV_DECAYTIME_SOFT, /* 36 - decayVolEnv */
0, /* 37 - sustainVolEnv */ AL_VOLUME_ENV_SUSTAINVOLUME_SOFT, /* 37 - sustainVolEnv */
0, /* 38 - releaseVolEnv */ AL_VOLUME_ENV_RELEASETIME_SOFT, /* 38 - releaseVolEnv */
0, /* 39 - keynumToVolEnvHold */ AL_VOLUME_ENV_KEY_TO_HOLDTIME_SOFT, /* 39 - keynumToVolEnvHold */
0, /* 40 - keynumToVolEnvDecay */ AL_VOLUME_ENV_KEY_TO_DECAYTIME_SOFT, /* 40 - keynumToVolEnvDecay */
0, /* 41 - */ 0, /* 41 - */
0, /* 42 - */ 0, /* 42 - */
AL_KEY_RANGE_SOFT, /* 43 - keyRange */ AL_KEY_RANGE_SOFT, /* 43 - keyRange */

View File

@ -48,6 +48,14 @@
#define AL_KEY_CORRECTION_SOFT 0x2006 #define AL_KEY_CORRECTION_SOFT 0x2006
#define AL_SAMPLE_TYPE_SOFT 0x2007 #define AL_SAMPLE_TYPE_SOFT 0x2007
#define AL_FONTSOUND_LINK_SOFT 0x2008 #define AL_FONTSOUND_LINK_SOFT 0x2008
#define AL_VOLUME_ENV_DELAYTIME_SOFT 0x0021
#define AL_VOLUME_ENV_ATTACKTIME_SOFT 0x0022
#define AL_VOLUME_ENV_HOLDTIME_SOFT 0x0023
#define AL_VOLUME_ENV_DECAYTIME_SOFT 0x0024
#define AL_VOLUME_ENV_SUSTAINVOLUME_SOFT 0x0025
#define AL_VOLUME_ENV_RELEASETIME_SOFT 0x0026
#define AL_VOLUME_ENV_KEY_TO_HOLDTIME_SOFT 0x0027
#define AL_VOLUME_ENV_KEY_TO_DECAYTIME_SOFT 0x0028
#define AL_KEY_RANGE_SOFT 0x002B #define AL_KEY_RANGE_SOFT 0x002B
#define AL_VELOCITY_RANGE_SOFT 0x002C #define AL_VELOCITY_RANGE_SOFT 0x002C
#define AL_LOOP_MODE_SOFT 0x0036 #define AL_LOOP_MODE_SOFT 0x0036

View File

@ -23,6 +23,17 @@ typedef struct ALfontsound {
ALint MinKey, MaxKey; ALint MinKey, MaxKey;
ALint MinVelocity, MaxVelocity; ALint MinVelocity, MaxVelocity;
struct {
ALint DelayTime;
ALint AttackTime;
ALint HoldTime;
ALint DecayTime;
ALint SustainVol;
ALint ReleaseTime;
ALint KeyToHoldTime;
ALint KeyToDecayTime;
} VolEnv;
ALuint Start; ALuint Start;
ALuint End; ALuint End;
ALuint LoopStart; ALuint LoopStart;

View File

@ -130,6 +130,38 @@ AL_API void AL_APIENTRY alFontsoundiSOFT(ALuint id, ALenum param, ALint value)
SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done); SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done);
switch(param) switch(param)
{ {
case AL_VOLUME_ENV_DELAYTIME_SOFT:
sound->VolEnv.DelayTime = value;
break;
case AL_VOLUME_ENV_ATTACKTIME_SOFT:
sound->VolEnv.AttackTime = value;
break;
case AL_VOLUME_ENV_HOLDTIME_SOFT:
sound->VolEnv.HoldTime = value;
break;
case AL_VOLUME_ENV_DECAYTIME_SOFT:
sound->VolEnv.DecayTime = value;
break;
case AL_VOLUME_ENV_SUSTAINVOLUME_SOFT:
sound->VolEnv.SustainVol = value;
break;
case AL_VOLUME_ENV_RELEASETIME_SOFT:
sound->VolEnv.ReleaseTime = value;
break;
case AL_VOLUME_ENV_KEY_TO_HOLDTIME_SOFT:
sound->VolEnv.KeyToHoldTime = value;
break;
case AL_VOLUME_ENV_KEY_TO_DECAYTIME_SOFT:
sound->VolEnv.KeyToDecayTime = value;
break;
case AL_SAMPLE_START_SOFT: case AL_SAMPLE_START_SOFT:
sound->Start = value; sound->Start = value;
break; break;
@ -250,6 +282,14 @@ AL_API void AL_APIENTRY alFontsoundivSOFT(ALuint id, ALenum param, const ALint *
alFontsound2iSOFT(id, param, values[0], values[1]); alFontsound2iSOFT(id, param, values[0], values[1]);
return; return;
case AL_VOLUME_ENV_DELAYTIME_SOFT:
case AL_VOLUME_ENV_ATTACKTIME_SOFT:
case AL_VOLUME_ENV_HOLDTIME_SOFT:
case AL_VOLUME_ENV_DECAYTIME_SOFT:
case AL_VOLUME_ENV_SUSTAINVOLUME_SOFT:
case AL_VOLUME_ENV_RELEASETIME_SOFT:
case AL_VOLUME_ENV_KEY_TO_HOLDTIME_SOFT:
case AL_VOLUME_ENV_KEY_TO_DECAYTIME_SOFT:
case AL_SAMPLE_START_SOFT: case AL_SAMPLE_START_SOFT:
case AL_SAMPLE_END_SOFT: case AL_SAMPLE_END_SOFT:
case AL_SAMPLE_LOOP_START_SOFT: case AL_SAMPLE_LOOP_START_SOFT:
@ -296,6 +336,38 @@ AL_API void AL_APIENTRY alGetFontsoundivSOFT(ALuint id, ALenum param, ALint *val
SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
switch(param) switch(param)
{ {
case AL_VOLUME_ENV_DELAYTIME_SOFT:
values[0] = sound->VolEnv.DelayTime;
break;
case AL_VOLUME_ENV_ATTACKTIME_SOFT:
values[0] = sound->VolEnv.AttackTime;
break;
case AL_VOLUME_ENV_HOLDTIME_SOFT:
values[0] = sound->VolEnv.HoldTime;
break;
case AL_VOLUME_ENV_DECAYTIME_SOFT:
values[0] = sound->VolEnv.DecayTime;
break;
case AL_VOLUME_ENV_SUSTAINVOLUME_SOFT:
values[0] = sound->VolEnv.SustainVol;
break;
case AL_VOLUME_ENV_RELEASETIME_SOFT:
values[0] = sound->VolEnv.ReleaseTime;
break;
case AL_VOLUME_ENV_KEY_TO_HOLDTIME_SOFT:
values[0] = sound->VolEnv.KeyToHoldTime;
break;
case AL_VOLUME_ENV_KEY_TO_DECAYTIME_SOFT:
values[0] = sound->VolEnv.KeyToDecayTime;
break;
case AL_KEY_RANGE_SOFT: case AL_KEY_RANGE_SOFT:
values[0] = sound->MinKey; values[0] = sound->MinKey;
values[1] = sound->MaxKey; values[1] = sound->MaxKey;