diff options
author | andreas128 <Andreas> | 2017-03-27 00:03:36 +0200 |
---|---|---|
committer | andreas128 <Andreas> | 2017-03-27 00:03:36 +0200 |
commit | d9d46c982e3270a349f98ce094d959d326c998ce (patch) | |
tree | af57d0d3cd6a77381101d36e29c554de337a33d7 | |
parent | 5c29e8776e1bd833e1ea60b57698a09b4d7f60e7 (diff) | |
parent | 82b3ca9e4ff05298438226957274ac7cd56f17f9 (diff) | |
download | dabmod-d9d46c982e3270a349f98ce094d959d326c998ce.tar.gz dabmod-d9d46c982e3270a349f98ce094d959d326c998ce.tar.bz2 dabmod-d9d46c982e3270a349f98ce094d959d326c998ce.zip |
Add normalisation for file output
-rw-r--r-- | doc/example.ini | 13 | ||||
-rw-r--r-- | src/DabMod.cpp | 14 |
2 files changed, 22 insertions, 5 deletions
diff --git a/doc/example.ini b/doc/example.ini index 0659813..f8cec36 100644 --- a/doc/example.ini +++ b/doc/example.ini @@ -141,13 +141,16 @@ output=uhd [fileoutput] ; Two output formats are supported: In the default mode, -; the file output writes I/Q float values (i.e. complex float) -; to the file. The I and Q samples can take values up to -; 100000 in absolute magnitude with gainmode FIX. -; With gainmode VAR, they should never exceed 50000. -; With gainmode MAX, thet are limited to 32767. +; the file output writes I/Q float values (i.e. complex +; float) to the file. The I and Q samples can take values up +; to 810000 in absolute magnitude with gainmode FIX. With +; gainmode VAR and FIX, they should never exceed 50000. ;format=complexf ; +; When the format is set to complexf_normalised the maximal +; amplitude written to a file, is the digital gain +-10%. +;format=complexf_normalised +; ; When the format is set to s8, the output writes I/Q 8-bit ; signed integers, where the magnitude is multiplied by 128/50000 ; effectively mapping the gainmode VAR range of -50000 -- 50000 diff --git a/src/DabMod.cpp b/src/DabMod.cpp index 301b078..4e4cdab 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -81,6 +81,11 @@ */ static const float normalise_factor = 50000.0f; +//Empirical normalisation factors used to normalise the samples to amplitude 1. +static const float normalise_factor_file_fix = 81000.0f; +static const float normalise_factor_file_var = 46000.0f; +static const float normalise_factor_file_max = 46000.0f; + typedef std::complex<float> complexf; using namespace std; @@ -183,6 +188,15 @@ static shared_ptr<ModOutput> prepare_output( if (s.fileOutputFormat == "complexf") { output = make_shared<OutputFile>(s.outputName); } + if (s.fileOutputFormat == "complexf_normalised") { + if (s.gainMode == GainMode::GAIN_FIX) + s.normalise = 1.0 / normalise_factor_file_fix; + else if (s.gainMode == GainMode::GAIN_MAX) + s.normalise = 1.0 / normalise_factor_file_max; + else if (s.gainMode == GainMode::GAIN_VAR) + s.normalise = 1.0 / normalise_factor_file_var; + output = make_shared<OutputFile>(s.outputName); + } else if (s.fileOutputFormat == "s8") { // We must normalise the samples to the interval [-127.0; 127.0] s.normalise = 127.0f / normalise_factor; |