File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,33 @@ define(function () {
1010 * 'http://webaudio.github.io/web-audio-api/'>Web Audio API
1111 * </a>.</p>
1212 *
13+ * <p>Some browsers require users to startAudioContext
14+ * with a user gesture, such as touchStarted in the example below.</p>
15+ *
1316 * @method getAudioContext
1417 * @return {Object } AudioContext for this sketch
18+ * @example
19+ * <div><code>
20+ * function draw() {
21+ * background(255);
22+ * textAlign(CENTER);
23+ *
24+ * if (getAudioContext().state !== 'running') {
25+ * text('click to start audio', width/2, height/2);
26+ * } else {
27+ * text('audio is enabled', width/2, height/2);
28+ * }
29+ * }
30+ *
31+ * function touchStarted() {
32+ * if (getAudioContext().state !== 'running') {
33+ * getAudioContext().resume();
34+ * }
35+ * var synth = new p5.MonoSynth();
36+ * synth.play('A4', 0.5, 0, 0.2);
37+ * }
38+ *
39+ * </div></code>
1540 */
1641 p5 . prototype . getAudioContext = function ( ) {
1742 return audiocontext ;
You can’t perform that action at this time.
0 commit comments