Commit b6028550 authored by Dominik Weckbecker's avatar Dominik Weckbecker 💬
Browse files

fix floating point exception in noise est

parent f221482e
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -206,6 +206,8 @@

#define FIX_485_STATIC_BUFFERS                          /* FhG: move static buffers in DirAC parameter estimator to the DirAC struct */

#define FIX_483                                         /* FhG: fix usse 483, division by zero in nois_est */

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

+15 −0
Original line number Diff line number Diff line
@@ -378,6 +378,20 @@ void noise_est(
    {
        if ( st->hSpMusClas != NULL )
        {
#ifdef FIX_483
            float E;

            E = mean( lf_E, 8 );
            if ( E < 1.0f )
            {
                st->hSpMusClas->ener_RAT = 0.f;
            }
            else
            {
                st->hSpMusClas->ener_RAT = 10.0f * (float) log10( E );
                st->hSpMusClas->ener_RAT /= ( Etot + 0.01f );
            }
#else
            st->hSpMusClas->ener_RAT = 10.0f * (float) log10( mean( lf_E, 8 ) );
            st->hSpMusClas->ener_RAT /= ( Etot + 0.01f );

@@ -385,6 +399,7 @@ void noise_est(
            {
                st->hSpMusClas->ener_RAT = 0.0f;
            }
#endif

            if ( st->hSpMusClas->ener_RAT > 1.0 )
            {