Skip to content

Instantly share code, notes, and snippets.

@khoin
Created October 3, 2014 15:21
Show Gist options
  • Save khoin/4e5549bdf3abdb714c42 to your computer and use it in GitHub Desktop.
Save khoin/4e5549bdf3abdb714c42 to your computer and use it in GitHub Desktop.
Some wavepot fiddling
function dsp(t) {
var si = 0.5 * sin(t, 880 * t%2);
var sq = sqr(t,445 + 10 * sin(t, 0.1) ) * (0.5 + si);
return 1*saw(t,sampleRate/(41 + 20 * sin(t, 0.01 )) ) * si + 0.3 * sq;
}
function saw(t,freq) {
return (0.5-((t*sampleRate)%freq)/freq)*1.5 ;
}
function sin(t,f) {
return Math.sin(Math.PI*2*t * f);
}
function sqr (t,f) {
return sin(t,f) > 0 ? 1 : -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment