Public
Edited
Nov 4, 2023
1 fork
8 stars
Insert cell
Insert cell
Insert cell
Insert cell
decibels = d3
.scaleLinear()
.domain([0, 255])
.range([analyser.minDecibels, analyser.maxDecibels])
Insert cell
frequency = d3
.scaleLinear()
.domain([0, analyser.frequencyBinCount - 1])
.range([0, analyser.context.sampleRate / 2 / 1000])
Insert cell
Insert cell
data = {
const time = new Uint8Array(analyser.fftSize);
const frequency = new Uint8Array(analyser.frequencyBinCount);
let t0 = Date.now();
while (true) {
analyser.getByteTimeDomainData(time);
analyser.getByteFrequencyData(frequency);
const now = Date.now();
yield { time, frequency, fps: 1000 / (now - t0) };
t0 = now;
}
}
Insert cell
Insert cell
analyser = {
const ctx = new (window.AudioContext || window.webkitAudioContext)();
return ctx
.createMediaStreamSource(stream)
.connect(new AnalyserNode(ctx, { fftSize: 256 }));
}
Insert cell
stream = 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