pub struct NcoSource<W: Waveform> { /* private fields */ }Expand description
Implementations§
Source§impl<W: Waveform> NcoSource<W>
impl<W: Waveform> NcoSource<W>
Sourcepub fn from_parts(nco: Nco, waveform: W) -> Self
pub fn from_parts(nco: Nco, waveform: W) -> Self
Builds a unit-amplitude, zero-offset source from an oscillator and a waveform.
Sourcepub fn with_amplitude(self, amplitude: f64) -> Self
pub fn with_amplitude(self, amplitude: f64) -> Self
Sets the output amplitude (a multiplier on the waveform).
Sourcepub fn with_offset(self, offset: W::Output) -> Self
pub fn with_offset(self, offset: W::Output) -> Self
Sets a constant added to every output sample (a complex constant for complex sources).
Sourcepub fn with_phase_turns(self, turns: f64) -> Self
pub fn with_phase_turns(self, turns: f64) -> Self
Sets the starting phase in turns (a quarter turn turns a sine into a cosine).
pub fn nco_mut(&mut self) -> &mut Nco
pub fn waveform_mut(&mut self) -> &mut W
Sourcepub fn next_sample(&mut self) -> W::Output
pub fn next_sample(&mut self) -> W::Output
Produces the next output sample.
Sourcepub fn next_sample_modulated(&mut self, offset_hz: f64) -> W::Output
pub fn next_sample_modulated(&mut self, offset_hz: f64) -> W::Output
Produces the next output sample with the frequency offset by offset_hz for this step.
Source§impl NcoSource<PulseTrainWave>
impl NcoSource<PulseTrainWave>
Source§impl NcoSource<TriangleWave>
impl NcoSource<TriangleWave>
Source§impl NcoSource<SineWave>
impl NcoSource<SineWave>
Sourcepub fn sinusoid(frequency_hz: f64, sample_rate: f64) -> Result<Self, ErrorsJSL>
pub fn sinusoid(frequency_hz: f64, sample_rate: f64) -> Result<Self, ErrorsJSL>
A sine source at frequency_hz for the given sampling rate (starting at phase 0).
Source§impl NcoSource<SquareWave>
impl NcoSource<SquareWave>
Source§impl NcoSource<NoiseWave>
impl NcoSource<NoiseWave>
Sourcepub fn white_noise(kind: NoiseKind, seed: u64) -> Self
pub fn white_noise(kind: NoiseKind, seed: u64) -> Self
White noise: an independent value every sample.
Source§impl NcoSource<QuadratureWave>
impl NcoSource<QuadratureWave>
Sourcepub fn quadrature(
frequency_hz: f64,
sample_rate: f64,
polarity: Polarity,
) -> Result<Self, ErrorsJSL>
pub fn quadrature( frequency_hz: f64, sample_rate: f64, polarity: Polarity, ) -> Result<Self, ErrorsJSL>
A quadrature source at frequency_hz using floating-point sin/cos.
Sourcepub fn quadrature_cordic(
frequency_hz: f64,
sample_rate: f64,
polarity: Polarity,
iterations: u32,
) -> Result<Self, ErrorsJSL>
pub fn quadrature_cordic( frequency_hz: f64, sample_rate: f64, polarity: Polarity, iterations: u32, ) -> Result<Self, ErrorsJSL>
A quadrature source whose sine and cosine come from a single 32-bit integer CORDIC pass
with iterations (1 to 30) micro-rotations (accurate to about 1e-8).
Sourcepub fn quadrature_cordic64(
frequency_hz: f64,
sample_rate: f64,
polarity: Polarity,
iterations: u32,
) -> Result<Self, ErrorsJSL>
pub fn quadrature_cordic64( frequency_hz: f64, sample_rate: f64, polarity: Polarity, iterations: u32, ) -> Result<Self, ErrorsJSL>
Like quadrature_cordic but with the 64-bit CORDIC
(iterations 1 to 62; 52 or more reaches double-precision accuracy) driven by the
oscillator’s full 64-bit phase.
Sourcepub fn set_polarity(&mut self, polarity: Polarity)
pub fn set_polarity(&mut self, polarity: Polarity)
Changes the polarity; the phase continues without a jump.
Trait Implementations§
Source§impl<W: Waveform> StreamOperator<(), <W as Waveform>::Output> for NcoSource<W>
Free-running operation: the number of input items is the number of samples produced.
impl<W: Waveform> StreamOperator<(), <W as Waveform>::Output> for NcoSource<W>
Free-running operation: the number of input items is the number of samples produced.
Source§fn process(
&mut self,
data_in: &[()],
) -> Result<Option<Vec<W::Output>>, ErrorsJSL>
fn process( &mut self, data_in: &[()], ) -> Result<Option<Vec<W::Output>>, ErrorsJSL>
Source§fn flush(&mut self) -> Result<Option<Vec<W::Output>>, ErrorsJSL>
fn flush(&mut self) -> Result<Option<Vec<W::Output>>, ErrorsJSL>
Source§impl<W: Waveform> StreamOperator<f64, <W as Waveform>::Output> for NcoSource<W>
Frequency-modulated operation: each input is a frequency offset in Hz for that sample.
impl<W: Waveform> StreamOperator<f64, <W as Waveform>::Output> for NcoSource<W>
Frequency-modulated operation: each input is a frequency offset in Hz for that sample.