]>
code.octet-stream.net Git - m17rt/blob - demod/src/main.rs
f67f87dccbbe18de1bfc41326815d1e57bc509c6
3 modem
::{Demodulator
, SoftDemodulator
},
4 protocol
::{Frame
, LichCollection
},
6 pub(crate) use std
::{fs
::File
, io
::Read
};
8 pub fn run_my_decode() {
9 let file
= File
::open("../../Data/test_vk7xt.rrc").unwrap
();
11 let mut baseband
= vec
![];
12 input
.read_to_end(&mut baseband
).unwrap
();
14 let mut lich
= LichCollection
::new();
15 let mut codec2_data
= vec
![];
16 let mut modem
= SoftDemodulator
::new();
18 for pair
in baseband
.chunks(2) {
19 let sample
: i16 = i16::from_le_bytes([pair
[0], pair
[1]]);
20 if let Some(frame
) = modem
.demod(sample
) {
21 debug
!("Modem demodulated frame: {:?}", frame
);
22 if let Frame
::Stream(s
) = frame
{
23 for b
in s
.stream_data
{
26 let valid_before
= lich
.valid_segments();
27 lich
.set_segment(s
.lich_idx
, s
.lich_part
);
28 let valid_after
= lich
.valid_segments();
29 if valid_before
!= valid_after
{
30 debug
!("Valid lich segments: {}", lich
.valid_segments());
32 if valid_before
== 5 && valid_after
== 6 {
33 if let Some(l
) = lich
.try_assemble() {
34 debug
!("Assembled complete lich: {l:?}");
39 debug
!("len of codec2 data: {}", codec2_data
.len());
40 assert_eq
!(codec2_data
.len(), 1504);
42 m17codec2
::decode_codec2(&codec2_data
, "../../Data/speech_out.raw");