diff options
Diffstat (limited to 'src/DabMod.cpp')
-rw-r--r-- | src/DabMod.cpp | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp index 91c0b9d..dc61ae2 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -35,6 +35,7 @@ #include "DabModulator.h" #include "InputMemory.h" #include "OutputFile.h" +#include "FormatConverter.h" #if defined(HAVE_OUTPUT_UHD) # include "OutputUHD.h" #endif @@ -176,6 +177,7 @@ int main(int argc, char* argv[]) std::string outputName; int useZeroMQOutput = 0; int useFileOutput = 0; + std::string fileOutputFormat = "complexf"; int useUHDOutput = 0; uint64_t frame = 0; @@ -187,6 +189,17 @@ int main(int argc, char* argv[]) GainMode gainMode = GAIN_VAR; Buffer data; + + /* UHD requires the input I and Q samples to be in the interval + * [-1.0,1.0], otherwise they get truncated, which creates very + * wide-spectrum spikes. Depending on the Transmission Mode, the + * Gain Mode and the sample rate (and maybe other parameters), the + * samples can have peaks up to about 48000. The value of 50000 + * should guarantee that with a digital gain of 1.0, UHD never clips + * our samples. + */ + const float normalise_factor = 50000.0f; + std::string filterTapsFilename = ""; // Two configuration sources exist: command line and (new) INI file @@ -207,6 +220,7 @@ int main(int argc, char* argv[]) Flowgraph* flowgraph = NULL; DabModulator* modulator = NULL; InputMemory* input = NULL; + FormatConverter* format_converter = NULL; ModOutput* output = NULL; BaseRemoteController* rc = NULL; @@ -478,6 +492,8 @@ int main(int argc, char* argv[]) goto END_MAIN; } useFileOutput = 1; + + fileOutputFormat = pt.get("fileoutput.format", fileOutputFormat); } #if defined(HAVE_OUTPUT_UHD) else if (output_selected == "uhd") { @@ -741,23 +757,23 @@ int main(int argc, char* argv[]) goto END_MAIN; } - if (useFileOutput) { - // Opening COFDM output file - output = new OutputFile(outputName); + if (fileOutputFormat == "complexf") { + output = new OutputFile(outputName); + } + else if (fileOutputFormat == "s8") { + // We must normalise the samples to the interval [-127.0; 127.0] + normalise = 127.0f / normalise_factor; + + format_converter = new FormatConverter(); + + output = new OutputFile(outputName); + } } #if defined(HAVE_OUTPUT_UHD) else if (useUHDOutput) { - /* UHD requires the input I and Q samples to be in the interval - * [-1.0,1.0], otherwise they get truncated, which creates very - * wide-spectrum spikes. Depending on the Transmission Mode, the - * Gain Mode and the sample rate (and maybe other parameters), the - * samples can have peaks up to about 48000. The value of 50000 - * should guarantee that with a digital gain of 1.0, UHD never clips - * our samples. - */ - normalise = 1.0f/50000.0f; + normalise = 1.0f / normalise_factor; outputuhd_conf.sampleRate = outputRate; try { @@ -773,7 +789,7 @@ int main(int argc, char* argv[]) #if defined(HAVE_OUTPUT_ZEROMQ) else if (useZeroMQOutput) { /* We normalise the same way as for the UHD output */ - normalise = 1.0f/50000.0f; + normalise = 1.0f / normalise_factor; output = new OutputZeroMQ(outputName); } @@ -785,7 +801,13 @@ int main(int argc, char* argv[]) modulator = new DabModulator(modconf, rc, logger, outputRate, clockRate, dabMode, gainMode, digitalgain, normalise, filterTapsFilename); flowgraph->connect(input, modulator); - flowgraph->connect(modulator, output); + if (format_converter) { + flowgraph->connect(modulator, format_converter); + flowgraph->connect(format_converter, output); + } + else { + flowgraph->connect(modulator, output); + } #if defined(HAVE_OUTPUT_UHD) if (useUHDOutput) { |