http://sdfphd.net/creativepact2010/day20b.html
update:
http://sdfphd.net/creativepact2010/day20c.html ← karplus strong type thing!
I did implement some user controls, but they didn't have very much affect on the sound, so I took a step back to version 'c' and now I'm going to go to sleep...
Here's an extract from code (view source on the page to see it all):
// main functions:
function clicknow()
{
for(var i=0; i< samplesize; i++)
{
envelope[i] = 1 - ( i / samplesize );
clicknoise[i] = envelope[i]*( (2*Math.random()) - 1 );
}
}//end function clicknow()
setInterval(
function()
{
if(active)
{
output.mozWriteAudio( clicknoise );
// apply feedback gain reduction
for(var i=0; i< samplesize; i++)
{ clicknoise[i] *= filterFdbk; }
// simple low pass filter...
for(var i=1; i< samplesize; i++) // start at 1 bcus we call i-1
{ clicknoise[i] += filterCoef*clicknoise[i-1]; }
} //end if(active)
}, periodMs);//end setInterval
No comments:
Post a Comment