2018-07-30 03:33:15 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>TWO CONTEXTS RUNNING AT ONCE</title>
|
|
|
|
<script src="../../build/Tone.js"></script>
|
|
|
|
|
2018-08-26 23:43:28 +00:00
|
|
|
<script>
|
2018-07-30 03:33:15 +00:00
|
|
|
|
2018-08-26 23:43:28 +00:00
|
|
|
function assert(statement, error){
|
|
|
|
if (!statement){
|
|
|
|
throw new Error(error);
|
|
|
|
}
|
|
|
|
}
|
2018-07-30 03:33:15 +00:00
|
|
|
|
2018-08-26 23:43:28 +00:00
|
|
|
if (Tone && Tone.context){
|
|
|
|
Tone.context.thisisthesamecontext = true;
|
2018-08-27 00:12:10 +00:00
|
|
|
assert(window.TONE_AUDIO_CONTEXT.thisisthesamecontext, "Did not assign global TONE_AUDIO_CONTEXT");
|
2018-08-26 23:43:28 +00:00
|
|
|
} else {
|
|
|
|
throw new Error("NO TONE!");
|
|
|
|
}
|
|
|
|
|
|
|
|
var instanceOne = Tone;
|
|
|
|
</script>
|
2018-07-30 03:33:15 +00:00
|
|
|
|
|
|
|
<script src="../../build/Tone.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
2018-08-26 23:43:28 +00:00
|
|
|
|
|
|
|
<script>
|
|
|
|
if (Tone && Tone.context){
|
2018-08-27 00:12:10 +00:00
|
|
|
assert(window.TONE_AUDIO_CONTEXT === Tone.context, "Did not assign global TONE_AUDIO_CONTEXT 2");
|
2018-08-26 23:43:28 +00:00
|
|
|
assert(Tone.context.thisisthesamecontext, "Not the same AudioContext");
|
|
|
|
} else {
|
|
|
|
throw new Error("NO TONE 2!");
|
|
|
|
}
|
|
|
|
|
|
|
|
var instanceTwo = Tone;
|
|
|
|
|
|
|
|
//additional checks
|
|
|
|
assert(instanceOne !== instanceTwo, "Did not create two instances");
|
|
|
|
assert(instanceOne.context === instanceTwo.context, "Instances don't share the same Tone.Context");
|
|
|
|
assert(instanceOne.context.rawContext === instanceTwo.context.rawContext, "Instances don't share the same AudioContext");
|
|
|
|
</script>
|
2018-07-30 03:33:15 +00:00
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|