Skip to content

Instantly share code, notes, and snippets.

@fluffy
Created December 26, 2013 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fluffy/8136414 to your computer and use it in GitHub Desktop.
Save fluffy/8136414 to your computer and use it in GitHub Desktop.
Simple web audio demo send3
<!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