Use ALfontsound_setPropi to set fontsound sample properties

And make sure the loop mode is properly translated for FluidSynth.
This commit is contained in:
Chris Robinson
2014-01-15 21:17:46 -08:00
parent 50b74629dd
commit 9ebeae6228
2 changed files with 30 additions and 13 deletions
+12 -1
View File
@@ -113,6 +113,17 @@ static enum fluid_gen_type getSf2Gen(ALenum gen)
return 0;
}
static int getSf2LoopMode(ALenum mode)
{
switch(mode)
{
case AL_NONE: return 0;
case AL_LOOP_CONTINUOUS_SOFT: return 1;
case AL_LOOP_UNTIL_RELEASE_SOFT: return 3;
}
return 0;
}
typedef struct FSample {
DERIVE_FROM_TYPE(fluid_sample_t);
@@ -313,7 +324,7 @@ static int FPreset_noteOn(fluid_preset_t *preset, fluid_synth_t *synth, int chan
fluid_voice_gen_set(voice, GEN_ATTENUATION, sound->Attenuation);
fluid_voice_gen_set(voice, GEN_COARSETUNE, sound->CoarseTuning);
fluid_voice_gen_set(voice, GEN_FINETUNE, sound->FineTuning);
fluid_voice_gen_set(voice, GEN_SAMPLEMODE, sound->LoopMode);
fluid_voice_gen_set(voice, GEN_SAMPLEMODE, getSf2LoopMode(sound->LoopMode));
fluid_voice_gen_set(voice, GEN_SCALETUNE, sound->TuningScale);
fluid_voice_gen_set(voice, GEN_EXCLUSIVECLASS, sound->ExclusiveClass);
for(m = 0;m < sample->NumMods;m++)
+18 -12
View File
@@ -763,6 +763,14 @@ static ALenum getModTransOp(int op)
return AL_INVALID;
}
static ALenum getLoopMode(int mode)
{
if(mode == 0) return AL_NONE;
if(mode == 1) return AL_LOOP_CONTINUOUS_SOFT;
if(mode == 3) return AL_LOOP_UNTIL_RELEASE_SOFT;
ERR("Unhandled loop mode: %d\n", mode);
return AL_NONE;
}
static void fillZone(ALfontsound *sound, ALCcontext *context, const GenModList *zone)
{
@@ -909,10 +917,7 @@ static void fillZone(ALfontsound *sound, ALCcontext *context, const GenModList *
else if(param == AL_CHORUS_SEND_SOFT || param == AL_REVERB_SEND_SOFT)
value = clampi(value, 0, 1000);
else if(param == AL_LOOP_MODE_SOFT)
{
if(!(value == 0 || value == 1 || value == 3))
value = 0;
}
value = getLoopMode(value);
ALfontsound_setPropi(sound, context, param, value);
}
else if(gen->mGenerator < 256)
@@ -1016,14 +1021,15 @@ static void processInstrument(ALfontsound ***sounds, ALsizei *sounds_size, ALCco
break;
(*sounds)[*sounds_size] = NewFontsound(context);
(*sounds)[*sounds_size]->Start = samp->mStart;
(*sounds)[*sounds_size]->End = samp->mEnd;
(*sounds)[*sounds_size]->LoopStart = samp->mStartloop;
(*sounds)[*sounds_size]->LoopEnd = samp->mEndloop;
(*sounds)[*sounds_size]->SampleRate = samp->mSampleRate;
(*sounds)[*sounds_size]->PitchKey = samp->mOriginalKey;
(*sounds)[*sounds_size]->PitchCorrection = samp->mCorrection;
(*sounds)[*sounds_size]->LoopMode = (samp->mSampleType&0x7ffff);
ALfontsound_setPropi((*sounds)[*sounds_size], context, AL_SAMPLE_START_SOFT, samp->mStart);
ALfontsound_setPropi((*sounds)[*sounds_size], context, AL_SAMPLE_END_SOFT, samp->mEnd);
ALfontsound_setPropi((*sounds)[*sounds_size], context, AL_SAMPLE_LOOP_START_SOFT, samp->mStartloop);
ALfontsound_setPropi((*sounds)[*sounds_size], context, AL_SAMPLE_LOOP_END_SOFT, samp->mEndloop);
ALfontsound_setPropi((*sounds)[*sounds_size], context, AL_SAMPLE_RATE_SOFT, samp->mSampleRate);
ALfontsound_setPropi((*sounds)[*sounds_size], context, AL_BASE_KEY_SOFT, samp->mOriginalKey);
ALfontsound_setPropi((*sounds)[*sounds_size], context, AL_KEY_CORRECTION_SOFT, samp->mCorrection);
if(samp->mSampleType == 1 || samp->mSampleType == 2 || samp->mSampleType == 4)
ALfontsound_setPropi((*sounds)[*sounds_size], context, AL_SAMPLE_TYPE_SOFT, samp->mSampleType);
fillZone((*sounds)[*sounds_size], context, &lzone);
(*sounds_size)++;