Expand description
A numerically controlled oscillator (NCO) and the machinery shared by every signal source.
The oscillator is a fixed-point phase accumulator: the phase is a u64 where 2^64 is one full
cycle, advanced each sample by a frequency tuning word. Wrap-around is free, the phase never
drifts, and frequency resolution is sample_rate / 2^64.
A source is an NcoSource, which pairs an Nco with a Waveform that maps phase to an
amplitude, plus an output amplitude and offset. Sine, square, triangle, ramp, pulse-train and
noise sources are all just different waveforms driven by the same oscillator, and they all
implement StreamOperator through the one implementation here.
All periodic waveforms share the sine’s phase reference: at phase 0 they are at their rising zero crossing (or, for the 0/1 pulse train, at the start of the pulse).
§Streaming
A source implements StreamOperator<(), Output> (free-running: the length of the input slice is
the number of samples to produce) and StreamOperator<f64, Output> (frequency modulation: each
input value is an instantaneous frequency offset in Hz added to the oscillator frequency), where
Output is f64 for real sources and Complex<f64> for the quadrature source.
See the book entry Signal sources: oscillators, CORDIC and waveforms.
Structs§
- Nco
- A numerically controlled oscillator.
- NcoSource
- A signal source: an
Ncodriving aWaveform, scaled byamplitudeand shifted byoffset. - Phase
- A point in the oscillator’s cycle, as a fraction of a turn in
[0, 1)scaled by2^64.