1
1
'use strict' ;
2
2
3
- define ( function ( require ) {
3
+ define ( function ( require ) {
4
4
var p5sound = require ( 'master' ) ;
5
5
6
6
var BPM = 120 ;
@@ -110,14 +110,14 @@ define(function (require) {
110
110
111
111
/**
112
112
* <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>
114
114
*
115
115
* <p>See p5.Phrase for more about musical timing.</p>
116
116
*
117
117
* @class p5.Part
118
118
* @constructor
119
119
* @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)
121
121
* @example
122
122
* <div><code>
123
123
* var box, drum, myPart;
@@ -173,17 +173,14 @@ define(function (require) {
173
173
this . partStep = 0 ;
174
174
this . phrases = [ ] ;
175
175
this . isPlaying = false ;
176
-
177
176
this . noLoop ( ) ;
178
-
179
177
this . tatums = bLength || 0.0625 ; // defaults to quarter note
180
178
181
179
this . metro = new p5 . Metro ( ) ;
182
180
this . metro . _init ( ) ;
183
181
this . metro . beatLength ( this . tatums ) ;
184
182
this . metro . setBPM ( BPM ) ;
185
183
p5sound . parts . push ( this ) ;
186
-
187
184
this . callback = function ( ) { } ;
188
185
} ;
189
186
@@ -199,7 +196,7 @@ define(function (require) {
199
196
} ;
200
197
201
198
/**
202
- * Returns the Beats Per Minute of this currently part.
199
+ * Returns the tempo, in Beats Per Minute, of this part.
203
200
*
204
201
* @method getBPM
205
202
* @return {Number }
@@ -238,7 +235,6 @@ define(function (require) {
238
235
// rest onended function
239
236
this . onended = function ( ) {
240
237
this . partStep = 0 ;
241
- // dont start phrases over, right?
242
238
} ;
243
239
var t = time || 0 ;
244
240
this . start ( t ) ;
@@ -249,7 +245,7 @@ define(function (require) {
249
245
*
250
246
* @method noLoop
251
247
*/
252
- p5 . Part . prototype . noLoop = function ( ) {
248
+ p5 . Part . prototype . noLoop = function ( ) {
253
249
this . looping = false ;
254
250
// rest onended function
255
251
this . onended = function ( ) {
@@ -258,7 +254,7 @@ define(function (require) {
258
254
} ;
259
255
260
256
/**
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.
262
258
*
263
259
* @method stop
264
260
* @param {Number } [time] seconds from now
@@ -297,7 +293,6 @@ define(function (require) {
297
293
throw 'invalid input. addPhrase accepts name, callback, array or a p5.Phrase' ;
298
294
}
299
295
this . phrases . push ( p ) ;
300
-
301
296
// reset the length if phrase is longer than part's existing length
302
297
if ( p . sequence . length > this . length ) {
303
298
this . length = p . sequence . length ;
@@ -335,8 +330,7 @@ define(function (require) {
335
330
} ;
336
331
337
332
/**
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.
340
334
*
341
335
* @method replaceSequence
342
336
* @param {String } phraseName
@@ -352,12 +346,11 @@ define(function (require) {
352
346
} ;
353
347
354
348
p5 . Part . prototype . incrementStep = function ( time ) {
355
- if ( this . partStep < this . length - 1 ) {
349
+ if ( this . partStep < this . length - 1 ) {
356
350
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 ) {
361
354
console . log ( 'done' ) ;
362
355
// this.callback(time);
363
356
this . onended ( ) ;
@@ -366,7 +359,7 @@ define(function (require) {
366
359
} ;
367
360
368
361
/**
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 .
370
363
*
371
364
* @method onStep
372
365
* @param {Function } callback The name of the callback
@@ -401,7 +394,7 @@ define(function (require) {
401
394
for ( var i in arguments ) {
402
395
if ( arguments [ i ] && this . parts [ i ] ) {
403
396
this . parts [ i ] = arguments [ i ] ;
404
- this . parts [ i ] . nextPart = this . parts [ i + 1 ] ;
397
+ this . parts [ i ] . nextPart = this . parts [ i + 1 ] ;
405
398
this . parts [ i ] . onended = function ( ) {
406
399
thisScore . resetPart ( i ) ;
407
400
playNextPart ( thisScore ) ;
0 commit comments