Store 4 modulators per map entry
This commit is contained in:
parent
dc76013126
commit
8dec92531b
@ -171,14 +171,16 @@ static void FSample_Construct(FSample *self, ALfontsound *sound)
|
||||
self->Sound = sound;
|
||||
|
||||
self->NumMods = 0;
|
||||
self->Mods = calloc(sound->ModulatorMap.size, sizeof(self->Mods[0]));
|
||||
self->Mods = calloc(sound->ModulatorMap.size*4, sizeof(fluid_mod_t[4]));
|
||||
if(self->Mods)
|
||||
{
|
||||
ALsizei i, j;
|
||||
ALsizei i, j, k;
|
||||
|
||||
for(i = j = 0;i < sound->ModulatorMap.size;i++)
|
||||
{
|
||||
ALsfmodulator *mod = sound->ModulatorMap.array[i].value;
|
||||
for(k = 0;k < 4;k++,mod++)
|
||||
{
|
||||
if(mod->Dest == AL_NONE)
|
||||
continue;
|
||||
fluid_mod_set_source1(&self->Mods[j], getGenInput(mod->Source[0].Input),
|
||||
@ -191,6 +193,7 @@ static void FSample_Construct(FSample *self, ALfontsound *sound)
|
||||
fluid_mod_set_dest(&self->Mods[j], getSf2Gen(mod->Dest));
|
||||
self->Mods[j++].next = NULL;
|
||||
}
|
||||
}
|
||||
self->NumMods = j;
|
||||
}
|
||||
}
|
||||
@ -260,7 +263,6 @@ static void FPreset_Destruct(FPreset *self)
|
||||
static ALboolean FPreset_canDelete(FPreset *self)
|
||||
{
|
||||
ALsizei i;
|
||||
|
||||
for(i = 0;i < self->NumSamples;i++)
|
||||
{
|
||||
if(fluid_sample_refcount(STATIC_CAST(fluid_sample_t, &self->Samples[i])) != 0)
|
||||
@ -300,8 +302,7 @@ static int FPreset_noteOn(fluid_preset_t *preset, fluid_synth_t *synth, int chan
|
||||
continue;
|
||||
|
||||
voice = fluid_synth_alloc_voice(synth, STATIC_CAST(fluid_sample_t, sample), channel, key, vel);
|
||||
if(voice == NULL)
|
||||
return FLUID_FAILED;
|
||||
if(voice == NULL) return FLUID_FAILED;
|
||||
|
||||
fluid_voice_gen_set(voice, GEN_MODLFOTOPITCH, sound->ModLfoToPitch);
|
||||
fluid_voice_gen_set(voice, GEN_VIBLFOTOPITCH, sound->VibratoLfoToPitch);
|
||||
|
@ -87,6 +87,7 @@ typedef struct ALfontsound {
|
||||
ALenum SampleType;
|
||||
struct ALfontsound *Link;
|
||||
|
||||
/* NOTE: Each map entry contains *four* (4) ALsfmodulator objects. */
|
||||
UIntMap ModulatorMap;
|
||||
|
||||
ALuint id;
|
||||
|
@ -25,9 +25,11 @@ void ALfontsound_setModStagei(ALfontsound *self, ALCcontext *context, ALsizei st
|
||||
static void ALfontsound_getModStagei(ALfontsound *self, ALCcontext *context, ALsizei stage, ALenum param, ALint *values);
|
||||
|
||||
static inline struct ALsfmodulator *LookupModulator(ALfontsound *sound, ALuint id)
|
||||
{ return (struct ALsfmodulator*)LookupUIntMapKey(&sound->ModulatorMap, id); }
|
||||
static inline struct ALsfmodulator *RemoveModulator(ALfontsound *sound, ALuint id)
|
||||
{ return (struct ALsfmodulator*)RemoveUIntMapKey(&sound->ModulatorMap, id); }
|
||||
{
|
||||
ALsfmodulator *mod = LookupUIntMapKey(&sound->ModulatorMap, id>>2);
|
||||
if(mod) mod += id&3;
|
||||
return mod;
|
||||
}
|
||||
|
||||
|
||||
AL_API void AL_APIENTRY alGenFontsoundsSOFT(ALsizei n, ALuint *ids)
|
||||
@ -846,15 +848,18 @@ static ALsfmodulator *ALfontsound_getModStage(ALfontsound *self, ALsizei stage)
|
||||
{
|
||||
static const ALsfmodulator moddef = {
|
||||
{ { AL_ONE_SOFT, AL_UNORM_SOFT, AL_LINEAR_SOFT },
|
||||
{ AL_ONE_SOFT, AL_UNORM_SOFT, AL_LINEAR_SOFT }
|
||||
},
|
||||
{ AL_ONE_SOFT, AL_UNORM_SOFT, AL_LINEAR_SOFT } },
|
||||
0,
|
||||
AL_LINEAR_SOFT,
|
||||
AL_NONE
|
||||
};
|
||||
ret = malloc(sizeof(*ret));
|
||||
*ret = moddef;
|
||||
InsertUIntMapEntry(&self->ModulatorMap, stage, ret);
|
||||
ret = malloc(sizeof(ALsfmodulator[4]));
|
||||
ret[0] = moddef;
|
||||
ret[1] = moddef;
|
||||
ret[2] = moddef;
|
||||
ret[3] = moddef;
|
||||
InsertUIntMapEntry(&self->ModulatorMap, stage>>2, ret);
|
||||
ret += stage&3;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user