Skip to content

Commit

Permalink
Updating for current Web Audio spec, moving webkit prefix to monkeypa…
Browse files Browse the repository at this point in the history
…tch.
  • Loading branch information
cwilso committed Jul 1, 2013
1 parent db11931 commit 1c40dc3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width user-scalable=no">
<title>Metronome</title>
<link rel="stylesheet" href="css/main.css">
<script src="http://cwilso.github.io/AudioContext-MonkeyPatch/AudioContextMonkeyPatch.js"></script>
<script src="js/metronome.js"></script>
</head>
<body>
Expand Down
12 changes: 8 additions & 4 deletions js/metronome.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ function scheduleNote( beatNumber, time ) {
else // other 16th notes = high pitch
osc.frequency.value = 880.0;

// TODO: Once start()/stop() deploys on Safari and iOS, these should be changed.
osc.noteOn( time );
osc.noteOff( time + noteLength );
osc.start( time );
osc.stop( time + noteLength );
}

function scheduler() {
Expand Down Expand Up @@ -138,7 +137,12 @@ function init(){
canvasContext.strokeStyle = "#ffffff";
canvasContext.lineWidth = 2;

audioContext = new webkitAudioContext();
// NOTE: THIS RELIES ON THE MONKEYPATCH LIBRARY BEING LOADED FROM
// Http://cwilso.github.io/AudioContext-MonkeyPatch/AudioContextMonkeyPatch.js
// TO WORK ON CURRENT CHROME!! But this means our code can be properly
// spec-compliant, and work on Chrome, Safari and Firefox.

audioContext = new AudioContext();

// if we wanted to load audio files, etc., this is where we should do it.

Expand Down

0 comments on commit 1c40dc3

Please sign in to comment.