Want more features on Pastebin? Sign Up, it's FREE!
Guest

satan's bagpipes

By: a guest on Jul 2nd, 2014  |  syntax: JavaScript  |  size: 0.88 KB  |  views: 502  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.        
  2.     // wavepot.com
  3.     // satan's bagpipes - justaboutdead
  4.     var volume = 0.666;
  5.      
  6.     var pitch = 0.666;
  7.      
  8.     var chorus;
  9.     var voices = 6;
  10.     var separation = 0.00666;
  11.     var detune = 666.666;
  12.      
  13.     function dsp(t){
  14.       chorus = 0;
  15.       for(i = 0; i < voices; i++){
  16.         chorus += (1 / voices) * $(pitch + (detune * i), t + (i * separation));
  17.       }
  18.       return volume * chorus;
  19.     }
  20.        
  21.          
  22.     var tau = 2 * Math.PI;
  23.      
  24.     function $(n, t){
  25.       return sub(0.666 * tri(n, t) + 0.0666 * sin(n * 666, t), (1 + sin(666, t)) * (2 + (1 + sin(666, t)) * 1), t);
  26.     }
  27.      
  28.     function sub(wave, mul, t){
  29.       return Math.sin(wave * mul + tau * t);
  30.     }
  31.      
  32.     function sin(x, t){
  33.       return Math.sin(tau * t * x);
  34.     }
  35.      
  36.     function tri(x, t){
  37.       return Math.abs(1 - (2 * t * x) % 2) * 2 - 1;
  38.     }
clone this paste RAW Paste Data