Native, high-performance GNU Octave signal package support in ForgeCurves. Design arbitrary FIR filters, optimal equiripple linear-phase FIR filters, classical analog-prototyped IIR digital filters, and execute high-throughput time-domain filtering and Welch spectral estimation accelerated by Rust WebAssembly.
ForgeCurves provides full algorithmic compatibility with GNU Octave's window-based FIR design routines, combining mathematical sinc pulse synthesis with symmetric time-domain windowing functions:
Designs lowpass, highpass, bandpass, and bandstop filters using truncated sinc impulse responses shaped by standard windows (hamming, hanning, blackman) with exact passband center frequency normalization.
Interpolates piecewise arbitrary amplitude response profiles onto a dense power-of-two frequency grid, followed by an in-place radix-2 complex Inverse FFT and symmetric window application.
The fir2 kernel in Rust WebAssembly delivers up to 375× speedup over pure JavaScript by executing the radix-2 IFFT in linear contiguous memory without heap allocations.
For applications demanding optimal passband flatness, steep transition bands, or equiripple stopband attenuation, ForgeCurves includes analytical least-squares and minimax Chebyshev exchange algorithms:
Calculates the optimal filter coefficients minimizing the weighted integral squared error over specified frequency bands. Assembles a symmetric Toeplitz-plus-Hankel matrix $Q = T + H$ solved via partial-pivoting linear elimination.
Implements the Remez exchange algorithm over dense Chebyshev grids. Employs barycentric Lagrange interpolation to iterate extremal frequency sets until the Chebyshev alternation theorem condition is satisfied.
Estimates minimal filter order $N$, normalized frequency grid $f_o$, amplitude response $a_o$, and band weights $w$ given passband/stopband cutoffs and allowable ripple specifications.
ForgeCurves implements a unified float64 analog prototype synthesis pipeline for the four fundamental classical IIR filter approximations, complete with bilinear transformation and complex polynomial expansion:
| Filter Type | Octave Function | Passband Behavior | Stopband Behavior | Key Characteristic |
|---|---|---|---|---|
| Butterworth | [b, a] = butter(n, Wn, ...) |
Maximally Flat | Monotonic Decay | Smoothest phase response, no passband ripple |
| Chebyshev Type I | [b, a] = cheby1(n, Rp, Wn, ...) |
Equiripple ($R_p\text{ dB}$) | Monotonic Decay | Steeper roll-off than Butterworth for same order |
| Chebyshev Type II | [b, a] = cheby2(n, Rs, Wn, ...) |
Monotonic | Equiripple ($R_s\text{ dB}$) | Flat passband with specified stopband attenuation |
| Elliptic (Cauer) | [b, a] = ellip(n, Rp, Rs, Wn, ...) |
Equiripple ($R_p\text{ dB}$) | Equiripple ($R_s\text{ dB}$) | Steepest possible transition band of any classical filter |
The Elliptic engine evaluates complete elliptic integrals $K(k)$ and Jacobi elliptic functions ($\text{sn}, \text{cn}, \text{dn}$) via iterative Arithmetic-Geometric Mean (AGM) descending Landen transformations.
Supports lowpass ('low'), highpass ('high'), bandpass (two-element [W1, W2]), and bandstop ('stop') mappings in the continuous Laplace $s$-domain.
Maps analog poles and zeros into the discrete $z$-domain using $s = 2(1 - z^{-1})/(1 + z^{-1})$ with tangent pre-warping to eliminate frequency warping distortion.
ForgeCurves supports high-throughput, low-latency digital filtering and non-parametric spectral density estimation fully compatible with GNU Octave:
Standard difference equation digital filter implementing transposed direct form II. Operates across 1D vectors and matrices, supporting continuous state chaining via [y, zf] = filter(b, a, x, zi) without edge discontinuity.
Zero-phase digital filtering that processes data in both forward and reverse directions. Employs Gustafsson companion-matrix initial state solving and \(3 \cdot \max(N_b, N_a)\) edge reflection to eliminate startup and ending transients.
Calculates the average delay of each frequency component using Smith's ramped cross-polynomial FFT algorithm: \(\tau_g(\omega) = \text{Re}(\mathcal{F}\{n \cdot b\} / \mathcal{F}\{b\}) - \text{Re}(\mathcal{F}\{n \cdot a\} / \mathcal{F}\{a\})\).
Power spectral density (PSD) estimation using the modified periodogram and Welch's averaged periodogram with overlapping segmented windowing, executed zero-copy inside WebAssembly linear memory.
Estimates the complex transfer function \(T_{xy}(f) = P_{xy}(f) / P_{xx}(f)\) of linear time-invariant systems from input and output measurements using Welch's averaged cross-spectral method.
Automatically pairs large numeric vectors (up to 1,000,000 samples) with contiguous Float64Array memory buffers, enabling instantaneous zero-copy ingestion into WebAssembly linear memory without garbage collection pauses.
ForgeCurves provides full GNU Octave compatibility for multirate DSP, rational sample rate conversion, pulse train synthesis, and high-performance discrete window generation:
Resamples an input signal by a rational factor p/q using an optimal Kaiser-windowed sinc anti-aliasing lowpass FIR filter with sub-filter polyphase delay compensation.
x = randn(200000, 1); [y, h] = resample(x, 3, 2); % 3/2 rate change % y has length ceil(length(x)*3/2) = 300,000
Upsamples by factor p, applies FIR filter h, and downsamples by factor q using polyphase sub-filter decomposition h[φ + k·p], evaluating zero unnecessary products.
h = fir1(48, 0.4); y = upfirdn(x, h, 3, 2);
Increases sample rate by integer factor r by inserting zeros and applying a symmetric Hamming-windowed sinc lowpass filter with exact delay alignment.
[y, b] = interp(x, 4); % 4x interpolation % Length is exactly length(x) * 4
Direct strided gathering and zero-padding expansion with arbitrary sample phase offsets (0 ≤ phase < factor).
y_dec = downsample(x, 4); % Keep every 4th sample y_exp = upsample(x, 4); % Insert 3 zeros between samples
Synthesizes continuous pulse trains from delay centers and amplitudes using built-in Gaussian RF (gauspuls), rectangular (rectpuls), or triangular (tripuls) pulses, accelerated up to 29.5× in Rust WASM.
t = linspace(0, 1, 50000); d = 0.05:0.05:0.95; % 19 pulse occurrences y = pulstran(t, d, 'gauspuls', 10000, 0.5);
Generates discrete column window vectors with symmetric/periodic phase options. Includes exact modified Bessel I0(β) Kaiser windows and Dolph-Chebyshev (chebwin) equiripple sidelobe windows via in-place radix-2 IFFT.
w_k = kaiser(1024, 8.5); % Bessel I0 window w_c = chebwin(1024, 80); % 80 dB Chebyshev attenuation w_f = flattopwin(1024); % 5-term Flat-top window
Performance measured directly within the ForgeCurves browser runtime across both benchmark_signal_analysis.m (23 configurations) and benchmark_filter_design.m (25 configurations), comparing the Pure TypeScript baseline against compiled Rust WebAssembly:
| Routine & Workload | Configuration / Parameters | Pure TypeScript | Rust WASM | Speedup | Throughput (Rust WASM) |
|---|---|---|---|---|---|
| filter (IIR) | Order = 8, N = 10k | 0.642 ms | 0.898 ms | 0.71× | 11.14 M-samp/s |
| filter (FIR) | Taps = 64, N = 10k | 1.324 ms | 0.981 ms | 1.35× | 10.20 M-samp/s |
| filtfilt (IIR) | Order = 8, N = 10k | 1.287 ms | 0.812 ms | 1.59× | 12.32 M-samp/s |
| filter (IIR) | Order = 8, N = 100k | 11.878 ms | 7.884 ms | 1.51× | 12.68 M-samp/s |
| filter (FIR) | Taps = 64, N = 100k | 17.276 ms | 13.441 ms | 1.29× | 7.44 M-samp/s |
| filtfilt (IIR) | Order = 8, N = 100k | 14.126 ms | 13.247 ms | 1.07× | 7.55 M-samp/s |
| filter (IIR) | Order = 8, N = 1,000,000 | 131.626 ms | 113.501 ms | 1.16× | 8.81 M-samp/s (1M in 113 ms) |
| filter (FIR) | Taps = 64, N = 1,000,000 | 186.689 ms | 177.519 ms | 1.05× | 5.63 M-samp/s |
| filtfilt (IIR) | Order = 8, N = 1,000,000 | 149.720 ms | 126.680 ms | 1.18× | 7.89 M-samp/s |
| grpdelay (IIR) | Nfft = 512 | 0.306 ms | 0.713 ms | 0.43× | 1,403 evals/s |
| grpdelay (FIR-64) | Nfft = 512 | 0.321 ms | 0.185 ms | 1.74× | 5,394 evals/s |
| grpdelay (IIR) | Nfft = 2048 | 0.672 ms | 0.717 ms | 0.94× | 1,394 evals/s |
| grpdelay (FIR-64) | Nfft = 2048 | 0.595 ms | 0.443 ms | 1.34× | 2,257 evals/s |
| grpdelay (IIR) | Nfft = 8192 | 2.485 ms | 2.339 ms | 1.06× | 428 evals/s |
| grpdelay (FIR-64) | Nfft = 8192 | 3.016 ms | 1.994 ms | 1.51× | 501 evals/s |
| periodogram | N = 32k, Default Rect | 3.006 ms | 2.304 ms | 1.30× | 434 runs/s |
| periodogram | N = 32k, Hann 4k | 1.192 ms | 1.162 ms | 1.03× | 860 runs/s |
| pwelch | N = 32k, Win = 1k, Ov = 50% | 4.346 ms | 2.770 ms | 1.57× | 361 runs/s |
| periodogram | N = 128k, Default Rect | 17.057 ms | 18.362 ms | 0.93× | 54 runs/s |
| periodogram | N = 128k, Hann 4k | 2.125 ms | 3.054 ms | 0.70× | 327 runs/s |
| pwelch | N = 128k, Win = 1k, Ov = 50% | 13.410 ms | 9.580 ms | 1.40× | 104 runs/s (255 FFTs in 9.5 ms) |
| tfestimate | N = 32k, Nfft = 2048 | 11.202 ms | 5.977 ms | 1.87× | 167 runs/s (1.87× faster) |
| tfestimate | N = 128k, Nfft = 2048 | 28.202 ms | 19.381 ms | 1.46× | 52 runs/s (510 FFTs in 19.3 ms) |
| Filter Routine | Order / Parameters | Workload Type | Pure TypeScript | Rust WASM | Speedup Factor | Engine Advantage |
|---|---|---|---|---|---|---|
| fir1 | $N = 64$ | Hamming Windowed LP | 0.178 ms | 0.086 ms | 2.07× | Sinc pulse synthesis |
| fir1 | $N = 256$ | Hamming Windowed LP | 0.151 ms | 0.112 ms | 1.35× | Predictable memory execution |
| fir1 | $N = 1024$ | Hamming Windowed LP | 0.399 ms | 0.168 ms | 2.38× | Zero JS GC overhead on large array |
| fir2 | $N = 64$ | Arbitrary Grid Bandpass | 2.327 ms | 0.148 ms | 15.72× | Radix-2 complex IFFT in linear memory |
| fir2 | $N = 256$ | Arbitrary Grid Bandpass | 13.625 ms | 0.197 ms | 69.16× | Avoids dynamic array allocations |
| fir2 | $N = 1024$ | Arbitrary Grid Bandpass | 228.177 ms | 0.608 ms | 375.29× | 375× WASM Speedup |
| firls | $N = 32$ | Least-Squares Lowpass | 0.268 ms | 0.133 ms | 2.02× | Analytical band integration |
| firls | $N = 128$ | Least-Squares Lowpass | 1.096 ms | 0.317 ms | 3.46× | Toeplitz+Hankel matrix assembly |
| firls | $N = 512$ | Least-Squares Lowpass | 15.395 ms | 4.903 ms | 3.14× | $257 \times 257$ linear matrix solver |
| firpmord | $[0.3, 0.4], [1, 0]$ | Order Estimation | 0.143 ms | 0.099 ms | 1.44× | Closed-form scalar formula |
| firpm | $N = 32$ | Equiripple Remez Lowpass | 0.130 ms | 0.150 ms | 0.87× | Parity (call boundary overhead) |
| firpm | $N = 64$ | Equiripple Remez Lowpass | 0.160 ms | 0.247 ms | 0.65× | Barycentric Lagrange evaluation |
| firpm | $N = 128$ | Equiripple Remez Lowpass | 0.458 ms | 0.626 ms | 0.73× | Converges in < 25 Remez cycles |
| butter | Order = 4 | Butterworth Lowpass | 0.123 ms | 0.085 ms | 1.45× | Bilinear transform & pre-warping |
| butter | Order = 8 | Butterworth Lowpass | 0.117 ms | 0.082 ms | 1.43× | Polynomial expansion `poly` |
| butter | Order = 16 | Butterworth Lowpass | 0.219 ms | 0.087 ms | 2.52× | Float64 root expansion stability |
| cheby1 | Order = 4, $R_p = 1\text{ dB}$ | Chebyshev Type I | 0.124 ms | 0.109 ms | 1.14× | Hyperbolic pole placement |
| cheby1 | Order = 8, $R_p = 1\text{ dB}$ | Chebyshev Type I | 0.123 ms | 0.092 ms | 1.34× | Bilinear frequency mapping |
| cheby1 | Order = 16, $R_p = 1\text{ dB}$ | Chebyshev Type I | 0.131 ms | 0.101 ms | 1.30× | Continuous-to-discrete conversion |
| cheby2 | Order = 4, $R_s = 40\text{ dB}$ | Chebyshev Type II | 0.131 ms | 0.108 ms | 1.21× | Inverse pole & zero placement |
| cheby2 | Order = 8, $R_s = 40\text{ dB}$ | Chebyshev Type II | 0.132 ms | 0.095 ms | 1.39× | Passband gain normalization |
| cheby2 | Order = 16, $R_s = 40\text{ dB}$ | Chebyshev Type II | 0.121 ms | 0.126 ms | 0.96× | Parity across high orders |
| ellip | Order = 4, $R_p=1, R_s=40$ | Elliptic Cauer | 0.142 ms | 0.121 ms | 1.17× | Landen AGM complete elliptic integrals |
| ellip | Order = 8, $R_p=1, R_s=40$ | Elliptic Cauer | 0.153 ms | 0.155 ms | 0.99× | Complex Jacobi sn, cn, dn functions |
| ellip | Order = 16, $R_p=1, R_s=40$ | Elliptic Cauer | 0.182 ms | 0.182 ms | 1.00× | Root expansion precision |
| firpm (Stress) | $N = 256$, 3 bands | Multi-Band Equiripple | 2.713 ms | 2.834 ms | 0.96× | Iterative convergence over dense grid |
| firls (Stress) | $N = 1024$ | Toeplitz Matrix Solve | 136.261 ms | 43.529 ms | 3.13× | 513 × 513 Solve in 43.5 ms |
| ellip (Stress) | Order = 24 Bandpass | High-Order IIR Stress | 0.233 ms | 0.151 ms | 1.54× | 48 Poles & 48 Zeros in 0.15 ms |
| Routine & Workload | Configuration / Parameters | Pure TypeScript | Rust WASM | Speedup | Throughput (Rust WASM) |
|---|---|---|---|---|---|
| downsample | N = 100k, factor = 4 | 0.598 ms | 0.445 ms | 1.34× | 224.90 M-samp/s |
| downsample | N = 1,000k, factor = 4 | 4.136 ms | 3.891 ms | 1.06× | 257.00 M-samp/s |
| interp | N = 10k, factor = 4 | 1.863 ms | 1.559 ms | 1.19× | 6.41 M-samp/s |
| interp | N = 100k, factor = 4 | 16.953 ms | 11.717 ms | 1.45× | 8.53 M-samp/s |
| upfirdn | N = 50k, P = 3, Q = 2, 49 taps | 5.320 ms | 3.825 ms | 1.39× | 13.07 M-samp/s |
| upfirdn | N = 250k, P = 3, Q = 2, 49 taps | 22.754 ms | 12.090 ms | 1.88× | 20.68 M-samp/s |
| resample | N = 50k, P = 3, Q = 2 | 5.183 ms | 4.118 ms | 1.26× | 12.14 M-samp/s |
| resample | N = 200k, P = 3, Q = 2 | 19.200 ms | 15.155 ms | 1.27× | 13.20 M-samp/s |
| pulstran (gauspuls) | 50k pts, 19 Gaussian pulses | 181.098 ms | 6.137 ms | 29.50× | 162.94 runs/s (29.5× Speedup) |
| kaiser | L = 1,024, β = 8.5 | 0.327 ms | 0.102 ms | 3.21× | 10.00 M-pts/s |
| chebwin | L = 1,024, r = 80 dB | 1.010 ms | 0.202 ms | 5.00× | 5.06 M-pts/s |
| chebwin | L = 65,536, r = 80 dB | 9.656 ms | 6.033 ms | 1.60× | 10.86 M-pts/s |
| chebwin | L = 1,048,576 (220), r = 80 dB | 216.145 ms | 228.261 ms | 0.95× | 4.59 M-pts/s (Radix-2 IFFT) |
| hamming / hanning | L = 1,048,576 (220) | 24.386 ms | 27.324 ms | 0.89× | 38.38 M-pts/s (Lazy _f64 Proxy) |
ForgeCurves employs a resilient dual-engine execution strategy that guarantees instant execution in any modern browser without external dependencies:
Compute kernels execute inside a pre-allocated 64-bit float linear memory buffer. Numerical arrays are passed via 32-bit byte offset pointers, eliminating JavaScript-to-WASM serialization latency.
Every filter routine has an exact, bit-compatible Pure TypeScript baseline implementation in src/kernel/packages/signal.ts, guaranteeing 100% functionality even in constrained environments where WebAssembly is unavailable.
The Octave kernel parser natively handles multi-output syntax like [b, a] = butter(...) and [n, fo, ao, w] = firpmord(...), automatically assigning return arrays to individual workspace variables.
All signal processing routines, fast Fourier transforms, Jacobi elliptic functions, and linear algebra solvers run entirely inside client-side browser memory with zero network traffic.
The table below summarizes the 25 core digital signal processing routines ported to Rust WebAssembly (crates/octave-wasm-math/src/signal_kernels.rs), including their mathematical domain, original GNU Octave / Fortran implementation language, and key computational capabilities:
| Function | Mathematical Domain | Original Language | Rust Kernel Function | Algorithmic Implementation & Capabilities |
|---|---|---|---|---|
fir1 |
Windowed Linear-Phase FIR | Octave M-code / C++ | fir1_kernel |
Truncated sinc impulse response synthesis with standard window multiplication (Hamming, Hann, Blackman) and passband center frequency normalization. |
fir2 |
Frequency Sampling FIR | Octave M-code / C++ | fir2_kernel |
Piecewise linear frequency grid interpolation followed by in-place radix-2 complex Inverse FFT and symmetric window application (up to 375× speedup). |
firls |
Least-Squares FIR | Fortran 77 / C++ | firls_kernel |
Unconstrained weighted least-squares integral minimization via symmetric Toeplitz-plus-Hankel system assembly and Gaussian elimination. |
firpm (remez) |
Minimax Equiripple FIR | Fortran 77 (Parks-McClellan) | firpm_kernel |
Iterative Remez exchange algorithm finding Chebyshev equiripple polynomials on dense grid with Lagrange barycentric interpolation. |
butter |
Maximally Flat IIR | Octave M-code / C++ | butter_kernel |
Maximally flat magnitude Butterworth analog s-plane prototype transformed to discrete z-plane via Bilinear Transform with frequency pre-warping. |
cheby1 |
Chebyshev Type I IIR | Octave M-code / C++ | cheby1_kernel |
Chebyshev Type I analog prototype with exact user-specified passband ripple ε = √(10Rp/10 - 1) and Bilinear Transform mapping. |
cheby2 |
Chebyshev Type II IIR | Octave M-code / C++ | cheby2_kernel |
Inverse Chebyshev prototype with monotonic passband, stopband equiripple zeros on imaginary axis, and Bilinear Transform pole-zero mapping. |
ellip |
Cauer Equiripple IIR | Octave M-code / C++ | ellip_kernel |
Elliptic (Cauer) filter synthesis via complete elliptic integrals K(k) and Jacobi elliptic functions sn(u, k) for sharpest transition roll-off. |
filter |
Time-Domain Digital Filtering | C++ / Octave core | filter_kernel |
Direct-Form II Transposed difference equation running in contiguous linear memory (up to 12.68 M-samples/s). |
filtfilt |
Zero-Phase Forward-Backward | Octave M-code / C++ | filtfilt_kernel |
Forward-backward filtering yielding zero phase distortion, with Gustafsson reflective transient edge initialization. |
grpdelay |
Group Delay Analysis | Octave M-code / C++ | grpdelay_kernel |
Negative derivative of phase response computed via differentiated polynomial quotient evaluation. |
periodogram |
Non-Parametric Spectral PSD | Octave M-code / C++ | periodogram_kernel |
Normalized squared magnitude discrete Fourier transform with window power normalization. |
pwelch |
Welch Averaged Periodogram | Octave M-code / C++ | pwelch_kernel |
Modified periodogram averaging across overlapping windowed segments to reduce spectral variance (up to 104 runs/s). |
tfestimate |
Cross-Spectral Transfer Function | Octave M-code / C++ | tfestimate_kernel |
Empirical transfer function estimate computed from averaged auto- and cross-power spectral densities. |
resample |
Rational Polyphase Resampling | Octave M-code / C++ | resample_kernel |
Rational factor P/Q sampling rate conversion using polyphase Kaiser-windowed anti-aliasing lowpass filters (27.6 M-points/s). |
upfirdn |
Polyphase Multirate FIR | C++ (GNU Octave) | upfirdn_kernel |
Upsample by P, apply FIR coefficients, and downsample by Q in a single combined polyphase loop without intermediate allocation. |
interp |
Lowpass Interpolation | Octave M-code | interp_kernel |
Zero-insertion integer rate expansion by factor R followed by symmetric lowpass FIR filtering with unity passband gain. |
downsample |
Integer Decimation | Octave M-code | downsample_kernel |
Strided decimation retaining every N-th sample starting at user-specified phase offset without allocation overhead. |
pulstran |
Pulse Train Synthesis | Octave M-code / C++ | pulstran_kernel |
Continuous-time and discrete pulse train generator supporting Gaussian RF pulses (gauspuls), rectangular, and triangular pulses (29.5× speedup). |
hamming |
Hamming Window | Octave M-code / C++ | hamming_kernel |
Generalized cosine window with transparent lazy _f64 proxy vectors for 106 points. |
hanning / hann |
Hann Window | Octave M-code / C++ | hanning_kernel |
Symmetric cosine taper with zero-valued endpoints. |
blackman |
Blackman Window | Octave M-code / C++ | blackman_kernel |
Three-term cosine window yielding −58 dB sidelobes. |
flattopwin |
Flat-Top Window | Octave M-code / C++ | flattopwin_kernel |
Five-term cosine window engineered for minimum scallop loss and high-precision calibration peak amplitude measurement. |
kaiser |
Kaiser-Bessel Window | Fortran 77 / C++ | kaiser_kernel |
Near-optimal prolate spheroidal window parameterized by shape parameter β, evaluated using zeroth-order modified Bessel I0(x). |
chebwin |
Dolph-Chebyshev Window | Octave M-code / C++ | chebwin_kernel |
Minimum mainlobe width for a specified uniform sidelobe attenuation r dB, computed via inverse Chebyshev polynomial evaluation and radix-2 IFFT. |