Skip to content

Commit c3065de

Browse files
author
piersh
committed
move loadSound calls in examples to preload
1 parent 5a01ad1 commit c3065de

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/peakDetect.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,19 @@ define(function () {
4848
* var cnv, soundFile, fft, peakDetect;
4949
* var ellipseWidth = 10;
5050
*
51+
* function preload() {
52+
* soundFile = loadSound('assets/beat.mp3');
53+
* }
54+
*
5155
* function setup() {
5256
* background(0);
5357
* noStroke();
5458
* fill(255);
5559
* textAlign(CENTER);
5660
*
57-
* soundFile = loadSound('assets/beat.mp3');
58-
*
5961
* // p5.PeakDetect requires a p5.FFT
6062
* fft = new p5.FFT();
6163
* peakDetect = new p5.PeakDetect();
62-
*
6364
* }
6465
*
6566
* function draw() {
@@ -179,11 +180,14 @@ define(function () {
179180
* var cnv, soundFile, fft, peakDetect;
180181
* var ellipseWidth = 0;
181182
*
183+
* function preload() {
184+
* soundFile = loadSound('assets/beat.mp3');
185+
* }
186+
*
182187
* function setup() {
183188
* cnv = createCanvas(100,100);
184189
* textAlign(CENTER);
185190
*
186-
* soundFile = loadSound('assets/beat.mp3');
187191
* fft = new p5.FFT();
188192
* peakDetect = new p5.PeakDetect();
189193
*

src/soundfile.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,8 @@ define(function (require) {
451451
* @param {String} str 'restart' or 'sustain' or 'untilDone'
452452
* @example
453453
* <div><code>
454-
* function setup(){
454+
* var mySound;
455+
* function preload(){
455456
* mySound = loadSound('assets/Damscray_DancingTiger.mp3');
456457
* }
457458
* function mouseClicked() {
@@ -734,7 +735,7 @@ define(function (require) {
734735
* var ball = {};
735736
* var soundFile;
736737
*
737-
* function setup() {
738+
* function preload() {
738739
* soundFormats('ogg', 'mp3');
739740
* soundFile = loadSound('assets/beatbox.mp3');
740741
* }
@@ -1521,15 +1522,18 @@ define(function (require) {
15211522
* useful for removeCue(id)
15221523
* @example
15231524
* <div><code>
1525+
* var mySound;
1526+
* function preload() {
1527+
* mySound = loadSound('assets/beat.mp3');
1528+
* }
1529+
*
15241530
* function setup() {
15251531
* background(0);
15261532
* noStroke();
15271533
* fill(255);
15281534
* textAlign(CENTER);
15291535
* text('click to play', width/2, height/2);
15301536
*
1531-
* mySound = loadSound('assets/beat.mp3');
1532-
*
15331537
* // schedule calls to changeText
15341538
* mySound.addCue(0.50, changeText, "hello" );
15351539
* mySound.addCue(1.00, changeText, "p5" );

0 commit comments

Comments
 (0)