a little shootout between Zig / WASM and JS
run in Chrome (Safari won’t let you use performance.now
without trickery that is beyond me)
by, e.g. serving to localhost
python3 -m http.server
compile the wasm from source by downloading Zig (tested with version 0.12.0) and running
zig build-exe src/main.zig -target wasm32-freestanding -fno-entry -OReleaseFast --export=trianglePTR
you can alter the parameters of the shootout in test.js
, for example the number of samples,
the number of iterations, the frequency, phase input, sample rate, etc.
the function TrianglePTR is an implementation of the Polynomial Transition Region anti-aliasing algorithm to generate an asymmetric triangle wave.