summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-12-11 16:03:28 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-12-11 16:35:12 +0100
commit9ea7df6030842be17a8ea52e7e659871b33a49bf (patch)
tree91de181d314bb88f48dfd0c38d9d2bf1dfafb620
parente181b4b9fed8d811a3d9b22d249a1b939ed9f3f8 (diff)
downloaddabmod-9ea7df6030842be17a8ea52e7e659871b33a49bf.tar.gz
dabmod-9ea7df6030842be17a8ea52e7e659871b33a49bf.tar.bz2
dabmod-9ea7df6030842be17a8ea52e7e659871b33a49bf.zip
Make gainmode VAR the default and update config to accept gainmode identifiers
-rw-r--r--doc/example.ini10
-rw-r--r--src/DabMod.cpp21
-rw-r--r--src/Utils.cpp6
3 files changed, 23 insertions, 14 deletions
diff --git a/doc/example.ini b/doc/example.ini
index 259ee4a..6a4b0f4 100644
--- a/doc/example.ini
+++ b/doc/example.ini
@@ -64,25 +64,23 @@ loop=0
;source=localhost:9200
[modulator]
-; Gain mode: 0=FIX, 1=MAX, 2=VAR
-;
-; Mode 0 (FIX) uses a fixed factor and is really not recommended. It is more
+; Mode 'fix' uses a fixed factor and is really not recommended. It is more
; useful on an academic perspective for people trying to understand the DAB
; modulation.
;
-; Mode 1 (MAX) is the normalization of every OFDM symbol. No overshoot, no
+; Mode 'max' is the normalization of every OFDM symbol. No overshoot, no
; truncating, but varying output power (around 3dB) which might not be the best
; for some power amplifier. The output samples are limited to a magnitude
; of 32768.
;
-; Mode 2 (VAR) uses the method specified in ETSI 300 798. This method
+; Mode 'var' uses the method specified in ETSI 300 798. This method
; normalizes to 4 times the standard deviation for an approximation of the RMS
; power. So around 6/100000 samples will be truncated and will introduce some
; really minor distortion. But this mode also maximizes the output power. This
; is the gain mode recommended for real world operation as it is based on a DAB
; standard; the only difference is that ODR-DabMod uses a better resolution
; with 16 bits instead of 8 bits.
-gainmode=2
+gainmode=var
; Transmission mode
; If not defined, take the mode from ETI
diff --git a/src/DabMod.cpp b/src/DabMod.cpp
index 1cbbcbc..194c441 100644
--- a/src/DabMod.cpp
+++ b/src/DabMod.cpp
@@ -3,7 +3,7 @@
Her Majesty the Queen in Right of Canada (Communications Research
Center Canada)
- Copyright (C) 2014, 2015
+ Copyright (C) 2016
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -110,6 +110,19 @@ enum class run_modulator_state_t {
run_modulator_state_t run_modulator(modulator_data& m);
+static GainMode parse_gainmode(const std::string &gainMode_setting)
+{
+ string gainMode_minuscule(gainMode_setting);
+ std::transform(gainMode_minuscule.begin(), gainMode_minuscule.end(), gainMode_minuscule.begin(), ::tolower);
+
+ if (gainMode_minuscule == "0" or gainMode_minuscule == "fix") { return GainMode::GAIN_FIX; }
+ else if (gainMode_minuscule == "1" or gainMode_minuscule == "max") { return GainMode::GAIN_MAX; }
+ else if (gainMode_minuscule == "2" or gainMode_minuscule == "var") { return GainMode::GAIN_VAR; }
+
+ cerr << "Modulator gainmode setting '" << gainMode_setting << "' not recognised." << endl;
+ throw std::runtime_error("Configuration error");
+}
+
int launch_modulator(int argc, char* argv[])
{
int ret = 0;
@@ -227,7 +240,7 @@ int launch_modulator(int argc, char* argv[])
#endif
break;
case 'g':
- gainMode = (GainMode)strtol(optarg, NULL, 0);
+ gainMode = parse_gainmode(optarg);
break;
case 'G':
#if defined(HAVE_OUTPUT_UHD)
@@ -400,7 +413,9 @@ int launch_modulator(int argc, char* argv[])
// modulator parameters:
- gainMode = (GainMode)pt.get("modulator.gainmode", 0);
+ const string gainMode_setting = pt.get("modulator.gainmode", "var");
+ gainMode = parse_gainmode(gainMode_setting);
+
dabMode = pt.get("modulator.mode", dabMode);
clockRate = pt.get("modulator.dac_clk_rate", (size_t)0);
digitalgain = pt.get("modulator.digital_gain", digitalgain);
diff --git a/src/Utils.cpp b/src/Utils.cpp
index dd119a7..54a4161 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -75,11 +75,7 @@ void printUsage(char* progName)
fprintf(out, "-T taps_file: Enable filtering before the output, using the specified file containing the filter taps.\n");
fprintf(out, "-a gain: Apply digital amplitude gain.\n");
fprintf(out, "-c rate: Set the DAC clock rate and enable Cic Equalisation.\n");
- fprintf(out, "-g: Set computation gain mode: "
- "%u FIX, %u MAX, %u VAR\n",
- (unsigned int)GainMode::GAIN_FIX,
- (unsigned int)GainMode::GAIN_MAX,
- (unsigned int)GainMode::GAIN_VAR);
+ fprintf(out, "-g gainmode: Set computation gain mode: fix, max or var\n");
fprintf(out, "-h: Print this help.\n");
fprintf(out, "-l: Loop file when reach end of file.\n");
fprintf(out, "-m mode: Set DAB mode: (0: auto, 1-4: force).\n");