#pragma once //########################################################################### // // L4AUDEFX.h -- OpenAL EFX bridge for the authored filter/reverb chains // (task #50, AUDIO_FIDELITY F9/F11). // // The original drove the AWE32 initial-filter-cutoff NRPN per frame // (brightness x distance HF rolloff) and sent CC91 reverb on the 3D // channels (global_reverb_scale=0.3, AUDIO.INI) while keeping the cockpit // Direct channels dry. This bridge reproduces both through OpenAL Soft's // EFX extension: one EAXReverb aux slot + a scratch AL_FILTER_LOWPASS // whose parameters are copied at attach time. // //########################################################################### #include "openal/al.h" // Load the EFX entry points, create the reverb slot (gain = the authentic // global_reverb_scale) and the scratch lowpass. Call once, with the AL // context current. Returns false (and stays inert) without ALC_EXT_EFX. bool EFX_Initialize(float global_reverb_scale); bool EFX_Available(); // Per-frame direct-path lowpass: gainhf is the linear HF gain at the EFX // 5 kHz reference. Callers map the AWE cutoff (100 + scale*7900/127 Hz) // through EFX_CutoffScaleToGainHF below. void EFX_SetSourceLowpassGainHF(ALuint source, float gainhf); // AWE NRPN 21 curve -> EFX gainhf: cutoff_scale in [0,1] of the 100-8000 Hz // span; approximated as the attenuation of a 2-pole lowpass at the 5 kHz // reference [T3 -- curve shape approximate, endpoints exact]. inline float EFX_CutoffScaleToGainHF(float cutoff_scale) { if (cutoff_scale < 0.0f) cutoff_scale = 0.0f; if (cutoff_scale > 1.0f) cutoff_scale = 1.0f; float cutoff_hz = 100.0f + cutoff_scale * 7900.0f; float g = (cutoff_hz / 5000.0f) * (cutoff_hz / 5000.0f); return (g > 1.0f) ? 1.0f : ((g < 0.001f) ? 0.001f : g); } // Wet-exterior routing: attach the source's aux send to the reverb slot // (Dynamic3D/Static3D). Direct cockpit sources stay dry by default. void EFX_AttachReverbSend(ALuint source);