Meet npm Pro: unlimited public & private packages + package-based permissions.Learn more »

twelvetet-spn

0.3.2 • Public • Published

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
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 value argument is not a string
Param Type Description
value String Scientific pitch notation of a musical pitch.

License

This project is MIT-licensed

Install

npm i twelvetet-spn

DownloadsWeekly Downloads

2

Version

0.3.2

License

MIT

Unpacked Size

25.5 kB

Total Files

17

Last publish

Collaborators

  • avatar