Commit 9820ecc3 authored by Marek Szczerba's avatar Marek Szczerba
Browse files

Prototype implementation for computing power spectra and interaural coherence...

Prototype implementation for computing power spectra and interaural coherence for reverb filters using complete HRTF data set
parent 2c374d03
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@
#define FIX_575_LOW_OVERLAP_PLC_RECOVERY                /* FhG: Issue 575 fix for PLC and transistion to TCX5*/
#define ISM_FB_16k4                                     /* VA: Issue: 579: change BW from SWB to FB in NxISM conditions to match the EVS codec */
#define FIX_580_PARAMMC_ENER_BURSTS                     /* FhG: issue 580: energy bursts due to ILD holding when energy relations change too much */

#define HRTF_FOR_REVERB_FILTERS                         /* Philips: Related to issue 571 - HRTF points used to compute reverb filters */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+4 −0
Original line number Diff line number Diff line
@@ -1054,7 +1054,11 @@ ivas_error ivas_rend_openCrend(

        if ( outConfig == AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
        {
#ifdef HRTF_FOR_REVERB_FILTERS
            if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), inConfig, hSetOfHRTF, hRendCfg, output_Fs ) ) != IVAS_ERR_OK )
#else
            if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), inConfig, ( *pCrend )->hHrtfCrend, hRendCfg, output_Fs ) ) != IVAS_ERR_OK )
#endif
            {
                return error;
            }
+4 −0
Original line number Diff line number Diff line
@@ -565,7 +565,11 @@ void ivas_binaural_reverb_processSubframe(
ivas_error ivas_reverb_open( 
    REVERB_HANDLE *hReverb,                                     /* i/o: Reverberator handle                     */
    const AUDIO_CONFIG input_audio_config,                      /* i  : reverb. input audio configuration       */
#ifdef HRTF_FOR_REVERB_FILTERS
    const HRTFS_CREND_HANDLE hHrtf,                             /* i  : HRTF handle                             */
#else
    const HRTFS_HANDLE hHrtf,                                   /* i  : HRTF handle                             */
#endif
    RENDER_CONFIG_DATA *pConfig,                                /* i  : Reverb configuration                    */
    const int32_t output_Fs                                     /* i  : output sampling rate                    */
);
+81 −0
Original line number Diff line number Diff line
@@ -41,6 +41,9 @@
#include "math.h"
#include "ivas_rom_rend.h"
#include <assert.h>
#ifdef HRTF_FOR_REVERB_FILTERS
#include "ivas_rom_binaural_crend_head.h"
#endif
#include "wmc_auto.h"


@@ -944,22 +947,84 @@ static void set_fft_and_datablock_sizes(
 * Sets reverb acoustic data (room acoustics and HRTF), interpolating it to the filter grid
 *-----------------------------------------------------------------------------------------*/

#ifdef HRTF_FOR_REVERB_FILTERS
static ivas_error set_reverb_acoustic_data(
#else
static void set_reverb_acoustic_data(
#endif
    ivas_reverb_params_t *pParams,
    const AUDIO_CONFIG input_audio_config,
#ifdef HRTF_FOR_REVERB_FILTERS
    const HRTFS_CREND_HANDLE hHrtf,
    const int32_t output_fs,
#else
    const HRTFS_HANDLE hHrtf,
#endif
    ivas_roomAcoustics_t *pRoomAcoustics,
    const int16_t subframe_len,
    const int16_t nr_fc_input,
    const int16_t nr_fc_fft_filter )
{
#ifdef HRTF_FOR_REVERB_FILTERS
    int16_t hrtf_idx, bin_idx;
#else
    int16_t nr_out_ch, hrtf_idx, offset, iter_idx, bin_idx;
#endif
    float ln_1e6_inverted, delay_diff, exp_argument;
    float *pHrtf_set_l_re[MAX_INTERN_CHANNELS];
    float *pHrtf_set_l_im[MAX_INTERN_CHANNELS];
    float *pHrtf_set_r_re[MAX_INTERN_CHANNELS];
    float *pHrtf_set_r_im[MAX_INTERN_CHANNELS];

#ifdef HRTF_FOR_REVERB_FILTERS
    for ( hrtf_idx = 0; hrtf_idx < HRTF_LS_CHANNELS; hrtf_idx++ )
    {
        if ( hHrtf != NULL )
        {
            pHrtf_set_l_re[hrtf_idx] = hHrtf->hHRTF_hrir_combined->pOut_to_bin_re[hrtf_idx][0];
            pHrtf_set_l_im[hrtf_idx] = hHrtf->hHRTF_hrir_combined->pOut_to_bin_im[hrtf_idx][0];
            pHrtf_set_r_re[hrtf_idx] = hHrtf->hHRTF_hrir_combined->pOut_to_bin_re[hrtf_idx][1];
            pHrtf_set_r_im[hrtf_idx] = hHrtf->hHRTF_hrir_combined->pOut_to_bin_im[hrtf_idx][1];
        }
        else
        {
            if ( output_fs == 48000 )
            {
                pHrtf_set_l_re[hrtf_idx] = CRendBin_Combined_HRIR_coeff_re_48kHz[hrtf_idx][0];
                pHrtf_set_l_im[hrtf_idx] = CRendBin_Combined_HRIR_coeff_im_48kHz[hrtf_idx][0];
                pHrtf_set_r_re[hrtf_idx] = CRendBin_Combined_HRIR_coeff_re_48kHz[hrtf_idx][1];
                pHrtf_set_r_im[hrtf_idx] = CRendBin_Combined_HRIR_coeff_im_48kHz[hrtf_idx][1];
            }
            else if ( output_fs == 32000 )
            {
                pHrtf_set_l_re[hrtf_idx] = CRendBin_Combined_HRIR_coeff_re_32kHz[hrtf_idx][0];
                pHrtf_set_l_im[hrtf_idx] = CRendBin_Combined_HRIR_coeff_im_32kHz[hrtf_idx][0];
                pHrtf_set_r_re[hrtf_idx] = CRendBin_Combined_HRIR_coeff_re_32kHz[hrtf_idx][1];
                pHrtf_set_r_im[hrtf_idx] = CRendBin_Combined_HRIR_coeff_im_32kHz[hrtf_idx][1];
            }
            else if ( output_fs == 16000 )
            {
                pHrtf_set_l_re[hrtf_idx] = CRendBin_Combined_HRIR_coeff_re_16kHz[hrtf_idx][0];
                pHrtf_set_l_im[hrtf_idx] = CRendBin_Combined_HRIR_coeff_im_16kHz[hrtf_idx][0];
                pHrtf_set_r_re[hrtf_idx] = CRendBin_Combined_HRIR_coeff_re_16kHz[hrtf_idx][1];
                pHrtf_set_r_im[hrtf_idx] = CRendBin_Combined_HRIR_coeff_im_16kHz[hrtf_idx][1];
            }
            else
            {
                return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" );
            }
        }
    }

    /* Compute HRTF set properties using frequency-domain HRTF data */
    ivas_reverb_get_hrtf_set_properties( pHrtf_set_l_re, pHrtf_set_l_im, pHrtf_set_r_re, pHrtf_set_r_im, input_audio_config, HRTF_LS_CHANNELS, subframe_len,
                                         nr_fc_fft_filter, pParams->pHrtf_avg_pwr_response_l, pParams->pHrtf_avg_pwr_response_r, pParams->pHrtf_inter_aural_coherence );

    pParams->pHrtf_avg_pwr_response_l_const = (const float *) pParams->pHrtf_avg_pwr_response_l;
    pParams->pHrtf_avg_pwr_response_r_const = (const float *) pParams->pHrtf_avg_pwr_response_r;
    pParams->pHrtf_inter_aural_coherence_const = (const float *) pParams->pHrtf_inter_aural_coherence;

#else
    /* use crend hrtf filters */
    if ( hHrtf != NULL )
    {
@@ -1002,6 +1067,7 @@ static void set_reverb_acoustic_data(
        pParams->pHrtf_avg_pwr_response_r_const = orange53_right_avg_power;
        pParams->pHrtf_inter_aural_coherence_const = orange53_coherence;
    }
#endif

    /* interpolate input table data for T60 and DSR to the FFT filter grid */
    ivas_reverb_interpolate_acoustic_data( nr_fc_input, pRoomAcoustics->pFc_input, pRoomAcoustics->pAcoustic_rt60, pRoomAcoustics->pAcoustic_dsr,
@@ -1019,7 +1085,11 @@ static void set_reverb_acoustic_data(
        pParams->pDsr[bin_idx] *= expf( exp_argument );
    }

#ifdef HRTF_FOR_REVERB_FILTERS
    return IVAS_ERR_OK;
#else
    return;
#endif
}


@@ -1098,7 +1168,11 @@ static ivas_error setup_FDN_branches(
ivas_error ivas_reverb_open(
    REVERB_HANDLE *hReverb,                /* i/o: Reverberator handle               */
    const AUDIO_CONFIG input_audio_config, /* i  : reverb. input audio configuration */
#ifdef HRTF_FOR_REVERB_FILTERS
    const HRTFS_CREND_HANDLE hHrtf,        /* i  : HRTF handle                       */
#else
    const HRTFS_HANDLE hHrtf,              /* i  : HRTF handle                       */
#endif
    RENDER_CONFIG_HANDLE hRenderConfig,    /* i  : Renderer configuration handle     */
    const int32_t output_Fs                /* i  : output sampling rate              */
)
@@ -1173,7 +1247,14 @@ ivas_error ivas_reverb_open(
    }

    /* set up reverb acoustic data on the basis of HRTF data and renderer config  */
#ifdef HRTF_FOR_REVERB_FILTERS
    if ( ( error = set_reverb_acoustic_data( &params, input_audio_config, hHrtf, output_Fs, &hRenderConfig->roomAcoustics, subframe_len, nr_fc_input, nr_fc_fft_filter ) ) != IVAS_ERR_OK )
    {
        return error;
    }
#else
    set_reverb_acoustic_data( &params, input_audio_config, hHrtf, &hRenderConfig->roomAcoustics, subframe_len, nr_fc_input, nr_fc_fft_filter );
#endif

    /* set reverb acoustic configuration based on renderer config  */
#ifdef DEBUGGING