import memoize from 'lodash/memoize';

export const pitchToHz = memoize((pitch: number) => 440 * Math.pow(2, (pitch - 57)/12));
export const modulo = (n: number, m: number) => ((n % m) + m) % m;
export const clampZeroOne = (input: number) => Math.max(0, Math.min(1, input));
export const zeroOneToHz = (input: number) => 20 * Math.pow(2, input * (Math.log(20000 / 20) / Math.log(2)))
