Public
Edited
Mar 23, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = d3.range(101).map(x => x / 100).map(x => ({x, y: dampen(x)}))
Insert cell
parameters = ({Cb: n(1), ab: dampen(AB)})
Insert cell
gain = R.pipe(bass(parameters), dB)(frequency)
Insert cell
dampen = R.pipe(unitCircle, tanh, unitCircleInvert)
Insert cell
// transfer function for bass control
// ab = 0: → 100% boost
// ab = 1: → 100% attenuation
bass =
({Cb, ab}) =>
(ƒ) =>
(1 + (µ(650) * (1 - ab)) / (omega(ƒ) * Cb))
/ (1 + (µ(650) * ab) / (omega(ƒ) * Cb))
Insert cell
frequency = 10 // Hz
Insert cell
unitCircle = (x) => (2 * x) - 1 // [0, 1] -> [-1, +1]
// equivalent to d3.scaleLinear().domain([0, 1]).range([-1, +1])
Insert cell
unitCircleInvert = (x) => (x + 1) / 2 // [-1, +1] -> [0, 1]
// equivalent to d3.scaleLinear().domain([0, 1]).range([-1, +1]).invert
Insert cell
tanh = ((slope) => (x) => Math.tanh(slope * x))(slope)
Insert cell
omega = (ƒ) => 2 * Math.PI * ƒ // unit: rad / s
Insert cell
dB = (x) => 20 * Math.log10(x)
Insert cell
// µ, for micro
µ = x => x * 1e-6
Insert cell
// n, for nano
n = (x) => x * 1e-9
Insert cell
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