Commit b4f9aefa authored by kinuthia's avatar kinuthia
Browse files

specify directivity per object

- also add optional commandline arg `-ismDirectivity` to select directivity
  patterns.
parent b3e783ed
Loading
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -159,6 +159,9 @@ typedef struct

#ifdef CONTROL_METADATA_REVERB
    uint16_t acousticEnvironmentId;
#ifdef CONTROL_METADATA_DIRECTIVITY
    uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS];
#endif
#endif

} DecArguments;
@@ -619,6 +622,13 @@ int main(
            fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename );
            goto cleanup;
        }
#ifdef CONTROL_METADATA_DIRECTIVITY
        if ( ( error = RenderConfigReader_getDirectivity( renderConfigReader, arg.directivityPatternId, renderConfig.directivity ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Failed to get directivity for objects: %d %d %d %d\n\n", arg.directivityPatternId[0], arg.directivityPatternId[1], arg.directivityPatternId[2], arg.directivityPatternId[3] );
            goto cleanup;
        }
#endif

#ifdef CONTROL_METADATA_REVERB
        if ( arg.outputFormat == IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB )
@@ -996,6 +1006,12 @@ static bool parseCmdlIVAS_dec(

#ifdef CONTROL_METADATA_REVERB
    arg->acousticEnvironmentId = 0;
#ifdef CONTROL_METADATA_DIRECTIVITY
    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i )
    {
        arg->directivityPatternId[i] = 0;
    }
#endif
#endif

    /*-----------------------------------------------------------------*
@@ -1364,6 +1380,20 @@ static bool parseCmdlIVAS_dec(
            ++i;
            arg->acousticEnvironmentId = (int16_t) atoi( argv[i++] );
        }
#ifdef CONTROL_METADATA_DIRECTIVITY
        else if ( strcmp( argv_to_upper, "-ISMDIRECTIVITY" ) == 0 )
        {
            ++i;
            int16_t tmp;
            tmp = 0;
            while ( is_number( argv[i + tmp] ) && tmp < IVAS_MAX_NUM_OBJECTS )
            {
                arg->directivityPatternId[tmp] = (int16_t) atoi( argv[i + tmp] );
                ++tmp;
            }
            i += tmp;
        }
#endif
#endif
        /*-----------------------------------------------------------------*
         * Option not recognized
+4 −0
Original line number Diff line number Diff line
@@ -205,7 +205,11 @@ typedef struct _IVAS_RENDER_CONFIG
#ifdef SPLIT_REND_WITH_HEAD_ROT
    IVAS_SPLIT_REND_CONFIG_DATA split_rend_config;
#endif
#ifdef CONTROL_METADATA_DIRECTIVITY
    float directivity[IVAS_MAX_NUM_OBJECTS][3];
#else
    float directivity[3];
#endif
} IVAS_RENDER_CONFIG_DATA, *IVAS_RENDER_CONFIG_HANDLE;

typedef struct _IVAS_LS_CUSTOM_LAYOUT
+21 −0
Original line number Diff line number Diff line
@@ -1474,6 +1474,9 @@ ivas_error IVAS_DEC_GetRenderConfig(
)
{
    RENDER_CONFIG_HANDLE hRCin;
#ifdef CONTROL_METADATA_DIRECTIVITY
    int16_t i;
#endif

    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL || hRCout == NULL )
    {
@@ -1503,7 +1506,14 @@ ivas_error IVAS_DEC_GetRenderConfig(
    mvr2r( hRCin->roomAcoustics.pFc_input, hRCout->room_acoustics.pFc_input, CLDFB_NO_CHANNELS_MAX );
    mvr2r( hRCin->roomAcoustics.pAcoustic_rt60, hRCout->room_acoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX );
    mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->room_acoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX );
#ifdef CONTROL_METADATA_DIRECTIVITY
    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ )
    {
        mvr2r( hRCin->directivity[i], hRCout->directivity[i], 3 );
    }
#else
    mvr2r( hRCin->directivity, hRCout->directivity, 3 );
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
    hRCout->split_rend_config.splitRendBitRate = SPLIT_REND_768k;
@@ -1533,6 +1543,9 @@ ivas_error IVAS_DEC_FeedRenderConfig(
#ifdef SPLIT_REND_WITH_HEAD_ROT
    ivas_error error;
#endif
#ifdef CONTROL_METADATA_DIRECTIVITY
    int16_t i;
#endif

    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL )
    {
@@ -1558,7 +1571,15 @@ ivas_error IVAS_DEC_FeedRenderConfig(
    mvr2r( renderConfig.room_acoustics.pFc_input, hRenderConfig->roomAcoustics.pFc_input, CLDFB_NO_CHANNELS_MAX );
    mvr2r( renderConfig.room_acoustics.pAcoustic_rt60, hRenderConfig->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX );
    mvr2r( renderConfig.room_acoustics.pAcoustic_dsr, hRenderConfig->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX );
    
#ifdef CONTROL_METADATA_DIRECTIVITY
    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ )
    {
        mvr2r( renderConfig.directivity[i], hRenderConfig->directivity[i], 3 );
    }
#else
    mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 );
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
    hRenderConfig->split_rend_config = renderConfig.split_rend_config;
+30 −6
Original line number Diff line number Diff line
@@ -68,7 +68,11 @@ ivas_error ivas_td_binaural_open_unwrap(
    const int16_t nchan_transport,       /* i  : Number of channels                  */
    const IVAS_FORMAT ivas_format,       /* i  : IVAS format (ISM/MC)                */
    const AUDIO_CONFIG transport_config, /* i  : Transport configuration             */
#ifdef CONTROL_METADATA_DIRECTIVITY
    const float directivity[MAX_NUM_OBJECTS][3], /* i  : Directivity pattern (used for ISM)  */
#else
    const float *directivity, /* i  : Directivity pattern (used for ISM)  */
#endif
    const IVAS_OUTPUT_SETUP hTransSetup,                /* i  : Loudspeaker layout                  */
    BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd, /* o  : TD renderer handle                  */
    int32_t *binaural_latency_ns                        /* i  : Binauralization delay               */
@@ -196,6 +200,7 @@ ivas_error ivas_td_binaural_open_unwrap(
    if ( ivas_format == ISM_FORMAT )
    {
        DirAtten_p = pBinRendTd->DirAtten_p;
#ifndef CONTROL_METADATA_DIRECTIVITY
        if ( NULL == directivity )
        {
            DirAtten_p->ConeInnerAngle = 360.0f; /* Front cone */
@@ -208,9 +213,24 @@ ivas_error ivas_td_binaural_open_unwrap(
            DirAtten_p->ConeOuterAngle = directivity[1];
            DirAtten_p->ConeOuterGain = directivity[2];
        }
#endif

        for ( nS = 0; nS < nchan_rend; nS++ )
        {
#ifdef CONTROL_METADATA_DIRECTIVITY
            if ( NULL == directivity )
            {
                DirAtten_p->ConeInnerAngle = 360.0f; /* Front cone */
                DirAtten_p->ConeOuterAngle = 360.0f; /* Back cone */
                DirAtten_p->ConeOuterGain = 1.0f;    /* Back attenuation */
            }
            else
            {
                DirAtten_p->ConeInnerAngle = directivity[nS][0];
                DirAtten_p->ConeOuterAngle = directivity[nS][1];
                DirAtten_p->ConeOuterGain = directivity[nS][2];
            }
#endif
            TDREND_MIX_SRC_SetDirAtten( pBinRendTd, nS, DirAtten_p );
        }
    }
@@ -625,7 +645,11 @@ ivas_error ivas_td_binaural_open_ext(
    IVAS_FORMAT ivas_format;
    IVAS_OUTPUT_SETUP hTransSetup;
    ivas_error error;
#ifdef CONTROL_METADATA_DIRECTIVITY
    float (*directivity)[3] = NULL;
#else
    float *directivity = NULL;
#endif

    if ( inConfig != IVAS_REND_AUDIO_CONFIG_LS_CUSTOM )
    {
+4 −0
Original line number Diff line number Diff line
@@ -271,7 +271,11 @@ ivas_error ivas_td_binaural_open_unwrap(
    const int16_t nchan_transport,                              /* i  : Number of channels                      */
    const IVAS_FORMAT ivas_format,                              /* i  : IVAS format (ISM/MC)                    */
    const AUDIO_CONFIG transport_config,                        /* i  : Transport configuration                 */
#ifdef CONTROL_METADATA_DIRECTIVITY
    const float directivity[MAX_NUM_OBJECTS][3], /* i  : Directivity pattern (used for ISM)  */
#else
    const float *directivity,                                   /* i  : Directivity pattern (used for ISM)      */
#endif
    const IVAS_OUTPUT_SETUP hTransSetup,                        /* i  : Loudspeaker layout                      */
    BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd,         /* o  : TD renderer handle                      */
    int32_t *binaural_latency_ns                                /* i  : Binauralization delay                   */
Loading