Skip to content

Latest commit

 

History

History

chord-detect

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

@tonaljs/chord-detect tonal npm version

Usage

With ES6 import:

import { Chord } from "tonal";

With ES5 require:

const { Chord } = require("tonal");

Standalone:

import { detect } from "@tonaljs/chord-detect";

API

Chord.detect(notes: string[], options?: { assumePerfectFifth?: boolean }) => string[]

Examples:

Chord.detect(["D", "F#", "A", "C"]); // => ["D7"]
Chord.detect(["F#", "A", "C", "D"]); // => ["D7/F#"]
Chord.detect(["A", "C", "D", "F#"]); // => ["D7/A"]
Chord.detect(["E", "G#", "B", "C#"]); // => ["E6", "C#m7/E"]

This function is also exposed in Chord module.

Options

  • assumePerfectFifth: assumes perfect fifth if no fifth is present
detect(["D", "F", "C"], { assumePerfectFifth: true }); // => ["Dm7"]
detect(["D", "F", "C"], { assumePerfectFifth: false }); // => []