Created
June 22, 2014 18:58
-
-
Save ahmattox/12fced48b940199f3031 to your computer and use it in GitHub Desktop.
Wavepot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dsp(t) { | |
// return sinOsc(t, 220, .5); | |
return .3 * saw(t, 220, 4, .5) + saw(t, 221, 4, .5); | |
// return 0.1 * Math.sin(2 * Math.PI * t * 440); | |
} | |
function saw(time, frequency, octaves, falloff) { | |
value = 0; | |
for (var i = 0; i < octaves; i++) { | |
f = frequency * (i + 1); | |
a = .5 / (Math.pow(2, i)) | |
value += osc(time, f, a); | |
} | |
return value; | |
} | |
function osc(time, frequency, amplitude) { | |
return amplitude * Math.sin(2 * Math.PI * time * frequency); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment