diff options
| author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-12-25 14:57:56 +0100 | 
|---|---|---|
| committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-12-25 14:57:56 +0100 | 
| commit | 78c4a0b9af981dc66cb42d46dfd60fe87679d178 (patch) | |
| tree | 7da981e2ee8d8e9047c482f86ceb607e84ee1566 /src/DabMod.cpp | |
| parent | aa63facf2c4140acef2ba6e7f1b8012eec5536bf (diff) | |
| download | dabmod-78c4a0b9af981dc66cb42d46dfd60fe87679d178.tar.gz dabmod-78c4a0b9af981dc66cb42d46dfd60fe87679d178.tar.bz2 dabmod-78c4a0b9af981dc66cb42d46dfd60fe87679d178.zip  | |
Add file output format converter
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) {  | 
