[Openal-devel] Extension proposal updated

Chris Robinson chris.kcat at gmail.com
Tue Nov 25 17:17:11 PST 2008


On Friday 19 September 2008 08:11:45 am Daniel PEACOCK wrote:
> I don't really like the fact that each Attenuation Table needs a new enum
> value, or that there should be any limit on the number you can create,
> apart from memory.
>
> So how about ...
>
> We treat an Attenuation Table as an object ...
>
> alGenAttenuationTables(ALsizei n, ALuint *tables);
> alDeleteAttenuationTables(ALsizei n, ALuint *tables);
> alIsAttenuationTable(ALuint table);
>

Thinking a bit more, I may have an idea how to make it work like this. You'd 
basically have a generic 'table' object:

alGenTables(ALsizei n, ALuint *tables);
alDeleteTables(ALsizei n, ALuint *tables);
alIsTable(ALuint table);
... (all regular object set/get funcs) ...
// to fill the table:
alTableDataf(ALuint table, ALsizei len, ALfloat *entries);

To use it.. instead of overriding the distance model, it would work off of it. 
It would be attached to a source:
alSourcei(sID, AL_ATTENUATION_TABLE, tID);

and the source's calculated attenuation level (before clamping to min/max 
gain) would be used as a lookup index:
switch(ALContext->DistanceModel)
{
case AL_LINEAR_DISTANCE:
    ...
    flAttenuation = 1.0f - (Rolloff*(Distance-MinDist)/(MaxDist - MinDist));
    ...
}
if(ALSource->Table)
{
    ALsizei idx = (1.0f-flAttenuation) * (ALSource->Table->Size-1);
    idx = min(idx, ALSource->Table->Size-1);
    idx = max(idx, 0);
    flAttenuation = ALSource->Table->Data[idx];
}

// Source Gain + Attenuation and clamp to Min/Max Gain
...

This would allow an implementation to work with as many tables as it can 
allocate, avoid all the enums for a bunch of tables, have a more 
generic 'table' object that can be used for more than just attenuation, and 
work fine with AL_EXT_source_distance_model.


More information about the Openal-devel mailing list