0.3.2 • Published 6 years ago

twelvetet-spn v0.3.2

Weekly downloads
8
License
MIT
Repository
github
Last release
6 years ago

twelvetet-spn

Scientific pitch notation parser/formatter for Node.js and the browser.

Installation

Install the latest stable version of twelvetet-spn using npm:

npm install twelvetet-spn

You can also access the files on unpkg.com.

You can use twelvetet-spn with module bundlers.

The twelvetet-spn npm package includes precompiled production and development UMD builds in the dist/ folder. They can be used without a bundler.

The UMD builds make twelvetet-spn available as window.TwelveTetSPN global variable.

twelvetet-spn works in any modern browser and Node.js.

Usage

import { format, parse } from 'twelvetet-spn'

parse('A4') // [9, 4]

// NOTE: `format()` always returns an array of five elements
// ordered as follows: `[<double_sharp>, <sharp>, <natural>, <flat>, <double_flat>]`.
// An element is `null` when there is no corresponding enharmonic equivalent.
format([9, 4]) // ['Gx4', null, 'A4', null, 'Bbb4']

API

twelvetet-spn.format(value) ⇒ Array

Formats a musical pitch to scientific pitch notation.

Kind: static method of twelvetet-spn
Returns: Array - An array of scientific pitch notation enharmonic equivalents of the musical pitch. The array always has 5 elements. The order is always [<double sharp>, <sharp>, <natural>, <flat>, <double flat>]. An element of the array is null if there is no corresponding enharmonic equivalent
Throws:

  • TypeError Will throw an error if the value argument is not an array
ParamTypeDescription
valueArray.<Number>An array representing the musical pitch's class and octave.
value.0NumberThe pitch class of the musical pitch.
value.1NumberThe octave of the musical pitch.

twelvetet-spn.parse(value) ⇒ Array.<Number>

Parses scientific pitch notation of a musical pitch.

Kind: static method of twelvetet-spn
Returns: Array.<Number> - An array representing the musical pitch's class and octave.
Throws:

  • TypeError Will throw an error if the value argument is not a string
ParamTypeDescription
valueStringScientific pitch notation of a musical pitch.

License

This project is MIT-licensed

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago