L_tmp=Mpy_32_32(output_t60_fx[idx],ln_1e6_inverted_fx);// L_tmp in Q26 // exp = pRt60_e[bin_idx] + 0
//exp_argument_e = add( exp_argument_e, sub( 4, pRt60_e[idx] ) ); // Q27 -> e4 -> This step must be adjusted accordingly as per the above two steps
exp_argument_fx=BASOP_Util_Divide3232_Scale_newton(delay_diff_fx,L_tmp,&tmp_exp);//exp_argument_L_fx in Q30 (not alwys, because tmp_exp values are not constant) //Scale() returns values in the highest possible precision
exp_argument_fx=L_shr_sat(exp_argument_fx,sub(6,tmp_exp));//exp_argument_L_fx in Q26
/* Limit exponent to approx +/-100 dB in case of incoherent value of delay_diff, to prevent overflow */
// 23 in Q26
// Replace by 23 in Q14, only for _fx. 23 in Q14 = 376832
// Pseudocode
// IF (GT_32(exp_argument_fx, 376832 ))
/*{
assign Q14 equivalent of Left_Shift(23552,5) to exp_argument_fx
}
IF (LT_32(exp_argument_fx, 0))
{
IF(GT_32(exp_argument_fx,1543503872))//23 in Q26
{
If(LT_32(negate(exp_argument_fx), 376832))
{
assign Q14 equivalent of Left_Shift(-23552,5) to exp_argument_fx
// pOutput_t60[i] = output_t60_fx[i] * ( 1 << output_t60_e[i] ); // Will not work - mantissa is 16 bit
}
L_tmp=BASOP_util_Pow2(tmp,10,&pow_exp);//Q28 -> not always, because pow_exp is not fixed
// tmp is a 32-bit signed integer in Q21, therefore expoenent to the power function is 10
//L_tmp = L_shl_sat( L_tmp, pow_exp );// Q28??
//L_tmp = L_shl( L_tmp, add( 1, pow_exp ) );
//L_tmp = L_shl( L_tmp, pow_exp );
L_tmp=Mpy_32_32(L_tmp,output_ene_fx[idx]);// Q27. Q28 multiplied by Q30 gives Q27 -> Finally, energy should be in Q31 ( this is mandatory for further computations)
L_tmp=L_shl_sat(L_tmp,add(1,pow_exp));//
/*for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) //Should not be required in fixed-point
{
pOutput_t60[i] = (float) fabs( me2f( output_t60_fx[i], output_t60_e[i] ) ); -->This operation must be recreated in fixed-point to return T60
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??
// Step 3 : multiply temp variable by gain, with appropriate scaling for Q31 and Q16 multiplication
tmp_ene=Mpy_32_32(tmp_ene,dmx_gain_2_fx);// Mpy_32_32_ss multiplies two 32 bit numberrs in 64-bit with saturation or L_mult -> outputs word16 // Qfactor of tmp_ene?? dmx_gain_2_fx is in Q16
// incomplete implentation
// Step 4 : multiply step 3 result with output energy