(context)
| 125 | * @returns {Tuna} A new Tuna instance. |
| 126 | */ |
| 127 | export default function Tuna(context) { |
| 128 | if (!(this instanceof Tuna)) { |
| 129 | return new Tuna(context); |
| 130 | } |
| 131 | |
| 132 | var _window = typeof window === "undefined" ? {} : window; |
| 133 | |
| 134 | if (!_window.AudioContext) { |
| 135 | _window.AudioContext = _window.webkitAudioContext; |
| 136 | } |
| 137 | if (!context) { |
| 138 | console.log("tuna.js: Missing audio context! Creating a new context for you."); |
| 139 | context = _window.AudioContext && (new _window.AudioContext()); |
| 140 | } |
| 141 | if (!context) { |
| 142 | throw new Error("Tuna cannot initialize because this environment does not support web audio."); |
| 143 | } |
| 144 | connectify(context); |
| 145 | userContext = context; |
| 146 | userInstance = this; |
| 147 | } |
| 148 | |
| 149 | function connectify(context) { |
| 150 | if (context.__connectified__ === true) return; |
nothing calls this directly
no test coverage detected