wavegen
is a wavefrom generator made with 🦀
1) Add wavegen
to your project:
toml
[dependencies]
wavegen = "0.2"
Or, to use the no_std version:
toml
[dependencies]
wavegen = { version = "0.2", default-features = false, features = ["libm"] }
2) Define a waveform with sampling frequency and function components:
rust
let wf = Waveform::<f64>::with_components(200.0, vec![
sine!(frequency: 100, amplitude: 10),
dc_bias!(20)
]);
3) Turn it into an iterator and sample:
rust
let some_samples: Vec<f64> = wf.iter().take(200).collect();
Refer to documentation for more exhaustive usage examples.
All above examples are generated with simple program found in examples/plot.rs
. Run cargo run --example plot
to generate them yourself.
0.2 intorduces a braking change in how macros are annotated, changing the annotation form from frequency = n
to frequency: n