Commit 1f5ccf62 authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

[fix] minor improvements and add a warning when both LFE position and matrix...

[fix] minor improvements and add a warning when both LFE position and matrix are configured as on CLI
parent e20b56d3
Loading
Loading
Loading
Loading
Loading
+34 −16
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ typedef struct
    float lfe_azi;
    float lfe_ele;
    float lfe_gain_dB;
    char lfe_pan_mtx[FILENAME_MAX];
    char lfe_routing_mtx[FILENAME_MAX];
} LfeRoutingConfig;
#endif
typedef struct
@@ -828,7 +828,11 @@ int main(
        {
            if ( args.lfePanningEnabled )
            {
#ifdef FIX_296_CFG_LFE_SCENE_DESC
                fprintf( stderr, "Warning: LFE position specified as well as panning matrix! Ignoring position and using gains from panning matrix\n" );
#else
                fprintf( stdout, "Warning LFE position specified as well as panning matrix! Ignoring position and using gains from panning matrix\n" );
#endif
                args.lfePanningEnabled = false;
            }

@@ -854,9 +858,9 @@ int main(
            if ( lfeRoutingConfigs[i] != NULL )
            {
                /* prioritise panning matrix if configured */
                if ( lfeRoutingConfigs[i]->lfe_pan_mtx[0] != '\0' )
                if ( !isEmptyString( lfeRoutingConfigs[i]->lfe_routing_mtx ) )
                {
                    if ( ( error = parseLfePanMtxFile( lfeRoutingConfigs[i]->lfe_pan_mtx, &lfePanMatrix ) ) != IVAS_ERR_OK )
                    if ( ( error = parseLfePanMtxFile( lfeRoutingConfigs[i]->lfe_routing_mtx, &lfePanMatrix ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
                        exit( -1 );
@@ -1953,10 +1957,10 @@ LfeRoutingConfig *LfeRoutingConfig_open(
    LfeRoutingConfig *lrc;

    lrc = (LfeRoutingConfig *) malloc( sizeof( LfeRoutingConfig ) );
    lrc->lfe_azi = 0;
    lrc->lfe_ele = 0;
    lrc->lfe_gain_dB = 0;
    lrc->lfe_pan_mtx[0] = '\0';
    lrc->lfe_azi = 0.f;
    lrc->lfe_ele = 0.f;
    lrc->lfe_gain_dB = 0.f;
    lrc->lfe_routing_mtx[0] = '\0';

    return lrc;
}
@@ -2520,23 +2524,37 @@ static void parseMc(

    /* Read optional values */
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    bool lfe_panningEnabled;
    float lfe_gain_dB, lfe_azi, lfe_ele;
    char lfe_pan_mtx[FILENAME_MAX];
    char lfe_routing_mtx[FILENAME_MAX];

    parseOptionalInputValues( line, &lfe_gain_dB, &lfe_azi, &lfe_ele, lfe_pan_mtx, &inConfig->multiChannelBuses[idx].gain_dB );
    parseOptionalInputValues( line, &lfe_gain_dB, &lfe_azi, &lfe_ele, lfe_routing_mtx, &inConfig->multiChannelBuses[idx].gain_dB );

    if ( ( lfe_gain_dB != 0.f || lfe_azi != 0.f || lfe_ele != 0.f ) ||
         ( lfe_pan_mtx[0] != '\0' ) )
    lfe_panningEnabled = ( lfe_gain_dB != 0.f || lfe_azi != 0.f || lfe_ele != 0.f ) ? true : false;

    if ( lfe_panningEnabled && !isEmptyString( lfe_routing_mtx ) )
    {
        fprintf( stderr, "Warning: LFE position specified as well as panning matrix! Ignoring position and using gains from panning matrix\n" );
        lfe_panningEnabled = false;
    }

    if ( lfe_panningEnabled || !isEmptyString( lfe_routing_mtx ) )
    {
        /* a configuration was specified, set the values */
        lfeRoutingConfigs[idx] = LfeRoutingConfig_open();

        if ( lfe_panningEnabled )
        {
            lfeRoutingConfigs[idx]->lfe_gain_dB = lfe_gain_dB;
            lfeRoutingConfigs[idx]->lfe_azi = lfe_azi;
            lfeRoutingConfigs[idx]->lfe_ele = lfe_ele;
        }

        strncpy( lfeRoutingConfigs[idx]->lfe_pan_mtx, lfe_pan_mtx, FILENAME_MAX );
        convert_backslash( lfeRoutingConfigs[idx]->lfe_pan_mtx );
        if ( !isEmptyString( lfe_routing_mtx ) )
        {
            strncpy( lfeRoutingConfigs[idx]->lfe_routing_mtx, lfe_routing_mtx, FILENAME_MAX );
            convert_backslash( lfeRoutingConfigs[idx]->lfe_routing_mtx );
        }
    }
#else
    parseOptionalInputValues( line, &inConfig->multiChannelBuses[idx].gain_dB );