aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/midi
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-12-21 15:28:46 -0800
committerChris Robinson <[email protected]>2013-12-21 15:28:46 -0800
commit0df5eb90ea0d244050f71c5f71167c46cbc17355 (patch)
treead7e9bd27d5146b565f5b1e8ffbb27befab7d91d /Alc/midi
parentede3c208806af5c1180b72cae0ba4943bd6f0bfd (diff)
Make sure key and velocity ranges are the first two generators
Diffstat (limited to 'Alc/midi')
-rw-r--r--Alc/midi/base.c28
1 files changed, 28 insertions, 0 deletions
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++;