title
A prototype
Generate Random Waveform
const audioContext = new (window.AudioContext || window.webkitAudioContext)(); let currentWaveform; function generateRandomWaveform() { const real = generateRandomArray(); const imag = generateRandomArray(); currentWaveform = { real, imag }; // Play the newly generated waveform for 2 seconds playCustomWaveform(real, imag, 2); } function generateRandomArray(length = 5) { return Array.from({ length }, () => Math.random()); } function createCustomWaveform(real, imag) { const customWaveform = audioContext.createPeriodicWave(real, imag); const oscillator = audioContext.createOscillator(); oscillator.setPeriodicWave(customWaveform); oscillator.connect(audioContext.destination); return oscillator; } function playCustomWaveform(real, imag, duration) { const customWaveformSynth = createCustomWaveform(real, imag); customWaveformSynth.start(); customWaveformSynth.stop(audioContext.currentTime + duration); }
snap
save
new
fork
download
html
css
js
output
gallery
config
➚ link to output
➚ snap player
font size
live reload
snap mode
layout
⤷ switch
★ info and code