Skip to content

Instantly share code, notes, and snippets.

@soerface
Created June 3, 2018 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soerface/c7bd151bde9ed73f59d8411baf3b016b to your computer and use it in GitHub Desktop.
Save soerface/c7bd151bde9ed73f59d8411baf3b016b to your computer and use it in GitHub Desktop.
const {random, sin, PI, pow} = Math
this.t += 1 / 44100
const freq = noteNumber => pow(2, (noteNumber-69) / 12) * 440
const lowPass = (name, v, amount) => {
amount = amount ? amount : 1;
const val = (this[name] * amount + v) / (amount + 1)
this[name] = val;
return val;
}
const envelope = lowPass('asdfa', keys.length < 0 ? 1 : 0, 100000000)
return (
sin(2 * PI * this.t * freq((keys[0] || 0))) * knobs.lol * envelope
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment