From a5d6573ffc517f76e5d2167b4f008a317e673972 Mon Sep 17 00:00:00 2001 From: Divyanshu Raj Date: Sat, 2 May 2020 17:19:46 +0530 Subject: [PATCH 1/2] fixed abnormal behaviour of audio output in p5.signal example --- src/signal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/signal.js b/src/signal.js index 52008c6b..6391089f 100644 --- a/src/signal.js +++ b/src/signal.js @@ -39,7 +39,6 @@ define(function (require) { * text('tap to play', 20, 20); * * carrier = new p5.Oscillator('sine'); - * carrier.start(); * carrier.amp(1); // set amplitude * carrier.freq(220); // set frequency * @@ -58,6 +57,7 @@ define(function (require) { * function canvasPressed() { * userStartAudio(); * carrier.amp(1.0); + * carrier.start(); * } * * function mouseReleased() { From f423ee483714c09d9c3f5031c179bb53ddf6d490 Mon Sep 17 00:00:00 2001 From: Divyanshu Raj Date: Sat, 2 May 2020 20:53:55 +0530 Subject: [PATCH 2/2] added checks to avoid multiple start calls --- src/signal.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/signal.js b/src/signal.js index 6391089f..6830326b 100644 --- a/src/signal.js +++ b/src/signal.js @@ -31,6 +31,7 @@ define(function (require) { * @example *
* let carrier, modulator; + * let hasStarted = false; * * function setup() { * let cnv = createCanvas(100, 100); @@ -57,7 +58,10 @@ define(function (require) { * function canvasPressed() { * userStartAudio(); * carrier.amp(1.0); - * carrier.start(); + * if(!hasStarted){ + * carrier.start(); + * hasStarted = true; + * } * } * * function mouseReleased() {