twelvetet-spn v0.3.2
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-spnYou 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
- .parse(value) ⇒ Array.<Number>
 
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 valueargument is not an array
| Param | Type | Description | 
|---|---|---|
| value | Array.<Number> | An array representing the musical pitch's class and octave. | 
| value.0 | Number | The pitch class of the musical pitch. | 
| value.1 | Number | The 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 valueargument is not a string
| Param | Type | Description | 
|---|---|---|
| value | String | Scientific pitch notation of a musical pitch. | 
License
This project is MIT-licensed