diff options
Diffstat (limited to 'gr-channels/lib/fading_model_impl.cc')
-rw-r--r-- | gr-channels/lib/fading_model_impl.cc | 83 |
1 files changed, 2 insertions, 81 deletions
diff --git a/gr-channels/lib/fading_model_impl.cc b/gr-channels/lib/fading_model_impl.cc index a39a6cf44f..4ea4d1274e 100644 --- a/gr-channels/lib/fading_model_impl.cc +++ b/gr-channels/lib/fading_model_impl.cc @@ -50,37 +50,8 @@ namespace gr { : sync_block("fading_model", io_signature::make(1, 1, sizeof(gr_complex)), io_signature::make(1, 1, sizeof(gr_complex))), - seed_1((int)seed), - dist_1(-M_PI, M_PI), - rv_1( seed_1, dist_1 ), // U(-pi,pi) - - seed_2((int)seed+1), - dist_2(0, 1), - rv_2( seed_2, dist_2 ), // U(0,1) - - d_N(N), - d_fDTs(fDTs), - d_theta(rv_1()), - d_theta_los(rv_1()), - d_step( powf(0.00125*fDTs, 1.1) ), // max step size approximated from Table 2 - d_m(0), - d_K(K), - d_LOS(LOS), - - d_psi(d_N+1, 0), - d_phi(d_N+1, 0), - - d_table(8*1024), - - scale_sin(sqrtf(2.0/d_N)), - scale_los(sqrtf(d_K)/sqrtf(d_K+1)), - scale_nlos(1/sqrtf(d_K+1)) + d_fader(N,fDTs, LOS, K, seed) { - // generate initial phase values - for(int i=0; i<d_N+1; i++){ - d_psi[i] = rv_1(); - d_phi[i] = rv_1(); - } } fading_model_impl::~fading_model_impl() @@ -138,17 +109,6 @@ namespace gr { #endif /* GR_CTRLPORT */ } - void - fading_model_impl::update_theta() - { - d_theta += (d_step*rv_2()); - if(d_theta > M_PI){ - d_theta = M_PI; d_step = -d_step; - } else if(d_theta < -M_PI){ - d_theta = -M_PI; d_step = -d_step; - } - } - int fading_model_impl::work (int noutput_items, gr_vector_const_void_star &input_items, @@ -156,48 +116,9 @@ namespace gr { { const gr_complex* in = (const gr_complex*) input_items[0]; gr_complex* out = (gr_complex*) output_items[0]; - for(int i=0; i<noutput_items; i++){ - gr_complex H(0,0); - - for(int n=1; n<d_N; n++){ - float alpha_n = (2*M_PI*n - M_PI + d_theta)/4*d_N; -#if FASTSINCOS == 1 - float s_i = scale_sin*gr::fxpt::cos(gr::fxpt::float_to_fixed(2*M_PI*d_fDTs*d_m*gr::fxpt::cos(gr::fxpt::float_to_fixed(alpha_n))+d_psi[n+1])); - float s_q = scale_sin*gr::fxpt::cos(gr::fxpt::float_to_fixed(2*M_PI*d_fDTs*d_m*gr::fxpt::sin(gr::fxpt::float_to_fixed(alpha_n))+d_phi[n+1])); -#elif FASTSINCOS == 2 - float s_i = scale_sin*d_table.cos(2*M_PI*d_fDTs*d_m*d_table.cos(alpha_n)+d_psi[n+1]); - float s_q = scale_sin*d_table.cos(2*M_PI*d_fDTs*d_m*d_table.sin(alpha_n)+d_phi[n+1]); - -#else - float s_i = scale_sin*cos(2*M_PI*d_fDTs*d_m*cos(alpha_n)+d_psi[n+1]); - float s_q = scale_sin*cos(2*M_PI*d_fDTs*d_m*sin(alpha_n)+d_phi[n+1]); -#endif - - H += gr_complex(s_i, s_q); - } - - if(d_LOS){ -#if FASTSINCOS == 1 - float los_i = gr::fxpt::cos(gr::fxpt::float_to_fixed(2*M_PI*d_fDTs*d_m*gr::fxpt::cos(gr::fxpt::float_to_fixed(d_theta_los)) + d_psi[0])); - float los_q = gr::fxpt::sin(gr::fxpt::float_to_fixed(2*M_PI*d_fDTs*d_m*gr::fxpt::cos(gr::fxpt::float_to_fixed(d_theta_los)) + d_psi[0])); -#elif FASTSINCOS == 2 - float los_i = d_table.cos(2*M_PI*d_fDTs*d_m*d_table.cos(d_theta_los) + d_psi[0]); - float los_q = d_table.sin(2*M_PI*d_fDTs*d_m*d_table.cos(d_theta_los) + d_psi[0]); -#else - float los_i = cos(2*M_PI*d_fDTs*d_m*cos(d_theta_los) + d_psi[0]); - float los_q = sin(2*M_PI*d_fDTs*d_m*cos(d_theta_los) + d_psi[0]); -#endif - - H = H*scale_nlos + gr_complex(los_i,los_q)*scale_los; - } - - out[i] = in[i]*H; - d_m++; - update_theta(); - + out[i] = in[i] * d_fader.next_sample(); } - return noutput_items; } |