Reference p5.Part

p5.Part

A p5.Part plays back one or more p5.Phrases. Instantiate a part with steps and tatums. By default, each step represents a 1/16th note.

See p5.Phrase for more about musical timing.

Examples

Syntax

p5.Part([steps], [tatums])

Parameters

steps
Number:

Steps in the part

tatums
Number:

Divisions of a beat, e.g. use 1/4, or 0.25 for a quater note (default is 1/16, a sixteenth note)

Methods

setBPM

Set the tempo of this part, in Beats Per Minute.

getBPM

Returns the tempo, in Beats Per Minute, of this part.

start

Start playback of this part. It will play through all of its phrases at a speed determined by setBPM.

loop

Loop playback of this part. It will begin looping through all of its phrases at a speed determined by setBPM.

noLoop

Tell the part to stop looping.

stop

Stop the part and cue it to step 0. Playback will resume from the begining of the Part when it is played again.

pause

Pause the part. Playback will resume from the current step.

addPhrase

Add a p5.Phrase to this Part.

removePhrase

Remove a phrase from this part, based on the name it was given when it was created.

getPhrase

Get a phrase from this part, based on the name it was given when it was created. Now you can modify its array.

replaceSequence

Find all sequences with the specified name, and replace their patterns with the specified array.

onStep

Set the function that will be called at every step. This will clear the previous function.

Notice any errors or typos? Please let us know. Please feel free to edit lib/addons/p5.sound.js and open a pull request!

Related References