music-gamut
music-gamut
is a library to work with collections of notes or intervals using a functional programming paradigm. Standard map
, filter
and reduce
functions are implemented:
var gamut = var octUp = gamut // => ['C3', 'D4', 'F##5']
This is part of tonal:
var tonal = tonaltonaltonal
Install
Via npm: npm i --save music-gamut
Usage
In tonal a gamut is a collection of pitches (notes, intervals or pitch classes). This collection can be expressed as:
- array of notes:
['C2', 'D2', 'E3']
- a string with notes (separated with spaces, commas or bars):
C2 D2 E3
- an array of notes in array notation:
[[0, 2, null], [1, 2, null]]
Create gamuts
You can create a gamut from a string with notes or intervals separated by spaces, bars or commas:
var gamut = // => ['A', 'B', 'C', '1P', '2M', '3M', null] // => ['C', 'D', 'E' 'F']
Map collection of notes
The gamut.map
function can be used to map a collection of notes:
var transpose = gamut // => ['C#', 'D', 'E', 'F#', 'G#']
Or partially apply to more functional style:
var thirdUp = gamut // => ['C#', 'D', 'E', 'F#', 'G#']
Filter collection of notes
Filter works the same way:
var onlyC = gamut // => ['C']
Select elements from a gamut
You can select elements with a list of 1-based index numbers and a gamut:
gamut // => ['C', 'E', 'G']
Rotate gamuts
gamut // => ['e', 'c', 'd']
License
MIT License