Public
Edited
Nov 4, 2023
10 stars
Insert cell
Insert cell
Insert cell
Insert cell
data = {
const buffer = new Uint8Array(frames * bins);
const times = new Array(frames);
let offset = 0;
let t0 = Date.now();
while (true) {
analyser.getByteFrequencyData(new Uint8Array(buffer.buffer, offset, bins));
const i = Math.floor(offset / bins);
const now = times[i] = Date.now();
yield { buffer, times, i, fps: 1000 / (now - t0) };
offset = (offset + bins) % buffer.length;
t0 = now;
}
}
Insert cell
Insert cell
frequency = d3
.scaleLinear()
.domain([0, analyser.frequencyBinCount - 1])
.range([0, analyser.context.sampleRate / 2 / 1000])
Insert cell
Insert cell
frames = 140
Insert cell
bins = Math.floor(analyser.frequencyBinCount / 2)
Insert cell
Insert cell
analyser = {
const ctx = new (window.AudioContext || window.webkitAudioContext)();
return ctx
.createMediaStreamSource(microphone)
.connect(new AnalyserNode(ctx, { fftSize: 256, smoothingTimeConstant: 0.2 }));
}
Insert cell
Insert cell
microphone = navigator.mediaDevices.getUserMedia({ audio: true })
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