📚 Music theory library providing iterable collections of every possible note, scale and chord
If you have ever needed to iterate through every possible note, scale, or chord in your music applications then tonal-index
is the answer.
tonal-index
uses tonal
to dynamically generate and aggregate each collection.
Because tonal-index
generates relatively large sets of data it may be loaded in either warm or lazy mode.
- Warm: Pre-generates and caches all of the possible collection values
- Lazy: Defers generation until the collections are actually needed (default)
npm install --save tonal-index
then, either:
// warm / pre-cached module
const music = require('tonal-index')()
or
// lazy module
const music = require('tonal-index')
- Types:
notes
,scales
, andchords
- Returns: Every possible combination of
notes
,scales
, orchords
const { notes, scales, chord } = require('tonal-index')
notes.all() // [ 'C', 'C#', 'Db', 'D', 'D#', 'Eb', ...]
scales.all() // 1530 results
chords.all() // 1853 results
Queries scale
or chord
collections by either type
or root
.
- Types:
scales
,chords
- Params:
key
: Either'type'
or'root'
(i.e. the rootnote
of thescale
orchord
)value
: The value to compare all other values against
- Returns: Entire collection filtered by entries matching a
key
andvalue
const { scales, chords } = require('tonal-index')
const majScales = scales.by('type', 'major')
const min7Chords = chords.by('type', 'm7')
- Types:
scales
,chords
- Returns: Each combination of
scales
, orchords
, one element at a time (generator)
const { scales } = require('tonal-index')
const generate = scales.each()
generate.next()
You can find the full list of chords and scales in test/fixtures/*
- Type:
string
- Format: Scientific pitch notation
- Type:
object
- Properties:
type
:- Type:
string
- Format: Scientific pitch notation
- Examples:
"+add#9"
,"m7"
,"major"
- Type:
root
:- Type:
string
- Format: Scientific pitch notation
- Example:
"C"
- Type:
notes
:- Type:
Array<string>
- Format: Scientific pitch notation
- Example:
["C", "E", "G#", "D#"]
- Type:
- Optionally group by root note
- Configurable octaves
- Chord voicings
- Chord inversions
- Generator collection
MIT