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 () {
10
10
* 'http://webaudio.github.io/web-audio-api/'>Web Audio API
11
11
* </a>.</p>
12
12
*
13
+ * <p>Some browsers require users to startAudioContext
14
+ * with a user gesture, such as touchStarted in the example below.</p>
15
+ *
13
16
* @method getAudioContext
14
17
* @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>
15
40
*/
16
41
p5 . prototype . getAudioContext = function ( ) {
17
42
return audiocontext ;
You can’t perform that action at this time.
0 commit comments