Phrases

PhraseComposer

Create reusable phrases with session.phrase():

session.phrase('progression', ({ phrase }) => {
  phrase.sequence([
    whole.note('cmaj'),
    whole.note('fmaj'),
    whole.note('cmaj'),
    whole.note('gmaj'),
  ])
});

// Play progression on piano:
session.track('piano', ({ track }) => {
  track.at(0).play.phrase('progression');
});

// Play progression on acoustic guitar:
session.track('acoustic-guitar', ({ track }) => {
  track.at(0).play.phrase('progression');
});

Phrases are declared once, but can be used by any track any number of times and are agnostic of the instrument playing them. Meaning, if 3 instruments play the same melody, you only have to code it once.

Shorthand

The same phrase can also be written more tersely:

session.phrase('progression', [
  whole.note('cmaj'),
  whole.note('fmaj'),
  whole.note('cmaj'),
  whole.note('gmaj'),
]);

Anonymous Phrases

Phrases can also be sequenced without being declared previously:

session.track('piano', ({ track }) => {
  track.at(0).play.phrase([
    whole.note('cmaj'),
    whole.note('fmaj'),
    whole.note('cmaj'),
    whole.note('gmaj'),
  ]);
});

Anonymous phrases are not reusable, but they can make sequencing easier.

Source:

Methods

sequence(sequence)

Assign a sequence of notes to a phrase.

Parameters:
Name Type Description
sequence Array | ExpressionModel

Sequence of notes and rests

Source:
Examples
phrase('melody', ({ phrase }) => {
  phrase.sequence([
    quarter.note(0),
    quarter.note(4),
    quarter.note(2),
    quarter.note(3),
  ])
})
phrase('melody', ({ phrase }) => {
  phrase.sequence(expression(...))
})