note-transposer is a module with a function to (surprise!) transpose notes, or create transposer functions:
var transpose =// => 'Eb3'// create a transposervar major3th ='C' 'D' 'E' // => ['E', 'F#', 'G#']
It's also capable of add intervals, and is part of tonal
npm i --save note-transposer and require the function.
Or use the distribution file (exports
transpose function to window globals):
The simplest usage is with a note name (pitch) and interval (the order doesn't matter):
// => 'F#2'// => 'F#2'
Pitch class transposition
You can transpose pitch classes (note names without octaves), and the returned value will be a pitch class:
// => 'C#'// => 'C#5'
If you need it you can transpose an interval:
// => '5A'
Also, you can partially apply the function to get a transposer:
var major3th =// => 'F#'
Partially applied transposers allows to work with arrays seamlessly:
'C' 'D' 'E' 'F' 'G' // => ['E', 'F#', 'G#', 'A', 'B']'1P' '3m' '5P' // => ['C', 'Eb', 'G']