Skip to content

Instantly share code, notes, and snippets.

@AvneeshSarwate
Created December 19, 2017 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AvneeshSarwate/5124424b2b64758d6d246c1930b05eb4 to your computer and use it in GitHub Desktop.
Save AvneeshSarwate/5124424b2b64758d6d246c1930b05eb4 to your computer and use it in GitHub Desktop.
Tone.Sequence not running on iOS
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>StartAudioContext</title>
<script type="text/javascript" src="StartAudioContext.js"></script>
<script type="text/javascript" src="Tone.js"></script>
</head>
<body>
<style type="text/css">
.starterButton {
width: 300px;
height: 80px;
line-height: 80px;
margin-left: auto;
margin-right: auto;
text-align: center;
background-color: rgb(204, 204, 204);
margin-top: 100px;
cursor: pointer;
font-family: sans-serif;
position: relative;
font-family: monospace;
}
.starterButton:active {
background-color: #FFB729;
color: white;
}
span {
font-size: 16px;
margin-right: 5px;
font-family: monospace;
}
</style>
<span>STATUS:</span><span id="isStarted">NOT Started</span>
<div class="starterButton">Tap to start the AudioContext</div>
<div id="tonedebug"></div>
<script type="text/javascript">
//create an audio context
window.AudioContext = window.AudioContext || window.webkitAudioContext
var audioContext = new AudioContext()
//set the context
StartAudioContext(audioContext, ".starterButton").then(function(){
document.querySelector("#isStarted").textContent = "Started";
Tone.Transport.start();
seq = new Tone.Sequence(function(time, note){
document.querySelector("#tonedebug").textContent = note;
}, ["C4", ["E4", "G4"], "A4"], "4n");
seq.start();
})
</script>
</body>
</html>
@AvneeshSarwate
Copy link
Author

Basic page using Tone.js and StartAudioContent (for iOS). On Chrome for the desktop and on Android, the note strings appear in the bottom left of the window and update as expected, but in iOS 11 (both Chrome and Safari), the first note is displayed and then it does not change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment