Skip to content

danigb/music-gamut

Repository files navigation

music-gamut

Build Status Test Coverage Code Climate js-standard-style npm version pitch-array

music-gamut is a javascript library to manipulate notes (or intervals):

gamut.pitchSet('C2 D3 C4 E5') // => ['C', 'D', 'E']
gamut.transpose('2M', 'C D E F G') // => ['D', 'E', 'F#', 'G', 'A']
gamut.distances('C2', 'C3 C4') // => ['8P', '15P']

It's fast, easy and side-effects free (all pure functions).

Install

For node users: npm i --save music-gamut. For browser users, use webpack, browserify or similar tool.

Usage

In music-gamut, a gamut is list of notes or intervals. The list can be expressed as arrays or as strings separated by spaces, commas or bars:

gamut(['C', 'D', 'E']) // => ['C', 'D', 'E']
gamut('C D E') // => ['C', 'D', 'E']
gamut('C | D | E') // => ['C', 'D', 'E']
gamut('C, D, E') // => ['C', 'D', 'E']

You can use the functions notes and intervals and to filter the type:

gamut.notes('C2 blah D3') // => ['C2', null, 'D3']
gamut.intervals('1 2 3 blah 4 5') // => ['1P', '2M', '3M', null, '4P', '5P']

You have a collection of funtions to manipulate the lists. All the functions returns a new copy of the list (no mutations):

  • transpose: transpose a list of notes by an interval
  • add: add an interval to a list of intervals
  • distances: get distances of the gamut from a note
  • pitchSet: get the pitch set from the gamut
  • intervalSet: get the interval set from the gamut
  • uniq: remove duplicates and nulls
  • pitchClasses: remove the octaves from the notes

(... and some more. Read the docs)

## What is this for?

See music-scale, music-chord or tonal

Documentation

Generated API documentation is here

License

MIT License

About

Manipulate notes made easy

Resources

License

Stars

Watchers

Forks

Packages

No packages published