wavegen 0.2.1

Wavefrom generator library
Documentation

wavegen

Crates.io docs Bors enabled

wavegen is a wavefrom generator made with 🦀

How to use it?

  1. Add wavegen to your project:
[dependencies]
wavegen = "0.2"

Or, to use the no_std version:

[dependencies]
wavegen = { version = "0.2", default-features = false, features = ["libm"] }
  1. Define a waveform with sampling frequency and function components:
let wf = Waveform::<f64>::with_components(200.0, vec![
        sine!(frequency: 100, amplitude: 10),
        dc_bias!(20)
    ]);
  1. Turn it into an iterator and sample:
let some_samples: Vec<f64> = wf.iter().take(200).collect();

Refer to documentation for more exhaustive usage examples.

Show me some examples!

  • Simple sine

Sine plot

  • Two superposed phase-shifted sines

Superposed sines plot

  • "Real life" example: 300Hz sine signal with 50Hz interference noise

300_50_hz_sines

  • Sawtooth

Sawtooth plot

  • Superposition of sine + sawtooth

Sine and sawtooth superposed

  • Square wave

Square wave

  • Superposition of Sine, Square and Sawtooth with different frequencies

Something funky

All above examples are generated with simple program found in examples/plot.rs. Run cargo run --example plot to generate them yourself.

Similar crates

  • Waver which was the inspiration for this crate

Breaking changes

0.2

0.2 intorduces a braking change in how macros are annotated, changing the annotation form from frequency = n to frequency: n