Remove code duplication by re-using enum from fluid_gen.h

We already have an enum for all generator values, so there is
no need to define another list in the loader code.
This commit is contained in:
Marcus Weseloh 2021-03-27 16:09:47 +01:00
parent c4d38a7125
commit 6b63c80d3d

View file

@ -112,98 +112,32 @@ static const uint32_t idlist[] =
SM24_FCC SM24_FCC
}; };
/* generator types */
typedef enum
{
Gen_StartAddrOfs,
Gen_EndAddrOfs,
Gen_StartLoopAddrOfs,
Gen_EndLoopAddrOfs,
Gen_StartAddrCoarseOfs,
Gen_ModLFO2Pitch,
Gen_VibLFO2Pitch,
Gen_ModEnv2Pitch,
Gen_FilterFc,
Gen_FilterQ,
Gen_ModLFO2FilterFc,
Gen_ModEnv2FilterFc,
Gen_EndAddrCoarseOfs,
Gen_ModLFO2Vol,
Gen_Unused1,
Gen_ChorusSend,
Gen_ReverbSend,
Gen_Pan,
Gen_Unused2,
Gen_Unused3,
Gen_Unused4,
Gen_ModLFODelay,
Gen_ModLFOFreq,
Gen_VibLFODelay,
Gen_VibLFOFreq,
Gen_ModEnvDelay,
Gen_ModEnvAttack,
Gen_ModEnvHold,
Gen_ModEnvDecay,
Gen_ModEnvSustain,
Gen_ModEnvRelease,
Gen_Key2ModEnvHold,
Gen_Key2ModEnvDecay,
Gen_VolEnvDelay,
Gen_VolEnvAttack,
Gen_VolEnvHold,
Gen_VolEnvDecay,
Gen_VolEnvSustain,
Gen_VolEnvRelease,
Gen_Key2VolEnvHold,
Gen_Key2VolEnvDecay,
Gen_Instrument,
Gen_Reserved1,
Gen_KeyRange,
Gen_VelRange,
Gen_StartLoopAddrCoarseOfs,
Gen_Keynum,
Gen_Velocity,
Gen_Attenuation,
Gen_Reserved2,
Gen_EndLoopAddrCoarseOfs,
Gen_CoarseTune,
Gen_FineTune,
Gen_SampleId,
Gen_SampleModes,
Gen_Reserved3,
Gen_ScaleTune,
Gen_ExclusiveClass,
Gen_OverrideRootKey,
Gen_Last /* Sentinel value, not a valid generator */
} Gen_Type;
static const unsigned short invalid_inst_gen[] = static const unsigned short invalid_inst_gen[] =
{ {
Gen_Unused1, GEN_UNUSED1,
Gen_Unused2, GEN_UNUSED2,
Gen_Unused3, GEN_UNUSED3,
Gen_Unused4, GEN_UNUSED4,
Gen_Reserved1, GEN_RESERVED1,
Gen_Reserved2, GEN_RESERVED2,
Gen_Reserved3, GEN_RESERVED3,
}; };
static const unsigned short invalid_preset_gen[] = static const unsigned short invalid_preset_gen[] =
{ {
Gen_StartAddrOfs, GEN_STARTADDROFS,
Gen_EndAddrOfs, GEN_ENDADDROFS,
Gen_StartLoopAddrOfs, GEN_STARTLOOPADDROFS,
Gen_EndLoopAddrOfs, GEN_ENDLOOPADDROFS,
Gen_StartAddrCoarseOfs, GEN_STARTADDRCOARSEOFS,
Gen_EndAddrCoarseOfs, GEN_ENDADDRCOARSEOFS,
Gen_StartLoopAddrCoarseOfs, GEN_STARTLOOPADDRCOARSEOFS,
Gen_Keynum, GEN_KEYNUM,
Gen_Velocity, GEN_VELOCITY,
Gen_EndLoopAddrCoarseOfs, GEN_ENDLOOPADDRCOARSEOFS,
Gen_SampleModes, GEN_SAMPLEMODE,
Gen_ExclusiveClass, GEN_EXCLUSIVECLASS,
Gen_OverrideRootKey, GEN_OVERRIDEROOTKEY,
}; };
@ -1409,7 +1343,7 @@ static int load_pgen(SFData *sf, int size)
READW(sf, genid); READW(sf, genid);
if(genid == Gen_KeyRange) if(genid == GEN_KEYRANGE)
{ {
/* nothing precedes */ /* nothing precedes */
if(level == 0) if(level == 0)
@ -1423,7 +1357,7 @@ static int load_pgen(SFData *sf, int size)
skip = TRUE; skip = TRUE;
} }
} }
else if(genid == Gen_VelRange) else if(genid == GEN_VELRANGE)
{ {
/* only KeyRange precedes */ /* only KeyRange precedes */
if(level <= 1) if(level <= 1)
@ -1437,7 +1371,7 @@ static int load_pgen(SFData *sf, int size)
skip = TRUE; skip = TRUE;
} }
} }
else if(genid == Gen_Instrument) else if(genid == GEN_INSTRUMENT)
{ {
/* inst is last gen */ /* inst is last gen */
level = 3; level = 3;
@ -1928,7 +1862,7 @@ static int load_igen(SFData *sf, int size)
READW(sf, genid); READW(sf, genid);
if(genid == Gen_KeyRange) if(genid == GEN_KEYRANGE)
{ {
/* nothing precedes */ /* nothing precedes */
if(level == 0) if(level == 0)
@ -1942,7 +1876,7 @@ static int load_igen(SFData *sf, int size)
skip = TRUE; skip = TRUE;
} }
} }
else if(genid == Gen_VelRange) else if(genid == GEN_VELRANGE)
{ {
/* only KeyRange precedes */ /* only KeyRange precedes */
if(level <= 1) if(level <= 1)
@ -1956,7 +1890,7 @@ static int load_igen(SFData *sf, int size)
skip = TRUE; skip = TRUE;
} }
} }
else if(genid == Gen_SampleId) else if(genid == GEN_SAMPLEID)
{ {
/* sample is last gen */ /* sample is last gen */
level = 3; level = 3;
@ -2370,7 +2304,10 @@ static int valid_inst_genid(unsigned short genid)
{ {
size_t i; size_t i;
if(genid >= Gen_Last) /* OVERRIDEROOTKEY is the last official generator, everything
* following it are generators internal to FluidSynth and will
* never appear in a SoundFont file. */
if(genid > GEN_OVERRIDEROOTKEY)
{ {
return FALSE; return FALSE;
} }