From 82b3ca9e4ff05298438226957274ac7cd56f17f9 Mon Sep 17 00:00:00 2001 From: andreas128 Date: Thu, 16 Mar 2017 00:00:30 +0000 Subject: Add normalisation for file output --- src/DabMod.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/DabMod.cpp') diff --git a/src/DabMod.cpp b/src/DabMod.cpp index 7fc395e..4fedac4 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 complexf; using namespace std; @@ -183,6 +188,15 @@ static shared_ptr prepare_output( if (s.fileOutputFormat == "complexf") { output = make_shared(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(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; -- cgit v1.2.3