wavegen
is a wavefrom generator made with 🦀
1) Add wavegen
to your project:
toml
[dependencies]
wavegen = "0.4"
Or, to use the no_std version (custom global allocator is required):
toml
[dependencies]
wavegen = { version = "0.4", default-features = false, features = ["libm"] }
2) Define a waveform with sampling frequency and function components:
rust
let waveform = wf!(f64, 200, sine!(frequency: 100., amplitude: 10.), dc_bias!(20.));
3) Turn it into an iterator and sample:
rust
let some_samples: Vec<f64> = waveform.iter().take(200).collect();
Refer to documentation for more exhaustive usage examples.
Check out the demo at https://wavegen-demo.netlify.app
All above examples are generated with simple program found in examples/plot.rs
. Run cargo run --example plot
to generate them yourself.
The Minimum Supported Rust Version is 1.60
.
frequency = n
to frequency: n
Waveform::get_sample_rate
renamed to Waveform::sample_rate
and now returns a borrowed values, as per rust API specs.Waveform::get_components_len
removed. The functionality can be achieved by a new getter Waveform::components
.