function sum(f: (x: number) => number, upper = 500) {
let sum = 0;
for (let n = 0; n < upper; n++) sum += f(n);
return sum;
}
const weierstrass = (x: number, a = 0.5, b = 3) =>
sum(n => a ** n * Math.cos(b ** n * x));
Audio spectrum is bounded, so we are only hearing the first few terms of the series that make up the function (the coefficient under sine grows exponentially with n).
You could even replace the audible part with Chopin (or anything else, even f(x)=0) to get a Weierstrass-like function which sounds like Chopin (or silence) but is still not differentiable anywhere.
I wonder what they sound like as audio.
Edit: apparently it sounds like this https://youtu.be/vWmZnlPQK14