Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "PathSimProcessor.h"
#include "PathSimParams.h"

#include <cstdlib>
#include <iostream>
#include <random>
#include "cxxopts.h"
#include "AudioFile.h"

Expand Down Expand Up @@ -37,6 +39,9 @@ from a Windows GUI application by Moe Wheatley, AE4JY, 2000\n\
}

options.add_options("Propagation")
("seed", "PRNG seed for the fading/noise processes (default: random; "
"the seed used is printed so any run can be reproduced exactly)",
cxxopts::value<unsigned int>())
("snr", "Signal to Noise Ratio (SNR)", cxxopts::value<double>())
("spread", "Frequency spread of the 1st path [Hz]", cxxopts::value<double>())
("offset", "Frequency offset of the 1st path [Hz]", cxxopts::value<double>())
Expand All @@ -56,6 +61,20 @@ from a Windows GUI application by Moe Wheatley, AE4JY, 2000\n\
exit(0);
}

// Seed the PRNG behind the Rayleigh fading and AWGN stages. Without
// this, rand() runs from its default seed and EVERY invocation
// produces bit-identical "random" fading and noise — N runs give one
// realization N times, silently defeating ensemble statistics.
// Default is a fresh random seed; it is printed (stderr, so pipes
// stay clean) so any run can be reproduced with --seed.
{
unsigned int seed = result.count("seed")
? result["seed"].as<unsigned int>()
: std::random_device{}();
std::srand(seed);
std::cerr << "pathsim: seed " << seed << std::endl;
}

if (argc > 1 ||
((result.count("input_file") != 1 || result.count("output_file") != 1) &&
result.arguments().size() != 2)) {
Expand Down