Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <html>
  2. <body>
  3. <script src="lfo.js"></script>
  4. <script>
  5. window.audiocontext = window.audiocontext || new AudioContext();
  6.  
  7. /**
  8. * Example: Gain modulation ('Tremolo' effect)
  9. */
  10. var sawOsc = audiocontext.createOscillator();
  11. var sawGain = audiocontext.createGain();
  12.  
  13. sawOsc.type = 'saw';
  14. sawOsc.frequency.value = 440;
  15.  
  16. sawGain.gain.value = 0.5;
  17.  
  18. var lfo1 = new LFO({
  19. targetParam: sawGain.gain,
  20. context: audiocontext,
  21. frequency: 5,
  22. amplitude: 0.5
  23. });
  24.  
  25. sawOsc.connect(sawGain);
  26. sawGain.connect(audiocontext.destination);
  27.  
  28. //lfo1.start();
  29. //sawOsc.start();
  30.  
  31.  
  32. /**
  33. * Example: Frequency modulation
  34. */
  35. var sineOsc = audiocontext.createOscillator();
  36.  
  37. sineOsc.type = 'sine';
  38. sineOsc.frequency.value = 440;
  39.  
  40.  
  41. var lfo2 = new LFO({
  42. targetParam: sineOsc.frequency,
  43. context: audiocontext,
  44. frequency: 1,
  45. amplitude: 100
  46. });
  47.  
  48. sineOsc.connect(audiocontext.destination);
  49.  
  50. //lfo2.start();
  51. //sineOsc.start();
  52.  
  53. //lfo2.frequency = 0.3
  54.  
  55. </script>
  56. </body>
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement