Skip to content

Commit 1025565

Browse files
committed
Updated aplitude.disconnect() method documentation
1 parent 22928e7 commit 1025565

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/amplitude.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,51 @@ class Amplitude {
190190
// }
191191
}
192192

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+
*/
193238
disconnect() {
194239
if (this.output) {
195240
this.output.disconnect();

0 commit comments

Comments
 (0)