From: Thomas Karpiniec Date: Mon, 20 Jan 2025 08:59:28 +0000 (+1100) Subject: Reduce the number of samples being moved around for sync burst detection X-Git-Tag: v0.1.0~11 X-Git-Url: https://code.octet-stream.net/m17rt/commitdiff_plain/8d1ce395337cf7d508500b13c574eaeb401f1e77?hp=bc4b6ea4290384cd8c380af2a9014f162fd43683 Reduce the number of samples being moved around for sync burst detection --- diff --git a/m17core/src/decode.rs b/m17core/src/decode.rs index 6c8e02b..86567d9 100755 --- a/m17core/src/decode.rs +++ b/m17core/src/decode.rs @@ -54,8 +54,8 @@ pub(crate) fn sync_burst_correlation(target: [i8; 8], samples: &[f32]) -> (f32, let mut pos_max: f32 = f32::MIN; let mut neg_max: f32 = f32::MAX; for i in 0..8 { - pos_max = pos_max.max(samples[i * 10]); - neg_max = neg_max.min(samples[i * 10]); + pos_max = pos_max.max(samples[i]); + neg_max = neg_max.min(samples[i]); } let gain = (pos_max - neg_max) / 2.0; let shift = pos_max + neg_max; @@ -65,7 +65,7 @@ pub(crate) fn sync_burst_correlation(target: [i8; 8], samples: &[f32]) -> (f32, let mut diff = 0.0; for i in 0..8 { - let sym_diff = (((samples[i * 10] - shift) / gain) - target[i] as f32).abs(); + let sym_diff = (((samples[i] - shift) / gain) - target[i] as f32).abs(); if sym_diff > SYNC_BIT_THRESHOLD { return (f32::MAX, gain, shift); } diff --git a/m17core/src/modem.rs b/m17core/src/modem.rs index fe57188..b459826 100644 --- a/m17core/src/modem.rs +++ b/m17core/src/modem.rs @@ -65,9 +65,9 @@ impl Demodulator for SoftDemodulator { return None; } - let mut burst_window = [0f32; 71]; - for i in 0..71 { - let c = (self.rx_cursor + i) % 1920; + let mut burst_window = [0f32; 8]; + for i in 0..8 { + let c = (self.rx_cursor + (i * 10)) % 1920; burst_window[i] = self.rx_win[c]; }