]>
code.octet-stream.net Git - m17rt/blob - m17core/src/shaping.rs
1 pub static RRC_48K
: [f32; 81] = [
87 use std
::f32::consts
::PI
;
90 fn calculate_rrc_coefficients() {
91 let mut rrc
= [0.0; 81];
95 let inf_t
= t_s
/ (4.0 * roll_off
);
98 let t
= (i
as isize - 40) as f32;
101 rrc
[i
] = 1.0 / t_s
.sqrt() * ((1.0 - roll_off
) + (4.0 * roll_off
/ PI
));
102 } else if t
== inf_t
|| t
== -inf_t
{
103 rrc
[i
] = roll_off
/ (2.0 * t_s
).sqrt()
104 * ((1.0 + 2.0 / PI
) * f32::sin(PI
/ (4.0 * roll_off
))
105 + (1.0 - 2.0 / PI
) * f32::cos(PI
/ (4.0 * roll_off
)));
107 rrc
[i
] = 1.0 / t_s
.sqrt()
108 * (f32::sin((PI
* t
* (1.0 - roll_off
)) / t_s
)
109 + (4.0 * roll_off
* t
) / t_s
* f32::cos((PI
* t
* (1.0 + roll_off
)) / t_s
))
110 / (PI
* t
/ t_s
* (1.0 - (4.0 * roll_off
* t
/ t_s
).powi(2)));
114 println
!("{:?}", rrc
);
115 for (a
, b
) in rrc
.iter
().zip(super::RRC_48K
.iter
()) {
116 assert
!((a
- b
).abs() < 0.00001);