Skip to content

Commit e850a8d

Browse files
authored
Merge pull request #331 from rMazeiks/patch-2
Fixed documentation
2 parents 349495d + a3d829c commit e850a8d

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

src/looper.js

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
define(function (require) {
3+
define(function(require) {
44
var p5sound = require('master');
55

66
var BPM = 120;
@@ -110,14 +110,14 @@ define(function (require) {
110110

111111
/**
112112
* <p>A p5.Part plays back one or more p5.Phrases. Instantiate a part
113-
* with steps and tatums. By default, each step represents 1/16th note.</p>
113+
* with steps and tatums. By default, each step represents a 1/16th note.</p>
114114
*
115115
* <p>See p5.Phrase for more about musical timing.</p>
116116
*
117117
* @class p5.Part
118118
* @constructor
119119
* @param {Number} [steps] Steps in the part
120-
* @param {Number} [tatums] Divisions of a beat (default is 1/16, a quarter note)
120+
* @param {Number} [tatums] Divisions of a beat, e.g. use 1/4, or 0.25 for a quater note (default is 1/16, a sixteenth note)
121121
* @example
122122
* <div><code>
123123
* var box, drum, myPart;
@@ -173,17 +173,14 @@ define(function (require) {
173173
this.partStep = 0;
174174
this.phrases = [];
175175
this.isPlaying = false;
176-
177176
this.noLoop();
178-
179177
this.tatums = bLength || 0.0625; // defaults to quarter note
180178

181179
this.metro = new p5.Metro();
182180
this.metro._init();
183181
this.metro.beatLength(this.tatums);
184182
this.metro.setBPM(BPM);
185183
p5sound.parts.push(this);
186-
187184
this.callback = function() {};
188185
};
189186

@@ -199,7 +196,7 @@ define(function (require) {
199196
};
200197

201198
/**
202-
* Returns the Beats Per Minute of this currently part.
199+
* Returns the tempo, in Beats Per Minute, of this part.
203200
*
204201
* @method getBPM
205202
* @return {Number}
@@ -238,7 +235,6 @@ define(function (require) {
238235
// rest onended function
239236
this.onended = function() {
240237
this.partStep = 0;
241-
// dont start phrases over, right?
242238
};
243239
var t = time || 0;
244240
this.start(t);
@@ -249,7 +245,7 @@ define(function (require) {
249245
*
250246
* @method noLoop
251247
*/
252-
p5.Part.prototype.noLoop = function( ) {
248+
p5.Part.prototype.noLoop = function() {
253249
this.looping = false;
254250
// rest onended function
255251
this.onended = function() {
@@ -258,7 +254,7 @@ define(function (require) {
258254
};
259255

260256
/**
261-
* Stop the part and cue it to step 0.
257+
* Stop the part and cue it to step 0. Playback will resume from the begining of the Part when it is played again.
262258
*
263259
* @method stop
264260
* @param {Number} [time] seconds from now
@@ -297,7 +293,6 @@ define(function (require) {
297293
throw 'invalid input. addPhrase accepts name, callback, array or a p5.Phrase';
298294
}
299295
this.phrases.push(p);
300-
301296
// reset the length if phrase is longer than part's existing length
302297
if (p.sequence.length > this.length) {
303298
this.length = p.sequence.length;
@@ -335,8 +330,7 @@ define(function (require) {
335330
};
336331

337332
/**
338-
* Get a phrase from this part, based on the name it was
339-
* given when it was created. Now you can modify its array.
333+
* Find all sequences with the specified name, and replace their patterns with the specified array.
340334
*
341335
* @method replaceSequence
342336
* @param {String} phraseName
@@ -352,12 +346,11 @@ define(function (require) {
352346
};
353347

354348
p5.Part.prototype.incrementStep = function(time) {
355-
if (this.partStep < this.length-1) {
349+
if (this.partStep < this.length - 1) {
356350
this.callback(time);
357-
this.partStep +=1;
358-
}
359-
else {
360-
if (!this.looping && this.partStep === this.length-1) {
351+
this.partStep += 1;
352+
} else {
353+
if (!this.looping && this.partStep === this.length - 1) {
361354
console.log('done');
362355
// this.callback(time);
363356
this.onended();
@@ -366,7 +359,7 @@ define(function (require) {
366359
};
367360

368361
/**
369-
* Fire a callback function at every step.
362+
* Set the function that will be called at every step. This will clear the previous function.
370363
*
371364
* @method onStep
372365
* @param {Function} callback The name of the callback
@@ -401,7 +394,7 @@ define(function (require) {
401394
for (var i in arguments) {
402395
if (arguments[i] && this.parts[i]) {
403396
this.parts[i] = arguments[i];
404-
this.parts[i].nextPart = this.parts[i+1];
397+
this.parts[i].nextPart = this.parts[i + 1];
405398
this.parts[i].onended = function() {
406399
thisScore.resetPart(i);
407400
playNextPart(thisScore);

0 commit comments

Comments
 (0)