npm.io
4.9.5 • Published 1 week ago

@tonaljs/abc-notation

Licence
MIT
Version
4.9.5
Deps
2
Size
17 kB
Vulns
0
Weekly
0

@tonaljs/abc-notation tonal npm version

Convert note names between scientific and abc notation

import { AbcNotation } from "tonal";

AbcNotation.abcToScientificNotation("c"); // => "C5"

Usage

ES6:

import { AbcNotation } from "tonal";

nodejs:

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

API

AbcNotation.abcToScientificNotation

abcToScientificNotation(noteNameInAbc: string) => string

AbcNotation.abcToScientificNotation("c"); // => "C5"
AbcNotation.scientificToAbcNotation

scientificToAbcNotation(noteNameInScientific: string) => string

AbcNotation.scientificToAbcNotation("C#4"); // => "^C"
AbcNotation.transpose

transpose(note: string, interval: string) => string

Transpose an note in abc notation:

AbcNotation.transpose("=C", "P19"); // => "g'"
AbcNotation.distance

distance(from: string, to: string) => string

Find the interval between two notes in abc notation:

AbcNotation.distance("=C", "g"); // => "12P"
AbcNotation.tokenize

tokenize(note: string) => [string, string, string]

Split a note in abc notation into its accidentals, letter and octave marks. Invalid notes give empty strings:

AbcNotation.tokenize("^c'"); // => ["^", "c", "'"]
AbcNotation.tokenize("_B,,"); // => ["_", "B", ",,"]
AbcNotation.tokenize("x"); // => ["", "", ""]

References

Keywords