diff options
author | Chris Robinson <[email protected]> | 2013-12-25 19:23:34 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2013-12-25 19:23:34 -0800 |
commit | b650ecbc23222ebd295384fce45aaca8cfb5c368 (patch) | |
tree | 0ab985988bb87f04f9d7c0584061837de274ae94 | |
parent | 94ddc5cb1889a42c9ffe98b79e431b596a9563df (diff) |
Add methods to add generators and modulators to fontsounds
-rw-r--r-- | Alc/midi/base.c | 71 | ||||
-rw-r--r-- | OpenAL32/Include/alMidi.h | 2 |
2 files changed, 73 insertions, 0 deletions
diff --git a/Alc/midi/base.c b/Alc/midi/base.c index 33c39133..f3f89743 100644 --- a/Alc/midi/base.c +++ b/Alc/midi/base.c @@ -467,6 +467,77 @@ void ALfontsound_Destruct(ALfontsound *self) self->id = 0; } +ALenum ALfontsound_addGenerator(ALfontsound *self, ALenum generator, ALint value) +{ + ALsizei i; + for(i = 0;i < self->NumGenerators;i++) + { + if(self->Generators[i].Generator == generator) + { + self->Generators[i].Value = value; + return AL_NO_ERROR; + } + } + + if(self->NumGenerators == self->GeneratorsMax) + { + ALsizei newmax = 0; + ALvoid *temp = NULL; + + newmax = (self->GeneratorsMax ? self->GeneratorsMax<<1 : 1); + if(newmax > self->GeneratorsMax) + temp = realloc(self->Generators, newmax * sizeof(ALsfgenerator)); + if(!temp) return AL_OUT_OF_MEMORY; + + self->Generators = temp; + self->GeneratorsMax = newmax; + } + + self->Generators[self->NumGenerators].Generator = generator; + self->Generators[self->NumGenerators].Value = value; + self->NumGenerators++; + + return AL_NO_ERROR; +} + +ALenum ALfontsound_addModulator(ALfontsound *self, ALenum sourceop, ALenum destop, ALint amount, ALenum amtsourceop, ALenum transop) +{ + ALsizei i; + for(i = 0;i < self->NumModulators;i++) + { + if(self->Modulators[i].SourceOp == sourceop && self->Modulators[i].DestOp == destop && + self->Modulators[i].AmountSourceOp == amtsourceop && + self->Modulators[i].TransformOp == transop) + { + self->Modulators[i].Amount = amount; + return AL_NO_ERROR; + } + } + + if(self->NumModulators == self->ModulatorsMax) + { + ALsizei newmax = 0; + ALvoid *temp = NULL; + + newmax = (self->ModulatorsMax ? self->ModulatorsMax<<1 : 1); + if(newmax > self->ModulatorsMax) + temp = realloc(self->Modulators, newmax * sizeof(ALsfmodulator)); + if(!temp) return AL_OUT_OF_MEMORY; + + self->Modulators = temp; + self->ModulatorsMax = newmax; + } + + self->Modulators[self->NumModulators].SourceOp = sourceop; + self->Modulators[self->NumModulators].DestOp = destop; + self->Modulators[self->NumModulators].Amount = amount; + self->Modulators[self->NumModulators].AmountSourceOp = amtsourceop; + self->Modulators[self->NumModulators].TransformOp = transop; + self->NumModulators++; + + return AL_NO_ERROR; +} + void ALsfpreset_Construct(ALsfpreset *self) { diff --git a/OpenAL32/Include/alMidi.h b/OpenAL32/Include/alMidi.h index 374940c1..9b195d26 100644 --- a/OpenAL32/Include/alMidi.h +++ b/OpenAL32/Include/alMidi.h @@ -113,6 +113,8 @@ typedef struct ALfontsound { void ALfontsound_Construct(ALfontsound *self); void ALfontsound_Destruct(ALfontsound *self); +ALenum ALfontsound_addGenerator(ALfontsound *self, ALenum generator, ALint value); +ALenum ALfontsound_addModulator(ALfontsound *self, ALenum sourceop, ALenum destop, ALint amount, ALenum amtsourceop, ALenum transop); inline struct ALfontsound *LookupFontsound(ALCdevice *device, ALuint id) |