Commit f4e31a1e authored by Devansh Kandpal's avatar Devansh Kandpal
Browse files

Debugging code - for condensing ivas_reverb_set-energies()

parent 967dafc6
Loading
Loading
Loading
Loading
+44 −18
Original line number Diff line number Diff line
@@ -110,39 +110,47 @@ ivas_error ivas_reverb_prepare_cldfb_params(
 //       int a = 1; // for debugging
    }

    // TODO: Replace all these dedicated interpolate functions with just one taking a single input vector and map it to a single output vector. Period.

    ivas_reverb_interpolate_acoustic_data_fx( pInput_params->nBands, pInput_params->pFc_input_fx, pInput_params->pAcoustic_rt60_fx, pInput_params->pAcoustic_dsr_fx,
                                              CLDFB_NO_CHANNELS_MAX, output_fc_fx, output_t60_fx, output_ene_fx );
    // TODO: Replace all these dedicated interpolate functions with just one taking a single input vector and map it to a single output vector. The following function and the function call should be removed from code
    //ivas_reverb_interpolate_acoustic_data_fx( pInput_params->nBands, pInput_params->pFc_input_fx, pInput_params->pAcoustic_rt60_fx, pInput_params->pAcoustic_dsr_fx,
                                              //CLDFB_NO_CHANNELS_MAX, output_fc_fx, output_t60_fx, output_ene_fx );

    /* ---------- Debugging Block Starts-------------------*/
        //write to csv 
    FILE *filewriter = fopen("output.csv", "w");
    if (filewriter == NULL)
    {
        perror("Failed to open file");
//        return;
    }
    fprintf( filewriter, "T60(old function),DSR (old fucntion)\n" );

    FOR( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ )
    {
         fprintf( filewriter, "%f,%f\n", (float) output_t60_fx[idx] / ( 1 << 26 ), (float) output_ene_fx[idx] / ( 1 << 30 ) );
        //Print t60 and DSR
         //fprintf( filewriter, "%f,%f\n", (float) output_t60_fx[idx] / ( 1 << 26 ), (float) output_ene_fx[idx] / ( 1 << 30 ) );
    }
    
     fprintf( filewriter, "\n" );
     //fprintf( filewriter, "\n" );

    //Testing generalised interpolate function - write values to csv for comparison
    //T60
     /* --------- Debugging Block Ends--------------------*/

    //T60 - Q26
    ivas_reverb_interp_on_freq_grid_fx( pInput_params->nBands, pInput_params->pFc_input_fx, pInput_params->pAcoustic_rt60_fx, CLDFB_NO_CHANNELS_MAX, output_fc_fx, output_t60_fx );
    //DSR
    //DSR - Q30
    ivas_reverb_interp_on_freq_grid_fx( pInput_params->nBands, pInput_params->pFc_input_fx, pInput_params->pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX, output_fc_fx, output_ene_fx );

        /* ---------- Debugging Block Starts-------------------*/
    // write to csv 
    FOR( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ )
    {
        fprintf( filewriter, "%f,%f\n", (float) output_t60_fx[idx] / ( 1 << 26 ), (float) output_ene_fx[idx] / ( 1 << 30 ) );
        // Print T60 and DSR
        // fprintf( filewriter, "%f,%f\n", (float) output_t60_fx[idx] / ( 1 << 26 ), (float) output_ene_fx[idx] / ( 1 << 30 ) );
        // Print input and output center frequency
        fprintf( filewriter, "%f,%f\n", (float) pInput_params->pFc_input_fx[idx] / ( 1 << 16 ), (float) output_fc_fx[idx] / ( 1 << 16 ) );
    }

    //output_t60_fx: Q26, output_ene_fx: Q30
    fprintf( filewriter, "\n" );
    //Close file
    fclose( filewriter );
    /* --------- Debugging Block Ends--------------------*/

    /* adjust DSR for the delay difference */
    delay_diff_fx = L_sub( pInput_params->inputPreDelay_fx, pInput_params->acousticPreDelay_fx ); //Q27
@@ -172,7 +180,7 @@ ivas_error ivas_reverb_prepare_cldfb_params(
        L_tmp = Mpy_32_32( L_tmp, output_ene_fx[idx] ); //Q27 if result of previous step is in Q28
        L_tmp = L_shl_sat( L_tmp, add( 1, pow_exp ) );//L_tmp in Q31

        //Assign energyt o putput -pointer
        //Assign energy to output pointer
        pOutput_ene[idx] = L_tmp;
        move32();

@@ -181,7 +189,7 @@ ivas_error ivas_reverb_prepare_cldfb_params(

    }

    //This function can be condensed 
    //This function can be condensed and merged within prepare_cldfb_params(). It is only called once, at this location. 
    ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left_fx, avg_pwr_right_fx ); //This function returns avg powers for left and right in Q28 -> why?? how??

    for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ )
@@ -241,6 +249,24 @@ static void ivas_reverb_set_energies(
    }
#endif

            /* ---------- Debugging Block Starts-------------------*/
    FILE *filewriter = fopen( "output2.csv", "w" );
    if ( filewriter == NULL )
    {
        perror( "Failed to open file" );
    }
    // write to csv
    FOR( freq_idx = 0; freq_idx < CLDFB_NO_CHANNELS_MAX; freq_idx++ )
    {
        // Print T60 and DSR
        // fprintf( filewriter, "%f,%f\n", (float) output_t60_fx[idx] / ( 1 << 26 ), (float) output_ene_fx[idx] / ( 1 << 30 ) );
        // Print input and output center frequency
        fprintf( filewriter, "%f,%f\n", (float) input_fc_fx[freq_idx] / ( 1 << 16 ), (float) output_fc_fx[freq_idx] / ( 1 << 16 ) );
    }
    // Close file
     fclose( filewriter );
    /* --------- Debugging Block Ends--------------------*/

#ifndef FIX_1741_REVERB_TIMES_Q_FORMAT

    Word32 *input_fc_fx = (Word32 *) malloc( 60 * sizeof( Word32 ) );
@@ -265,8 +291,8 @@ static void ivas_reverb_set_energies(
#endif

#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
    ivas_reverb_interpolate_energies_fx( avg_pwr_len, input_fc_fx, avg_pwr_l, avg_pwr_r,
                                         CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx ); //Retains Q-Format
    //ivas_reverb_interpolate_energies_fx( avg_pwr_len, input_fc_fx, avg_pwr_l, avg_pwr_r,
      //                                   CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx ); //Retains Q-Format
    //Avg Energy Left
    ivas_reverb_interp_on_freq_grid_fx( avg_pwr_len, input_fc_fx, avg_pwr_l, CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx );
    //Avg Energy Right