Crate basic_dsp [] [src]

Basic digital signal processing (DSP) operations

Digital signal processing based on real or complex vectors in time or frequency domain. Vectors are expected to typically have a size which is at least in the order of magnitude of a couple of thousand elements. This crate tries to balance between a clear API and performance in terms of processing speed. This project started as small pet project to learn more about DSP, CPU architecture and Rust. Since learning involves making mistakes, don't expect things to be flawless or even close to flawless.

This library isn't suited - from my point of view - for game programming. If you are looking for vector types to do 2D or 3D graphics calculations then you unfortunately have to continue with your search. However there seem to be a lot of suitable crates on crates.io for you.

The vector types don't distinguish between 1xN or Nx1. This is a difference to other conventions such as in MATLAB or GNU Octave. The reason for this decision is that it seems to be more practical to ignore the shape of the vector.

Right now the library uses pretty aggressive parallelization. So this means that it will keep all CPU cores busy even if the performance gain is minimal e.g. because the multi core overhead is nearly as large as the performance boost of multiple cores. In future there will be likely an option which tells the library how it should balance between processing time and CPU utilization. The library also avoids to allocate and free memory and it allocates memory for temporary allocation. so the library is likely not suitable for devices which are tight on memory. On normal desktop computers there is usually plenty of memory available so that the optimization focus is on decreasing the processing time for every (common) operation and to spent little time with memory allocations.

Modules

combined_ops

This module allows to combine certain operations into one operation. Since one many machines the speed of many DSP operations is limited by the memory bus speed this approach may result in better register and cache usage and thus decrease the pressure on the memory bus. As with all performance hints remember rule number 1: Benchmark your code. This is especially true at this very early state of the library.

conv_types

Types around a convolution, see also https://en.wikipedia.org/wiki/Convolution.

interop_facade

Clients using other programming languages should use the functions in this mod. Please refer to the other chapters of the help for documentation of the functions.

window_functions

This mod contains a definition for window functions and provides implementations for a few standard windows. See the WindowFunction type for more information.

Macros

try_vec!

Like try! but for operations returning a vector.

Structs

ComplexFreqVector

A 1xN (one times N elements) or Nx1 data vector as used for most digital signal processing (DSP) operations. All data vector operations consume the vector they operate on and return a new vector. A consumed vector must not be accessed again.

ComplexTimeVector

A 1xN (one times N elements) or Nx1 data vector as used for most digital signal processing (DSP) operations. All data vector operations consume the vector they operate on and return a new vector. A consumed vector must not be accessed again.

GenericDataVector

A 1xN (one times N elements) or Nx1 data vector as used for most digital signal processing (DSP) operations. All data vector operations consume the vector they operate on and return a new vector. A consumed vector must not be accessed again.

MultiCoreSettings

Holds parameters which specify how multiple cores are used to execute an operation.

RealFreqVector

A 1xN (one times N elements) or Nx1 data vector as used for most digital signal processing (DSP) operations. All data vector operations consume the vector they operate on and return a new vector. A consumed vector must not be accessed again.

RealTimeVector

A 1xN (one times N elements) or Nx1 data vector as used for most digital signal processing (DSP) operations. All data vector operations consume the vector they operate on and return a new vector. A consumed vector must not be accessed again.

Statistics

Statistics about the data in a vector

Enums

DataVectorDomain

The domain of a data vector

ErrorReason

Enumeration of all error reasons

PaddingOption

An option which defines how a vector should be padded

Traits

ComplexVectorOps

Defines all operations which are valid on DataVectors containing complex data.

Convolution

Provides a convolution operation for data vectors.

CrossCorrelation

Cross-correlation of data vectors. See also https://en.wikipedia.org/wiki/Cross-correlation

DataVector

DataVector gives access to the basic properties of all data vectors

DotProductOps

An operation which multiplies each vector element with a constant

FrequencyDomainOperations

Defines all operations which are valid on DataVectors containing frequency domain data.

FrequencyMultiplication

Provides a frequency response multiplication operation for data vectors.

GenericVectorOps

Defines all operations which are valid on all DataVectors.

Interpolation

Provides interpolation operations for real and complex data vectors.

OffsetOps

An operation which adds a constant to each vector element

RealInterpolation

Provides interpolation operations which are only applicable for real data vectors.

RealNumber

A real floating pointer number intended to abstract over f32 and f64.

RealVectorOps

Defines all operations which are valid on DataVectors containing real data.

RededicateVector

This trait allows to change a vector type. The operations will convert a vector to a different type and set self.len() to zero. However self.allocated_len() will remain unchanged. The use case for this is to allow to reuse the memory of a vector for different operations.

ScaleOps

An operation which multiplies each vector element with a constant

StatisticsOps

Calculates the statistics of the data contained in the vector.

SymmetricFrequencyDomainOperations

Defines all operations which are valid on DataVectors containing frequency domain data and the data is assumed to half of complex conjugate symmetric spectrum round 0 Hz where the 0 Hz element itself is real.

SymmetricTimeDomainOperations

Defines all operations which are valid on DataVectors containing real time domain data.

TimeDomainOperations

Defines all operations which are valid on DataVectors containing time domain data.

VectorConvolution

Provides a convolution operation for data vectors with data vectors.

VectorIter

Operations which allow to iterate over the vector and to derive results or to change the vector.

Type Definitions

ComplexFreqVector32

Specialization of a vector for a certain data type.

ComplexFreqVector64

Specialization of a vector for a certain data type.

ComplexTimeVector32

Specialization of a vector for a certain data type.

ComplexTimeVector64

Specialization of a vector for a certain data type.

DataVector32

Specialization of a vector for a certain data type.

DataVector64

Specialization of a vector for a certain data type.

RealFreqVector32

Specialization of a vector for a certain data type.

RealFreqVector64

Specialization of a vector for a certain data type.

RealTimeVector32

Specialization of a vector for a certain data type.

RealTimeVector64

Specialization of a vector for a certain data type.

VecResult

Result contains on success the vector. On failure it contains an error reason and an vector with invalid data which still can be used in order to avoid memory allocation.

VoidResult

Void/nothing in case of success or a reason in case of an error.