Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
note-parser
Advanced tools
Parse note names (in scientific notation) with javascript. Given a string, obtain a hash with note properties (including midi number and frequency)
If you need parse interval names take a look to interval-notation
Install via npm: npm i --save note-parser
and require it:
var parser = require('note-parser')
parser.parse('c#4') // => { letter: 'C', acc: '#', ... midi: 61, freq: 277.1826309768721 }
The returned object will contain:
letter
: the uppercase letter of the noteacc
: the accidentals of the note (only sharps or flats)pc
: the pitch class (letter + acc)step
: s a numeric representation of the letter. It's an integer from 0 to 6 where 0 = C, 1 = D ... 6 = Balt
: a numeric representation of the accidentals. 0 means no alteration,
positive numbers are for sharps and negative for flatschroma
: a numeric representation of the pitch class. It's like midi for
pitch classes. 0 = C, 1 = C#, 2 = D ... It can have negative values: -1 = Cb.If the note name has octave, the returned object will additionally have:
oct
: the octave number (as integer)midi
: the midi numberfreq
: the frequency (using tuning parameter as base)If the parameter isTonic
is set to true another property is included:
tonicOf
: the rest of the string that follows note name (left and right trimmed)If you are interested only in midi numbers or frequencies, you can use midi
function:
parser.midi('A4') // => 69
parser.midi('blah') // => null
parser.midi(60) // => 60
parser.midi('60') // => 60
or the freq
function:
parser.freq('A4') // => 440
parser.freq('A3', 444) // => 222
parser.freq(69) // => 440
With the build
function you can convert back to string:
parser.build(parser.parse('cb2')) // => 'Cb2'
Alternatively the build
function accepts step, alteration, octave
parameters:
parser.build(3, -2, 4) // => 'Fbb4'
## Tests and documentation
You can read the generated API documentation here
To run the test clone this repo and:
npm install
npm test
MIT License
FAQs
Parse music notes in scientific notation
The npm package note-parser receives a total of 962 weekly downloads. As such, note-parser popularity was classified as not popular.
We found that note-parser 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
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.