Graf Zahl wrote:Chris wrote:The callback for the rolloff is pretty evil as well, since no other API that I know of does it that way.. OpenAL in particular has a per-source rolloff factor, but a global distance model/rolloff type, and only predefined types (linear, inverse distance, exponent, and none).
I'm afraid that this callback's functionality is necessary. It is essential for Doom's sound to work properly. Randy's first FmodEx version uses the stock rolloff calculations as well and it was horrible.
I suppose. I was able to make a work around that hopefully shouldn't impose too much on CPU time. OpenAL's distance attenuation is disabled, while SoundRenderer::UpdateSounds goes through the list of all allocated channels. For each one that has an in-use and non-local source, it gets the distance from the listener, calculates the attenuation, then sets it as the source gain.
For this, I'm thinking I might propose an OpenAL extension to provide essentially what S_SoundCurve is for (an array of mulipliers that's used to get attenuation between min dist and max dist). A callback would be more fitting, but those don't go over so well between different languages and language bindings, nor does it seem to be OpenAL's "style". I notice though, that each sound is given its own rolloff type (or at least, a type passed to each PlaySound3D call). Is it expected that different sounds can have different rolloff types, or is it just passed for no real reason? If the latter, I think it may be a better idea to pass the type once beforehand, and just the min dist and max dist/rolloff factor for PlaySound3D (to avoid this kind of confusion). If the former, then I think OpenAL will need another extension for that.
It seems most of the sound issues are taken care of for now, though. I don't notice any anamolies with it in Heretic, although Hexen still has a habit of losing sounds (particularly in the first level). Updated oalsound.cpp attached. Properly handling priorities and killing lowest-priority sounds may help, but I'll need to do some testing with it (I didn't have this issue with 2.2.0, so it doesn't strike me that I'm using all 12 channels at start, especially when I don't hear anything).
According to Randy this was so he 'doesn't need to jump through hoops.' I have been fighting against this sloppy organization for the last 2 weeks and I'm still not done separating the true interface code from improperly placed code. A few things I tried resulted in unexpected errors.
Unfortunately it's making me jump through hoops, and causing a bit of code duplication.
