Skip to content

ivas_binaural_reverb_open needs rework

Looking the long standing issue of the state of binaural reverb, I think it really needs to be addressed now. The current situation of the function ivas_binaural_reverb_open is not too good in various ways:

  • It has dependency on two different HRTF sets even though only one is ever needed at once
  • Output config is passed in for use very deep in the call tree and is actually "input config" for binaural rendering, i.e., the interim format for FastConv renderer
  • It is dependent on the renderer type although this has zero effect for reverb functionality itself, it is just used to set the reverb parameters
  • RoomAcoustics is only properly passed into it when coming from the FastConv path. This means that RoomAcoustics is never used on the ParamBin path. Also, if room acoustics is used, the parameters are always calculated with the FastConv HRTF set which would lead to possibly wrong output for ParamBin path.

What I think should be done is the following.

First, change the ivas_binaural_reverb_open interface as follows

Old

ivas_error ivas_binaural_reverb_open(
    REVERB_STRUCT_HANDLE *hReverbPr,                /* i/o: binaural reverb handle               */
    const int16_t numBins,                          /* i  : number of CLDFB bins                 */
    const int16_t numCldfbSlotsPerFrame,            /* i  : number of CLDFB slots per frame      */
    IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters            */
    const AUDIO_CONFIG output_config,               /* i  : output audio configuration           */
    const int32_t sampling_rate,                    /* i  : sampling rate                        */
    const RENDERER_TYPE renderer_type,              /* i  : renderer type                        */
    const HRTFS_FASTCONV_HANDLE hHrtfFastConv,      /* i  : FastConv HRTF handle                 */
    const HRTFS_PARAMBIN_HANDLE hHrtfParambin       /* i  : Parametric binauralizer HRTF handle  */
)

New

ivas_error ivas_binaural_reverb_open(
    REVERB_STRUCT_HANDLE *hReverbPr,                /* i/o: binaural reverb handle                                  */
    const int16_t numBins,                          /* i  : number of CLDFB bins                                    */
    const int16_t numCldfbSlotsPerFrame,            /* i  : number of CLDFB slots per frame                         */
    const int32_t sampling_rate,                    /* i  : sampling rate                                           */
    float revTimes[CLDFB_NO_CHANNELS_MAX],          /* i  : reverberation times T60 for each CLDFB bin in seconds   */
    float revEnes[CLDFB_NO_CHANNELS_MAX],           /* i  : spectrum for reverberated sound at each CLDFB bin       */
    const int16_t preDelay                          /* i  : reverb pre-delay in CLDFB slots                         */
)

This makes the reverb init completely independent from the renderer calling it. The function implementation will follow.

The next step is then to make the calling code work with the change and apply all necessary bits and pieces correctly. I would suggest creating a separate function for binaural reverb init based on the calling renderer. So ivas_binaural_reverb_init_fastconv and ivas_binaural_reverb_init_parambin. These would then take in corresponding HRTF set and room acoustics. All necessary tuning happens inside these functions.

All of this should be BE (except making room acoustics work for ParamBin) and will probably significantly improve code readability.