@@ -190,6 +190,51 @@ class Amplitude {
190
190
// }
191
191
}
192
192
193
+ /**
194
+ * Disconnects the output of this p5.Amplitude object.
195
+ *
196
+ * @method disconnect
197
+ * @for p5.Amplitude
198
+ * @example
199
+ * <div><code>
200
+ * let sound, amplitude, button;
201
+ * function preload(){
202
+ * sound = loadSound('assets/beat.mp3');
203
+ * }
204
+ *
205
+ * function setup() {
206
+ * let cnv = createCanvas(100, 100);
207
+ * cnv.mouseClicked(togglePlay);
208
+ * button = createButton();
209
+ * button.mouseClicked(amp_disconnect);
210
+ * button.html('tap to disconnect amplitude');
211
+ * button.position(0,100);
212
+ * amplitude = new p5.Amplitude();
213
+ * sound.loop();
214
+ * }
215
+ *
216
+ * function draw() {
217
+ * background(220);
218
+ * text('tap to play', 20, 20);
219
+ * let level = amplitude.getLevel();
220
+ * let size = map(level, 0, 1, 0, 200);
221
+ * ellipse(width/2, height/2, size, size);
222
+ * }
223
+ *
224
+ * function togglePlay() {
225
+ * if (sound.isPlaying()){
226
+ * sound.pause();
227
+ * }
228
+ * else{
229
+ * sound.play();
230
+ * }
231
+ * }
232
+ * function amp_disconnect(){
233
+ * amplitude.disconnect();
234
+ * button.html('amplitude disconnect now');
235
+ * }
236
+ * </code></div>
237
+ */
193
238
disconnect ( ) {
194
239
if ( this . output ) {
195
240
this . output . disconnect ( ) ;
0 commit comments