Skip to content

Instantly share code, notes, and snippets.

@ElizabethHudnott
ElizabethHudnott / main.js
Created October 25, 2024 22:41
Logic/Arithmetic Operations on Waveforms in wavepot
class Oscillator {
constructor(waveFunction, frequency) {
const tableLength = Math.round(sampleRate / frequency);
const table = new Float32Array(tableLength);
for (let i = 0; i < tableLength; i++) {
table[i] = waveFunction(i / tableLength);
}
this.table = table;
this.period = tableLength / sampleRate;
}
@ElizabethHudnott
ElizabethHudnott / main.js
Last active April 28, 2024 02:00
Phase Distortion Synthesis in wavepot
/*
* Basic implementation of Phase Distortion Synthesis, like as was used in the Casio CZ series.
* By Elizabeth Hudnott.
*/
const TWO_PI = 2 * Math.PI;
const TIME_CONSTANTS = Math.log(2 ** (1023 / 128));
function cosine(phase) {
return -Math.cos(TWO_PI * phase);