38 if (value > fullscale)
41 return std::numeric_limits<std::int16_t>::max();
43 if (value < -fullscale)
46 return std::numeric_limits<std::int16_t>::min();
48 if (value == fullscale)
50 return std::numeric_limits<std::int16_t>::max();
52 if (value == -fullscale)
54 return std::numeric_limits<std::int16_t>::min();
58 std::round((value / fullscale) *
static_cast<RealType>(std::numeric_limits<std::int16_t>::max()));
59 return static_cast<std::int16_t
>(
60 std::clamp<RealType>(
scaled,
static_cast<RealType>(std::numeric_limits<std::int16_t>::min()),
61 static_cast<RealType>(std::numeric_limits<std::int16_t>::max())));
74 for (
auto& sample :
data)
76 auto [i, q] = std::tuple{std::clamp(std::floor(
levels * sample.real() / fullscale) /
levels, -1.0, 1.0),
77 std::clamp(std::floor(
levels * sample.imag() / fullscale) /
levels, -1.0, 1.0)};
97 int const start_sample =
static_cast<int>(std::round(rate * (
resp->startTime() - start)));
111 const RealType fracDelay,
const std::span<
const std::unique_ptr<serial::Response>> responses)
113 const RealType end = start + length;
116 for (
const auto&
response : responses)
125 const auto local_window_size =
static_cast<std::size_t
>(std::ceil(length * rate));
157 for (
auto& sample :
window)
176 for (
auto& sample :
window)
185 for (
const auto& sample :
window)
199 for (
auto& sample :
window)
210 if (fullscale <= 0.0 || !std::isfinite(fullscale))
212 throw std::invalid_argument(
"Fixed full-scale must be positive and finite.");
216 result.samples.reserve(samples.size());
217 for (
const auto& sample : samples)
224 ++
result.clipped_sample_count;
Generates white Gaussian noise.
Manages radar signal responses from a transmitter.
double RealType
Type for real numbers.
std::complex< RealType > ComplexType
Type for complex numbers.
RealType rate() noexcept
Get the rendering sample rate.
RealType boltzmannK() noexcept
Get the Boltzmann constant.
unsigned oversampleRatio() noexcept
Get the oversampling ratio.
unsigned adcBits() noexcept
Get the ADC quantization bits.
FixedFullscaleScalingResult scaleToInt16FixedFullscale(const std::span< const ComplexType > samples, const RealType fullscale)
Scales complex samples against a fixed full-scale to signed int16 IQ.
void applyThermalNoise(std::span< ComplexType > window, const RealType noiseTemperature, std::mt19937 &rngEngine)
Applies thermal (Johnson-Nyquist) noise to a window of I/Q samples.
void applyThermalNoiseAtSampleRate(std::span< ComplexType > window, const RealType noiseTemperature, std::mt19937 &rngEngine, const RealType sampleRateHz)
Applies circular complex thermal noise using a caller-specified complex-baseband sample rate.
RealType quantizeAndScaleWindow(std::span< ComplexType > window)
Simulates ADC quantization and scales a window of complex I/Q samples.
void renderWindow(std::vector< ComplexType > &window, const RealType length, const RealType start, const RealType fracDelay, const std::span< const std::unique_ptr< serial::Response > > responses)
Renders a time-window of I/Q data from a collection of raw radar responses.
Header file for noise generator classes.
Defines the Parameters struct and provides methods for managing simulation parameters.
Classes for managing radar signal responses.
Header for receiver-side signal processing and rendering.
One complex Cartesian IQ sample scaled for VITA-style signed 16-bit transport.
Result of fixed-fullscale IQ scaling.
A simple thread pool implementation.