tonal-index

2.2.2 • Public • Published

tonal-index

📚 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.

Modes

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)

Install

npm install --save tonal-index

then, either:

// warm / pre-cached module
const music = require('tonal-index')()

or

// lazy module
const music = require('tonal-index')

API

all

  • Types: notes, scales, and chords
  • Returns: Every possible combination of notes, scales, or chords
const { notes, scales, chord } = require('tonal-index')

notes.all()  // [ 'C', 'C#', 'Db', 'D', 'D#', 'Eb', ...]
scales.all() // 1530 results
chords.all() // 1853 results

by

Queries scale or chord collections by either type or root.

  • Types: scales, chords
  • Params:
    • key: Either 'type' or 'root' (i.e. the root note of the scale or chord)
    • value: The value to compare all other values against
  • Returns: Entire collection filtered by entries matching a key and value
const { scales, chords } = require('tonal-index')

const majScales  = scales.by('type', 'major')
const min7Chords = chords.by('type', 'm7')

each

  • Types: scales, chords
  • Returns: Each combination of scales, or chords, one element at a time (generator)
const { scales } = require('tonal-index')

const generate = scales.each()

generate.next()

Output

You can find the full list of chords and scales in test/fixtures/*

Types

note

scale and chord

Future

  • [ ] Optionally group by root note
  • [ ] Configurable octaves
  • [ ] Chord voicings
  • [ ] Chord inversions
  • [ ] Streamed collection
  • [x] Generator collection

License

MIT

/tonal-index/

    Package Sidebar

    Install

    npm i tonal-index

    Weekly Downloads

    9

    Version

    2.2.2

    License

    MIT

    Unpacked Size

    491 kB

    Total Files

    21

    Last publish

    Collaborators

    • slurm