From 0df5eb90ea0d244050f71c5f71167c46cbc17355 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 21 Dec 2013 15:28:46 -0800 Subject: Make sure key and velocity ranges are the first two generators --- Alc/midi/base.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'Alc/midi') diff --git a/Alc/midi/base.c b/Alc/midi/base.c index 45136faf..b7e94fd2 100644 --- a/Alc/midi/base.c +++ b/Alc/midi/base.c @@ -297,6 +297,34 @@ ALenum ALsfzone_addGenerator(ALsfzone *self, ALenum generator, ALint value) self->GeneratorsMax = newmax; } + /* Make sure key range generator is first in the list. */ + if(generator == 43/*key range*/ && self->NumGenerators > 0) + { + memmove(&self->Generators[1], &self->Generators[0], self->NumGenerators); + self->Generators[0].Generator = generator; + self->Generators[0].Value = value; + self->NumGenerators++; + + return AL_NO_ERROR; + } + + /* Make sure velocity range generator is second only to key range. */ + if(generator == 44/*vel range*/ && self->NumGenerators > 0) + { + ALsizei base = 0; + if(self->Generators[0].Generator == 43/*key range*/) + base = 1; + if(self->NumGenerators > base) + { + memmove(&self->Generators[base+1], &self->Generators[base], self->NumGenerators-base); + self->Generators[base].Generator = generator; + self->Generators[base].Value = value; + self->NumGenerators++; + + return AL_NO_ERROR; + } + } + self->Generators[self->NumGenerators].Generator = generator; self->Generators[self->NumGenerators].Value = value; self->NumGenerators++; -- cgit v1.2.3