wavegen is a wavefrom generator made with 🦀
- Add
wavegento your project:
[dependencies]
wavegen = "0.4"Or, to use the no_std version (custom global allocator is required):
[dependencies]
wavegen = { version = "0.4", default-features = false, features = ["libm"] }- Define a waveform with sampling frequency and function components:
let waveform = wf!(f64, 200., sine!(frequency: 100., amplitude: 10.), dc_bias!(20.));- Turn it into an iterator and sample:
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
- Simple sine
- Two superposed phase-shifted sines
- "Real life" example: 300Hz sine signal with 50Hz interference noise
- Sawtooth
- Superposition of sine + sawtooth
- Square wave
- Superposition of Sine, Square and Sawtooth with different frequencies
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.
- Waver which was the inspiration for this crate
- Braking change in how macros are annotated, changing the annotation form from
frequency = ntofrequency: n
Waveform::get_sample_raterenamed toWaveform::sample_rateand now returns a borrowed values, as per rust API specs.Waveform::get_components_lenremoved. The functionality can be achieved by a new getterWaveform::components.






