From 4d10d9f404b10232e65f1be58a159e08fb692f14 Mon Sep 17 00:00:00 2001
From: c vw <dl1ycf@darc.de>
Date: Mon, 15 Nov 2021 14:00:45 +0100
Subject: [PATCH] SOAPY: normalize TX IQ samples to unity.

---
 transmitter.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/transmitter.c b/transmitter.c
index 525dfd7..1e4ef52 100644
--- a/transmitter.c
+++ b/transmitter.c
@@ -1139,7 +1139,7 @@ static void full_tx_buffer(TRANSMITTER *tx) {
       break;
 #ifdef SOAPYSDR
     case SOAPYSDR_PROTOCOL:
-      gain=32767.0;  // 16 bit
+      // gain is not used, since samples are floating point
       break;
 #endif
   }
@@ -1181,7 +1181,7 @@ static void full_tx_buffer(TRANSMITTER *tx) {
     // by about 20 dB and at 1000 Hz by about 10 dB.
     // Natural speech has much energy at frequencies below 1000 Hz
     // which will therefore aquire only little energy, such that
-    // FM sounds rather silent.
+    // FM sounds rather "thin".
     //
     // At the expense of having some distortion for the highest
     // frequencies, we amplify the mic samples here by 15 dB
@@ -1259,7 +1259,8 @@ static void full_tx_buffer(TRANSMITTER *tx) {
       // 7.5 dB we have to damp significantly at this place, which may affect IMD.
       //
       // NOTE: When doing adaptive pre-distortion (PURESIGNAL), IQ scaling cannot
-      //       be used.
+      //       be used because the the TX ADC samples reported back also never
+      //       reach their "SetPK" amplitude and PURESIGNAL does not jump in
       //
       int power;
       double f,g;
@@ -1342,11 +1343,9 @@ static void full_tx_buffer(TRANSMITTER *tx) {
             // the only difference to the P2 treatment is that we do not
             // generate audio samples to be sent to the radio
             //
-	    isample=0;
             for(j=0;j<tx->output_samples;j++) {
 	      ramp=cw_shape_buffer192[j];	    		// between 0.0 and 1.0
-	      qsample=floor(gain*ramp+0.5);         	    	// always non-negative, isample is just the pulse envelope
-              soapy_protocol_iq_samples((float)isample,(float)qsample);
+              soapy_protocol_iq_samples(0.0F,(float)ramp);      // SOAPY: just convert double to float
 	    }
 	    break;
 #endif
@@ -1375,7 +1374,8 @@ static void full_tx_buffer(TRANSMITTER *tx) {
 		    break;
 #ifdef SOAPYSDR
                 case SOAPYSDR_PROTOCOL:
-                    soapy_protocol_iq_samples((float)isample,(float)qsample);
+                    // SOAPY: just convert the double IQ sampels (is,qs) to float.
+                    soapy_protocol_iq_samples((float)is,(float)qs);
                     break;
 #endif
 	    }
-- 
2.45.2