
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
music-notation
Advanced tools
Parse alterations, notes, intervals and other musical elements with differents notations
music-notation is a collection of javascript functions to parse alterations, notes, intervals and other pitched elements using different notations.
Install via npm : npm install --save music-notation
This is part of tonal
The array notation a format to represent pitches and intervals using fifths, octaves and duration encoded as an array. It's largely based on coord notation by teoria
The array notation is the primary format in this module. All the parse functions (note/parse, interval/parse, ...) converts from string to array format. All the str functions (note/str, interval/str, ...) converts from array notation to string.
A pitch in array notation is an array with different length depending what it stores:
'C' is [ 0 ], 'D' is [ 2 ], 'E' is [ 4 ], and so on.[ 2, 0 ] its '9M' (major ninth) since two fifths span more than a octave, so '2M' (major second) its [ 2, -1 ]C0 to the note pitch with an additional value of the duration. For example: 'C2' with no duration would be [0, 2, null].The purpose of this design is to provide a uniform way to represent pitches (including notes, pitch classes and intervals) so lot of code can be shared, but be able to differentiate them easily.
The note scientific notation is a string with the form <letter><alteration><octave>/<duration> where only the letter is mandatory.
You can parse notes in scientific notation with note/parse:
var parse = require('music-notation/note/parse')
parse('C2') // => [0, 2, null]
parse('c2') // => [0, 2, null]
You can parse and build notes with strings containing note helmholtz notation
The interval shorthand notation is a way to encode intervals using strings. In tonal the cannonical form is <number><quality> in which the components are reversed from the standard interval shorthand notation. The reason for this is to cleary differenciate between A4 (the note) and 4A (the interval).
The interval shorthand notation parser is capable to understand the reversed and the direct interval notation as well as intervals with the form <number><alteration>:
var parse = require('music-notation/interval/parse')
parse('2M') // => [2, -1] // reverse shorthand notation (tonal's default)
parse('M2') // => [2, -1] // standard shorthand notation
parse('2') // => [2, -1] // number-alteration notation
The roman notation allows to express pitch classes using string with roman numerals. The cannonical form is <alteration><roman> but the parser is capable to understand the <roman><alteration> format:
var parse = require('music-notation/roman/parse')
parse('bII') // => [ -5 ] <= same as `Db`
parse('bii') // => [ -5 ] <= case is ignored
parse('IIb') // => [ -5 ] <= reversed components allowed
You have functions to convert accidentals string to alterations integers (### => 3, for example) and vice versa.
Read the API documentation to see all the available functions.
MIT License
FAQs
Parse alterations, notes, intervals and other musical elements with differents notations
We found that music-notation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.