summaryrefslogtreecommitdiff
path: root/gr-digital/lib/constellation.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital/lib/constellation.cc')
-rw-r--r--gr-digital/lib/constellation.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/gr-digital/lib/constellation.cc b/gr-digital/lib/constellation.cc
index e73b2c8a43..9eee1cc501 100644
--- a/gr-digital/lib/constellation.cc
+++ b/gr-digital/lib/constellation.cc
@@ -50,9 +50,20 @@ namespace gr {
d_rotational_symmetry(rotational_symmetry),
d_dimensionality(dimensionality)
{
+ // Scale constellation points so that average magnitude is 1.
+ float summed_mag = 0;
+ unsigned int constsize = d_constellation.size();
+ for (unsigned int i=0; i<constsize; i++) {
+ gr_complex c = d_constellation[i];
+ summed_mag += sqrt(c.real()*c.real() + c.imag()*c.imag());
+ }
+ d_scalefactor = constsize/summed_mag;
+ for (unsigned int i=0; i<constsize; i++) {
+ d_constellation[i] = d_constellation[i]*d_scalefactor;
+ }
if(pre_diff_code.size() == 0)
d_apply_pre_diff_code = false;
- else if(pre_diff_code.size() != constell.size())
+ else if(pre_diff_code.size() != constsize)
throw std::runtime_error("The constellation and pre-diff code must be of the same length.");
else
d_apply_pre_diff_code = true;
@@ -318,6 +329,8 @@ namespace gr {
n_real_sectors(real_sectors), n_imag_sectors(imag_sectors),
d_width_real_sectors(width_real_sectors), d_width_imag_sectors(width_imag_sectors)
{
+ d_width_real_sectors *= d_scalefactor;
+ d_width_imag_sectors *= d_scalefactor;
find_sector_values();
}