summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/midi/fluidsynth.c33
-rw-r--r--OpenAL32/Include/alMidi.h1
-rw-r--r--OpenAL32/alFontsound.c21
3 files changed, 31 insertions, 24 deletions
diff --git a/Alc/midi/fluidsynth.c b/Alc/midi/fluidsynth.c
index 8810f607..7f003e09 100644
--- a/Alc/midi/fluidsynth.c
+++ b/Alc/midi/fluidsynth.c
@@ -171,25 +171,28 @@ 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;
- if(mod->Dest == AL_NONE)
- continue;
- fluid_mod_set_source1(&self->Mods[j], getGenInput(mod->Source[0].Input),
- getGenFlags(mod->Source[0].Input, mod->Source[0].Type,
- mod->Source[0].Form));
- fluid_mod_set_source2(&self->Mods[j], getGenInput(mod->Source[1].Input),
- getGenFlags(mod->Source[1].Input, mod->Source[1].Type,
- mod->Source[1].Form));
- fluid_mod_set_amount(&self->Mods[j], mod->Amount);
- fluid_mod_set_dest(&self->Mods[j], getSf2Gen(mod->Dest));
- self->Mods[j++].next = NULL;
+ 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),
+ getGenFlags(mod->Source[0].Input, mod->Source[0].Type,
+ mod->Source[0].Form));
+ fluid_mod_set_source2(&self->Mods[j], getGenInput(mod->Source[1].Input),
+ getGenFlags(mod->Source[1].Input, mod->Source[1].Type,
+ mod->Source[1].Form));
+ fluid_mod_set_amount(&self->Mods[j], mod->Amount);
+ 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);
diff --git a/OpenAL32/Include/alMidi.h b/OpenAL32/Include/alMidi.h
index 082e16d1..f3f623a5 100644
--- a/OpenAL32/Include/alMidi.h
+++ b/OpenAL32/Include/alMidi.h
@@ -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;
diff --git a/OpenAL32/alFontsound.c b/OpenAL32/alFontsound.c
index aaa65c98..3a8f1460 100644
--- a/OpenAL32/alFontsound.c
+++ b/OpenAL32/alFontsound.c
@@ -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;
}