### 3 releases (breaking)

0.3.0 | Oct 12, 2024 |
---|---|

0.2.0 | Aug 7, 2024 |

0.1.0 | Jul 10, 2024 |

#**522** in Math

**710** downloads per month

**MIT**license

490KB

209 lines

# convolution-dsp

1-dimensional convolution library for Rust intended for use in DSP applications. Uses the overlap-add FFT method.

## Planned features

- Input signal
- ☑ Complex32 signals
- ☐ f32 signals

- Filter kernels
- ☑ f32 filter kernels
- ☐ Complex32 filter kernels

- ☐ Use realfft when signal and kernel are both f32
- ☑ f64 support
- ☐ Fallbacks to non-fft convolution when it is faster
- ☑ Full or same length output mode, similar to numpy/scipy
- ☐ Threading
- ☐ Minimize memory allocations
- ☐ Faster than numpy/scipy
- ☐ Re-export num_complex?

## References

Stephen W. Smith, Ph.D., The Scientist and Engineer's Guide to Digital Signal Processing, Chapter 18.

###
`lib.rs`

:

`use` `convolution_dsp``::``{`ConvMode`,` Conv1dPlanner`}``;`
`use` `num_complex``::`Complex32`;`
`let` filter `=` `vec!``[``0.``,` `0.``,` `0.``,` `1.``,` `0.``,` `0.``,` `0.``]``;`
`let` planner `=` `Conv1dPlanner``::`new`(``)``;`
`let` `mut` conv `=` planner`.``plan_conv1d``(``&`filter`,` `ConvMode``::`Same`)``;`
`let` signal `=` `vec!``[``Complex32``::``ONE``;` `1_000_000``]``;`
`let` output `=` conv`.``process``(`signal`)``;`
`assert_eq!``(`output`.``len``(``)``,` `1_000_000``)``;`

#### Dependencies

~3MB

~57K SLoC