From 102556559b9e31189dbf1e616d2185c2efe16dd3 Mon Sep 17 00:00:00 2001 From: Nitesh639 Date: Sat, 26 Nov 2022 12:50:28 +0530 Subject: [PATCH 1/3] Updated aplitude.disconnect() method documentation --- src/amplitude.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/amplitude.js b/src/amplitude.js index 34616e18..3a47fdc5 100644 --- a/src/amplitude.js +++ b/src/amplitude.js @@ -190,6 +190,51 @@ class Amplitude { // } } + /** + * Disconnects the output of this p5.Amplitude object. + * + * @method disconnect + * @for p5.Amplitude + * @example + *
+ * let sound, amplitude, button; + * function preload(){ + * sound = loadSound('assets/beat.mp3'); + * } + * + * function setup() { + * let cnv = createCanvas(100, 100); + * cnv.mouseClicked(togglePlay); + * button = createButton(); + * button.mouseClicked(amp_disconnect); + * button.html('tap to disconnect amplitude'); + * button.position(0,100); + * amplitude = new p5.Amplitude(); + * sound.loop(); + * } + * + * function draw() { + * background(220); + * text('tap to play', 20, 20); + * let level = amplitude.getLevel(); + * let size = map(level, 0, 1, 0, 200); + * ellipse(width/2, height/2, size, size); + * } + * + * function togglePlay() { + * if (sound.isPlaying()){ + * sound.pause(); + * } + * else{ + * sound.play(); + * } + * } + * function amp_disconnect(){ + * amplitude.disconnect(); + * button.html('amplitude disconnect now'); + * } + *
+ */ disconnect() { if (this.output) { this.output.disconnect(); From dd89e7ff935266240b873ff239a60a0d4f647edf Mon Sep 17 00:00:00 2001 From: Nitesh639 Date: Mon, 28 Nov 2022 14:35:24 +0530 Subject: [PATCH 2/3] documentation of amplitude.connect() method --- src/amplitude.js | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/amplitude.js b/src/amplitude.js index 3a47fdc5..f11dc978 100644 --- a/src/amplitude.js +++ b/src/amplitude.js @@ -177,6 +177,60 @@ class Amplitude { } } + /** + * Connects the output of a p5.Amplitude object to input of another + * p5.sound object. For example, you may connect a p5.Amplitude to an + * FFT or an Effect. + * + * @method connect + * @for p5.Amplitude + * @param {Object} object Audio object that accepts an input + * @example + *
+ * let sound, amplitude, fft, button; + * function preload(){ + * sound = loadSound('assets/beat.mp3'); + * } + * + * function setup() { + * let cnv = createCanvas(100,100); + * cnv.mouseClicked(togglePlay); + * amplitude = new p5.Amplitude(); + * button = createButton("tap to disconnect amp"); + * button.mouseClicked(amp_disconnect); + * button.position(0,110); + * fft = new p5.FFT(); + * sound.loop(); + * } + * + * function draw() { + * background(220); + * text('tap to play', 20, 20); + * let level = amplitude.getLevel(); + * let size = map(level, 0, 1, 0, 200); + * ellipse(width/2, height/2, size, size); + * } + * + * function togglePlay() { + * if (sound.isPlaying()){ + * sound.pause(); + * } + * else{ + * sound.play(); + * } + * } + * function amp_disconnect(){ + * if (button.html()=="tap to disconnect amp"){ + * amplitude.disconnect(); + * button.html("tap to connect fft"); + * } + * else{ + * amplitude.connect(fft); + * button.html("tap to disconnect amp"); + * } + * } + *
+ */ connect(unit) { if (unit) { if (unit.hasOwnProperty('input')) { From 4f8a454f7c7a35ea2eace606f7ddd1e092b86941 Mon Sep 17 00:00:00 2001 From: Nitesh639 Date: Tue, 6 Dec 2022 03:47:40 +0530 Subject: [PATCH 3/3] documented the getPlaybackRate method in p5.SoundFile --- src/soundfile.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/soundfile.js b/src/soundfile.js index 229c9e0e..76bc0b7f 100644 --- a/src/soundfile.js +++ b/src/soundfile.js @@ -891,6 +891,14 @@ class SoundFile { this.rate(newPlaybackRate); } + /** + * Returns the current playback rate of a sound file. + * + * @method getPlaybackRate + * @for p5.SoundFile + * @return {Number} Current playback rate of the SoundFile. + * + */ getPlaybackRate() { return this.playbackRate; }