Commit b701392c authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

[wip] groundwork for issue 296

parent 5f8f40fe
Loading
Loading
Loading
Loading
Loading
+87 −0
Original line number Diff line number Diff line
@@ -1624,8 +1624,13 @@ static CmdlnArgs defaultArgs(

    args.lfePanningEnabled = false;
    args.lfeConfigGain = 1.0f;
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    args.lfeConfigAzimuth = 0.f;
    args.lfeConfigElevation = 0.f;
#else
    args.lfeConfigAzimuth = 0;
    args.lfeConfigElevation = 0;
#endif

    args.lfeCustomRoutingEnabled = false;
    clearString( args.inLfePanningMatrixFile );
@@ -2090,6 +2095,12 @@ static int8_t parseInt32(

static void parseOptionalInputValues(
    char *line,
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    float *lfe_gain_dB,
    float *lfe_pos_azi,
    float *lfe_pos_ele,
    char *lfe_pan_mtx_filename,
#endif
    float *gain_dB )
{
    char *parse_pos;
@@ -2101,6 +2112,24 @@ static void parseOptionalInputValues(

    /* Set default values, in case some values are not specified */
    *gain_dB = 0.f;
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    if ( lfe_gain_dB != NULL )
    {
        *lfe_gain_dB = 0.f;
    }
    if ( lfe_pos_azi != NULL )
    {
        *lfe_pos_azi = 0.f;
    }
    if ( lfe_pos_ele != NULL )
    {
        *lfe_pos_ele = 0.f;
    }
    if ( lfe_pan_mtx_filename != NULL )
    {
        *lfe_pan_mtx_filename = '\0';
    }
#endif

    /* Save parsing position - will have to be passed to strtok to resume parsing after using strtok with non-NULL value below */
    parse_pos = readNextMetadataChunk( line, "\n" );
@@ -2117,10 +2146,50 @@ static void parseOptionalInputValues(

            if ( *endptr != '\0' )
            {
#ifdef FIX_296_CFG_LFE_SCENE_DESC
                fprintf( stderr, "Cannot parse string \"%s\" as a float value\n", value );
#else
                fprintf( stderr, "Cannot parse string string \"%s\" as a float value\n", value );
#endif
                exit( -1 );
            }
        }
#ifdef FIX_296_CFG_LFE_SCENE_DESC
        else if ( ( strcmp( key, "lfe_gain_dB" ) == 0 ) && lfe_gain_dB != NULL )
        {
            *lfe_gain_dB = (float) strtod( value, &endptr );

            if ( *endptr != '\0' )
            {
                fprintf( stderr, "Cannot parse string \"%s\" as a float value\n", value );
                exit( -1 );
            }
        }
        else if ( ( strcmp( key, "lfe_azi" ) == 0 ) && lfe_pos_azi != NULL )
        {
            *lfe_pos_azi = (float) strtod( value, &endptr );

            if ( *endptr != '\0' )
            {
                fprintf( stderr, "Cannot parse string \"%s\" as a float value\n", value );
                exit( -1 );
            }
        }
        else if ( ( strcmp( key, "lfe_ele" ) == 0 ) && lfe_pos_ele != NULL )
        {
            *lfe_pos_ele = (float) strtod( value, &endptr );

            if ( *endptr != '\0' )
            {
                fprintf( stderr, "Cannot parse string \"%s\" as a float value\n", value );
                exit( -1 );
            }
        }
        else if ( strcmp( key, "lfe_matrix" ) == 0 )
        {
            strncpy( lfe_pan_mtx_filename, value, FILENAME_MAX - 1 );
        }
#endif
        else
        {
            fprintf( stderr, "Unsupported optional key: %s\n", key );
@@ -2204,7 +2273,11 @@ static void parseIsm(
    }

    /* Read optional values */
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    parseOptionalInputValues( line, NULL, NULL, NULL, NULL, &inConfig->audioObjects[idx].gain_dB );
#else
    parseOptionalInputValues( line, &inConfig->audioObjects[idx].gain_dB );
#endif

    return;
}
@@ -2225,7 +2298,11 @@ static void parseSba(
    inConfig->ambisonicsBuses[idx].audioConfig = ambisonicsOrderToEnum( ambiOrder );

    /* Read optional values */
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    parseOptionalInputValues( line, NULL, NULL, NULL, NULL, &inConfig->ambisonicsBuses[idx].gain_dB );
#else
    parseOptionalInputValues( line, &inConfig->ambisonicsBuses[idx].gain_dB );
#endif

    return;
}
@@ -2251,7 +2328,13 @@ static void parseMc(
    }

    /* Read optional values */
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    float lg, la, le;
    char tmpfile[FILENAME_MAX];
    parseOptionalInputValues( line, &lg, &la, &le, tmpfile, &inConfig->multiChannelBuses[idx].gain_dB );
#else
    parseOptionalInputValues( line, &inConfig->multiChannelBuses[idx].gain_dB );
#endif

    return;
}
@@ -2292,7 +2375,11 @@ static void parseMasa(
    }

    /* Read optional values */
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    parseOptionalInputValues( line, NULL, NULL, NULL, NULL, &inConfig->masaBuses[idx].gain_dB );
#else
    parseOptionalInputValues( line, &inConfig->masaBuses[idx].gain_dB );
#endif

    return;
}
+2 −0
Original line number Diff line number Diff line
@@ -213,6 +213,8 @@
//#define HODIRAC_READ_PARAMS
#endif

#define FIX_296_CFG_LFE_SCENE_DESC                       /* FhG: Fix issue 296 - add configurable LFE handling to the scene description file */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */