Skip to content

Instantly share code, notes, and snippets.

View scornork's full-sized avatar

scornork scornork

  • Singapore
View GitHub Profile
@scornork
scornork / utils.approximate-sinusoid.js
Last active December 22, 2025 05:04
A modern vanilla ES6+ implementation of a sinusoid approximated from a polynomial expansion of n terms
/**
* @author scornork <22217332+scornork@users.noreply.github.com>
* @see https://gist.github.com/scornork/0206437dd3cf6d7da64e82a4b6fe8cb6
*
* @typedef {Object} SinusoidTraits
* @property {number} [sampleRate=44100] - The overall wave sampling rate in Hz.
* @property {number} [frequency=1000] - The oscillation wave frequency in Hz.
* @property {number} [length=1024] - The total wave samples / buffer size.
* @property {number} [terms=13] - The total polynomial expansion terms.
*