/ music / double-pendulum
Sign in
music / double-pendulum
double-pendulum / src / instruments / fade.ts
6 lines · 314 BBlameHistoryRaw
1/** Gain curve for a musical fade-out: cos², so -6 dB at the midpoint and the drop concentrated at the end. */
2export function fadeCurve(from: number, n = 128): Float32Array {
3 const c = new Float32Array(n);
4 for (let i = 0; i < n; i++) c[i] = from * Math.cos((Math.PI / 2) * (i / (n - 1))) ** 2;
5 return c;
6}
↑↓ move↵openescclose