Synthlet
Audio Sources

Wavetable Oscillator

A morphing wavetable oscillator

@synthlet/wavetable-oscillator

This module implements a wavetable oscillator with morphing compatible with WaveEdit Online wavetable format.

import {
  WavetableOscillator,
  registerWavetableOscillatorWorklet,
  loadWavetable,
} from "@synthlet/wavetable-oscillator";
 
// Register the worklet
const audioContext = new AudioContext();
await registerWavetableOscillatorWorklet(audioContext);
 
// Create the oscillator and connect it to the destination
const osc = WavetableOscillator(audioContext, {
  morphFrequency: 0.1,
});
osc.connect(audioContext.destination);
 
// Load a wavetable
const wavetable = await loadWavetable(audioContext, "SYNLP10");
osc.setWavetable(wavetable);
 
// Change the frequency
osc.frequency.value = 880;

Parameters

  • frequency: The frequency of the oscillator in Hz. Default is 440.
  • morphFrequency: The frequency of the morphing in Hz. Default is 0.

Loading wavetables

This package provides a couple of helper functions to list available wavetables and load them:

import {
  loadWavetable,
  fetchWavetableNames,
} from "@synthlet/wavetable-oscillator";
 
const wavetableNames = await fetchWavetableNames(); // => ["SYNLP10", "SYNLP165",   ...]
 
const wavetable = await loadWavetable(audioContext, "SYNLP10");
 
osc.setWavetable(wavetable);

Wavetables are stored at smpldsnds wavedit repository. The list of available tables is here

On this page