From 7374f5bb81b06087dc6ab33fbabe3b7ede5513e9 Mon Sep 17 00:00:00 2001
From: Marek Blok <Marek.Blok@pg.edu.pl>
Date: Tue, 4 Apr 2023 16:23:38 +0200
Subject: [PATCH] Fix: QAM offset corrected

---
 CHANGELOG                | 2 +-
 src/cpp/DSP_modules2.cpp | 2 +-
 src/include/DSP_lib.h    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 258f559..1e0d608 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,7 +8,7 @@ TODO::
 LAST DONE:
 
 CHANGES:
-- ver. 0.20.021 - <b>2022.04.04</b> Added: 
+- ver. 0.20.022 - <b>2022.04.04</b> Added: 
   - DSP::u::SymbolMapper - experimental support for QAM for even bits_per_symbol (Gray ordering) 
 - ver. 0.20.020 - <b>2022.04.04</b> Fixed: 
   - DSP::u::SymbolMapper - fixed support for phase rotation of DSP::e::ModulationType::ASK constelation 
diff --git a/src/cpp/DSP_modules2.cpp b/src/cpp/DSP_modules2.cpp
index 41702b7..668b9c5 100644
--- a/src/cpp/DSP_modules2.cpp
+++ b/src/cpp/DSP_modules2.cpp
@@ -1837,7 +1837,7 @@ unsigned int getConstellation(
     case DSP::e::ModulationType::QAM: {
         //  to convert number into gray, take the number and perform XOR after shifting the number 1 bit to the right.
         // x_gray = x ^ (x >> 1);
-        DSP::Float component_offset = (sqrt(DSP::Float(M))-1);
+        DSP::Float component_offset = (sqrt(DSP::Float(M))-1)/2;
         if ((bits_per_symbol % 2) == 0) {
           unsigned int mask = 0x00;
           for (unsigned int ind = 0; ind < bits_per_symbol/2; ind++) {
diff --git a/src/include/DSP_lib.h b/src/include/DSP_lib.h
index 34d7894..9d1bcf8 100644
--- a/src/include/DSP_lib.h
+++ b/src/include/DSP_lib.h
@@ -11,7 +11,7 @@
 
 #define DSP_VER_MAJOR 0
 #define DSP_VER_MINOR 20
-#define DSP_VER_BUILD 21 // !!! without zeroes before, else this will be treated as octal number
+#define DSP_VER_BUILD 22 // !!! without zeroes before, else this will be treated as octal number
 #define DSP_VER_YEAR  2023
 #define DSP_VER       DSP_VER_MAJOR.DSP_VER_MINOR.DSP_VER_BUILD
 
-- 
GitLab