Published
Edited
Feb 16, 2018
Importers
Insert cell
Insert cell
audioContext = new (window.AudioContext || window.webkitAudioContext)()
Insert cell
duration = 3
Insert cell
Insert cell
buffer = {
const buffer = audioContext.createBuffer(2, audioContext.sampleRate * duration, audioContext.sampleRate)
for (var channel = 0; channel < buffer.numberOfChannels; channel++) {
const channelData = buffer.getChannelData(channel);
for (var i = 0; i < buffer.length; i++) {
channelData[i] = Math.random() * 2 - 1;
}
}
return buffer
}
Insert cell
source = {
// Get an AudioBufferSourceNode.
// This is the AudioNode to use when we want to play an AudioBuffer
const source = audioContext.createBufferSource();

// set the buffer in the AudioBufferSourceNode
source.buffer = buffer;

// connect the AudioBufferSourceNode to the
// destination so we can hear the sound
// source.connect(audioContext.destination);

// start the source playing
//source.start();
return source
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more