-
-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
documentation of amplitude.disconnect() method #682
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,6 +190,44 @@ class Amplitude { | |
// } | ||
} | ||
|
||
/** | ||
* Disconnects the output of this p5.Amplitude object. | ||
* | ||
* @method disconnect | ||
* @for p5.Amplitude | ||
* @example | ||
* <div><code> | ||
* let sound, amplitude; | ||
* function preload(){ | ||
* sound = loadSound('assets/beat.mp3'); | ||
* } | ||
* | ||
* function setup() { | ||
* let cnv = createCanvas(200, 200); | ||
* cnv.mouseClicked(togglePlay); | ||
* amplitude = new p5.Amplitude(); | ||
* sound.loop(); | ||
* } | ||
* | ||
* function draw() { | ||
* background(220); | ||
* text('Disconnect:', 20, 20); | ||
* let level = amplitude.getLevel(); | ||
* let size = map(level, 0, 1, 0, 400); | ||
* ellipse(width/2, height/2, size, size); | ||
* } | ||
* | ||
* function togglePlay() { | ||
* if (sound.isPlaying()){ | ||
* sound.pause(); | ||
* amplitude.disconnect(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we make a separate button for the disconnect method? |
||
* } | ||
* else{ | ||
* sound.play(); | ||
* } | ||
* } | ||
* </code></div> | ||
*/ | ||
disconnect() { | ||
if (this.output) { | ||
this.output.disconnect(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can make the text "Click to disconnect" so it's clearer you can click anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I do it.