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');
})