Notes

NoteComposer

Sequence single notes, chords and rests with note factories.

The following example uses quarter, eighth and dotted.quarter note factories:

// Single note:
track.at(0).play(quarter.note('C5'))

// Named chord:
track.at(0).play(quarter.note('Cmaj7'))

// Custom chord:
track.at(0).play(quarter.note('C4 D4 E4 G5'))

// One bar phrase with chords and a rest:
track.at(0).play.phrase([
  dotted.quarter.note('Cmaj7'),
  eighth.note('Dmin'),
  quarter.rest(),
  quarter.note('Bmaj')
]);

Note Factories

Note factories are subclasses of NoteComposer bound to a specific time unit.

Standard
large long doubleWhole whole half quarter eighth sixteenth thirtySecond sixtyFourth

Dotted
dotted.large dotted.long dotted.doubleWhole dotted.whole dotted.half dotted.quarter dotted.eighth dotted.sixteenth dotted.thirtySecond dotted.sixtyFourth

Double Dotted
doubleDotted.large doubleDotted.long doubleDotted.doubleWhole doubleDotted.whole doubleDotted.half doubleDotted.quarter doubleDotted.eighth doubleDotted.sixteenth doubleDotted.thirtySecond doubleDotted.sixtyFourth

Triplets
triplet.quarter triplet.eighth triplet.sixteenth

Quintuplets
quintuplet.quarter quintuplet.eighth quintuplet.sixteenth

Septuplets
septuplet.quarter septuplet.eighth septuplet.sixteenth

Pitches

Pitches are specified in ABC Notation or as integers relative to the key signature.

ABC Notation

// Default octave (4)
track.at(0).play(quarter.note('C'));

// With specific octave:
track.at(0).play(quarter.note('C2'));

Relative Notation

Relative pitches are signed integers that will be transposed to notes in the appropriate key signature at the time they are played.

Consider the following:

session('my-song', ({ session }) => {
  session.at(0)
    .key('C')
    .scale('major');

  session.phrase('melody', [
    quarter.note(0),
    quarter.note(1),
    quarter.note(2),
    quarter.note(3),
  ])

  session.track('my-track', ({ track }) => {
    track.at(0).play.phrase('melody'); // ==> C4, D4, E4, F4
    track.at(2).play.phrase('melody'); // ==> C4, D4, E4, F4
  });
});

If we change the key signature at measure 2, the resulting notes are:

session('my-song', ({ session }) => {
  session.at(0)
    .key('C')
    .scale('major');

  session.at(2)
    .key('E')
    .scale('major');

  session.phrase('melody', [
    quarter.note(0),
    quarter.note(1),
    quarter.note(2),
    quarter.note(3),
   ])

  track('my-track', ({ track }) => {
    track.at(0).play.phrase('melody'); // ==> C4, D4, E4, F4
    track.at(2).play.phrase('melody'); // ==> E4, F#, G#, A4
  });
});

Chords

Named Chords

Harmonicon supports a large number of chords that can be referenced by name:

session.track('my-track', () => {
 track.at(0).play(quarter.note('cmaj7'))
})

Custom Chord Structures

To specify chord notes manually, provide an array of notes:

session.track('my-track', () => {
 track.at(0).play(quarter.note([ 'C4', 'E4', 'F4' ]));
})

Alternatively, a space-delimited string also works:

session.track('my-track', () => {
 track.at(0).play(quarter.note('C4 E4 F4');
})
Source:

Methods

(static) note(pitch, options) → {NoteModel|Array.<NoteModel>}

Sequence one or more pitches at a position on the timeline.

Parameters:
Name Type Description
pitch Array | Integer | String

pitch, chord, or array of pitches

options Object
Properties
Name Type Description
velocity Integer

velocity (0 to 1)

octave Integer

octave (0 to 7)

Source:
Example
quarter.note('c4', { velocity: 0.5 })

(static) rest(options) → {RestModel}

Sequence a rest inside a phrase.

Parameters:
Name Type Description
options *
Source:
Example
// One bar phrase with a 2 beat rest:
session.phrase('my-phrase', [
  quarter.note('C'),
  half.rest(),
  quarter.note('D'),
])