X-Git-Url: https://code.octet-stream.net/m17rt/blobdiff_plain/4cfda08117c4288a5408d45db1ef4be82f4facaa..8d1ce395337cf7d508500b13c574eaeb401f1e77:/m17core/src/modem.rs?ds=sidebyside

diff --git a/m17core/src/modem.rs b/m17core/src/modem.rs
index b2ab773..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];
         }
 
@@ -311,12 +311,11 @@ impl SoftModulator {
         for i in 0..10 {
             // Right now we are encoding everything as 1.0-scaled dibit floats
             // This is a bit silly but it will do for a minute
-            // Max theoretical gain from the RRC filter is 4.328
-            // Let's bump everything to a baseline of 16383 / 4.328 = 3785.35
-            // This is not particularly high but at least we won't ever hit the top
+            // Max possible gain from the RRC filter with upsampling is about 0.462
+            // Let's bump everything to a baseline of 16383 / 0.462 = 35461
+            // For normal signals this yields roughly 0.5 magnitude which is plenty
             if i == 0 {
-                // 10x the impulse with zeroes between for upsampling
-                self.filter_win[self.filter_cursor] = dibit * 3785.0 * 10.0;
+                self.filter_win[self.filter_cursor] = dibit * 35461.0;
             } else {
                 self.filter_win[self.filter_cursor] = 0.0;
             }
@@ -420,7 +419,7 @@ impl Modulator for SoftModulator {
 
         // if we have pre-TX padding to accommodate TxDelay then expend that first
         if self.tx_delay_padding > 0 {
-            let len = out.len().max(self.tx_delay_padding);
+            let len = out.len().min(self.tx_delay_padding);
             self.tx_delay_padding -= len;
             for x in 0..len {
                 out[x] = 0;