Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <script src="lfo.js"></script>
- <script>
- window.audiocontext = window.audiocontext || new AudioContext();
- /**
- * Example: Gain modulation ('Tremolo' effect)
- */
- var sawOsc = audiocontext.createOscillator();
- var sawGain = audiocontext.createGain();
- sawOsc.type = 'saw';
- sawOsc.frequency.value = 440;
- sawGain.gain.value = 0.5;
- var lfo1 = new LFO({
- targetParam: sawGain.gain,
- context: audiocontext,
- frequency: 5,
- amplitude: 0.5
- });
- sawOsc.connect(sawGain);
- sawGain.connect(audiocontext.destination);
- //lfo1.start();
- //sawOsc.start();
- /**
- * Example: Frequency modulation
- */
- var sineOsc = audiocontext.createOscillator();
- sineOsc.type = 'sine';
- sineOsc.frequency.value = 440;
- var lfo2 = new LFO({
- targetParam: sineOsc.frequency,
- context: audiocontext,
- frequency: 1,
- amplitude: 100
- });
- sineOsc.connect(audiocontext.destination);
- //lfo2.start();
- //sineOsc.start();
- //lfo2.frequency = 0.3
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement