Skip to content

Latest commit

 

History

History
 
 

notation-scientific

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

@tonaljs/notation-scientific tonal npm version

Parse notes in scientific notation

Usage

⚠️ It's probably you don't need to use this package directly. Use tonal-note instead.

import { parse, name, tokenize } from "@tonaljs/notation-scientific";

parse("cb4"); // => { step: 0, oct: 4, alt: -1 }

API

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

Given a note name in [scientific notation] it returns an array with the different parts:

tokenize("Abb4 major"); // => ["", "A", "bb", "4", "major"]

parse(name: string) => { step, alt, oct? } | undefined

Given a note name, it returns an object with the following properties:

  • step (number): the letter number (0..6)
  • alt (number): the accidental number (..., -1 = 'b', 0 = '', 1 = '#', ...)
  • oct (number?): the optional octave

name(parsed) => string

Given the result of parse it returns the name.

name({ step: 1, oct: 2, alt: 1 }); // => "D#1"