Created
December 26, 2013 17:30
-
-
Save fluffy/8136414 to your computer and use it in GitHub Desktop.
Simple web audio demo send3
This file contains 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
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
<html> <head> | |
<title>Send 3</title> | |
<script> | |
function play() | |
{ | |
var contextClass = (window.AudioContext | |
|| window.webkitAudioContext | |
|| window.mozAudioContext | |
|| window.oAudioContext | |
|| window.msAudioContext); | |
if (contextClass) { | |
var context = new contextClass(); | |
} else { | |
alert('Browser does not support webAudio. Try Firefox or Chrome'); | |
} | |
var symbolTime = 0.032; // 0.032; | |
var transitionTime = 0.008; // 0.008; | |
var frequency = 1100; | |
var osc = context.createOscillator(); | |
osc.frequency.value = frequency; | |
osc.type = 'sine'; | |
// osc.onended | |
gain = context.createGain(); | |
gain.gain.value = 0.0; | |
osc.connect( gain ) | |
gain.connect( context.destination ); | |
var time = context.currentTime; | |
gain.gain.setValueAtTime( 0, time ); | |
osc.start( time ); | |
osc.stop( time+5.0 ); | |
time += 0.050; | |
gain.gain.setValueAtTime( 0, time ); | |
gain.gain.linearRampToValueAtTime( 0.5, time + 0.008 ); | |
gain.gain.setValueAtTime( 0.5, time + 0.032 - 0.008 ); | |
gain.gain.linearRampToValueAtTime( 0.0, time+0.032 ); | |
} | |
window.onload = play; | |
</script> | |
</head> | |
<body> | |
<h1>Send 3</h1> | |
<!-- hhmts start -->Last modified: Thu Dec 26 10:02:54 MST 2013 <!-- hhmts end --> | |
</body> </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment