https://github.com/mrfrac/goodchords
Music theory library
https://github.com/mrfrac/goodchords
chord interval music music-theory note pitch scale tone
Last synced: 11 months ago
JSON representation
Music theory library
- Host: GitHub
- URL: https://github.com/mrfrac/goodchords
- Owner: mrfrac
- License: mit
- Created: 2018-11-30T13:12:40.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-06-09T22:59:42.000Z (about 1 year ago)
- Last Synced: 2025-06-11T22:19:14.641Z (about 1 year ago)
- Topics: chord, interval, music, music-theory, note, pitch, scale, tone
- Language: TypeScript
- Homepage:
- Size: 2.03 MB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Goodchords
[](https://badge.fury.io/js/goodchords)

[](https://ci.appveyor.com/project/mrfrac/goodchords)
[](https://coveralls.io/github/mrfrac/goodchords?branch=master)
[](https://github.com/prettier/prettier)
[](https://sonarcloud.io/dashboard?id=mrfrac_goodchords)
> Music theory library
**The project is under development.**
## Usage
### Install
```bash
npm install --save goodchords
```
or
```bash
yarn add goodchords
```
### Import (ES6)
```js
import { Scale, Chord, Interval, Note } from "goodchords";
```
### Require (ES5)
```js
const { Scale, Chord, Interval, Note } = require("goodchords");
```
### Browser
Usage example:
```html
Goodchords
alert(window.goodchords.Note.fromString("A4").frequency());
```
> Replace X with correct version
### API
#### Note
```js
const note = new Note("A", "#", 4);
// or
const note = Note.fromString("A#4");
note.transpose("M3").toString(); // C##5
note.toString(); // A#4
note.frequency(); // 466.16
note.distanceTo("A#5"); // 12
note.number(); // 58
```
#### Interval
```js
const interval = new Interval(8, "P");
// or
const interval = Interval.fromString("8P"); // or P8
interval.semitones(); // 12
interval.isValid(); // true
interval.isCompound(); // false
Note.fromString("A4").transpose(interval).toString(); // A5
```
#### Scale
```js
const majorScaleFormula = ["P1", "M2", "M3", "P4", "P5", "M6", "M7"];
const scale = new Scale("A", majorScaleFormula);
scale.getNotes().map((note) => note.toString()); // ["A4", "B4", "C#5", "D5", "E5", "F#5", G#5", ]
const ionian = new Scale("C", "ionian");
ionian.getNotes().map((note) => note.toString()); // ["C4", "D4", "E4", "F4", "G4", "A4", "B4", ]
ionian.getChords(); // get chords for scale by degree
ionian.getScaleInfo(); // { name: "Major", formula: "<...>", altNames: ["Bilaval theta", "Ethiopian (A raray)", "Ionian", "Mela Dhirasankarabharana (29)", ]}
```
#### Chords
```js
const chord = new Chord("C", "m");
// or
const chord = Chord.fromString("Cm");
chord.getNotes(); // ["C4", "Eb4", "G4"]
```