2.0.1 • Published 3 years ago

chordjs v2.0.1

Weekly downloads
45
License
SEE LICENSE IN LI...
Repository
github
Last release
3 years ago

ChordJS Build Status npm version Code Climate

A simple JavaScript chord parsing and manipulation tool

⚠️ NOTE: These are the V2 docs. The V1 docs are here.

Installation

ChordJS is on npm, to install run:

npm install chordjs

or:

yarn add chordjs

Load with import (es2015):

var Chord = require('chordjs').default;
import Chord, { parse } from 'chordjs';

Functionalities

Parse

const chord = parse('Ebsus4/Bb');

Parse numeric chords (Nashville system):

const chord = parse('b1sus4/#3');

Display with #toString

Use #toString() to convert the chord to a chord string (eg Dsus/F#)

const chord = parse('Ebsus4/Bb');
chord.toString(); // --> "Ebsus4/Bb"

Clone

var chord2 = chord.clone();

Normalize

Normalizes keys B#, E#, Cb and Fb to C, F, B and E

const chord = parse('E#/B#'),
    normalizedChord = chord.normalize();
normalizedChord.toString(); // --> "F/C"

Switch modifier

Convert # to b and vice versa

const chord = parse('Eb/Bb');
const chord2 = chord.switchModifier();
chord2.toString(); // --> "D#/A#"

Use specific modifier

Set the chord to a specific modifier (# or b)

const chord = parse('Eb/Bb');
const chord2 = chord.useModifier('#');
chord2.toString(); // --> "D#/A#"
const chord = parse('Eb/Bb');
const chord2 = chord.useModifier('b');
chord2.toString(); // --> "Eb/Bb"

Transpose up

const chord = parse('Eb/Bb');
const chord2 = chord.transposeUp();
chord2.toString(); // -> "E/B"

Transpose down

const chord = parse('Eb/Bb');
const chord2 = chord.transposeDown();
chord2.toString(); // -> "D/A"

Transpose

const chord = parse('C/E');
const chord2 = chord.transpose(4);
chord2.toString(); // -> "E/G#"
const chord = parse('C/E');
const chord2 = chord.transpose(-4);
chord2.toString(); // -> "Ab/C"

Convert numeric chord to chord symbol

const numericChord = parse('2/4');
const chordSymbol = toChordSymbol(numericChord, 'E');
chordSymbol.toString(); // -> "F#m/A"
2.0.1

3 years ago

2.0.0

3 years ago

1.1.1

6 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

8 years ago