Skip to main content

Module math

Module math 

Source
Expand description

§Mathematical abstractions and utilities for DSP

This module combines:

  • Numeric types (Transcendental) for f32/f64 abstraction
  • Conversion between linear scales and dB
  • Fast math functions (tanh, sin, exp)
  • Signal generation (sine, saw, square)
  • Window functions for granular synthesis
  • Interpolation and smoothing

Structs§

Smoother
Exponential smoothing (one-pole filter)

Functions§

blackman_window
Blackman window
cubic_interpolate
Cubic interpolation (Hermite)
db_to_linear
Convert decibels to linear coefficient
fast_exp
Fast exponential approximation (Padé approximant)
fast_sin
Fast sine approximation (Taylor series)
fast_tanh
Fast tanh approximation (Padé approximant)
freq_to_midi
Convert frequency to MIDI note
hamming_window
Hamming window
hann_window
Hann window
lagrange_interpolate
Least-squares interpolation (for fractional delays)
lerp
Linear interpolation
linear_to_db
Convert linear coefficient to decibels
midi_to_freq
Convert MIDI note to frequency
samples_to_seconds
Convert samples to seconds
saw_phase
Generate sawtooth wave (phase 0..1)
seconds_to_samples
Convert seconds to samples
sine_phase
Generate sine wave (phase 0..1)
soft_clip
Soft clipping (wave shaping)
square_phase
Generate square wave (phase 0..1, pulse_width 0..1)
triangle_phase
Generate triangle wave (phase 0..1)
variable_window
Variable-shape window (0 = rectangular, 1 = Hann)