{"id":13570798,"url":"https://github.com/danigb/note-parser","last_synced_at":"2025-04-11T12:31:16.017Z","repository":{"id":32257036,"uuid":"35831437","full_name":"danigb/note-parser","owner":"danigb","description":"Parse notes with javascript","archived":false,"fork":false,"pushed_at":"2017-04-04T22:23:41.000Z","size":49,"stargazers_count":55,"open_issues_count":1,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-25T13:46:25.658Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danigb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-18T17:16:58.000Z","updated_at":"2023-10-16T03:47:12.000Z","dependencies_parsed_at":"2022-09-11T15:51:17.431Z","dependency_job_id":null,"html_url":"https://github.com/danigb/note-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Fnote-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Fnote-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Fnote-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Fnote-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danigb","download_url":"https://codeload.github.com/danigb/note-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248329792,"owners_count":21085604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T14:00:55.081Z","updated_at":"2025-04-11T12:31:15.766Z","avatar_url":"https://github.com/danigb.png","language":"JavaScript","readme":"# note-parser [![npm](https://img.shields.io/npm/v/note-parser.svg)](https://www.npmjs.com/package/note-parser)\n\n[![Build Status](https://travis-ci.org/danigb/note-parser.svg?branch=master)](https://travis-ci.org/danigb/note-parser) [![Code Climate](https://codeclimate.com/github/danigb/note-parser/badges/gpa.svg)](https://codeclimate.com/github/danigb/note-parser)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)\n\nParse note names (in [scientific notation](https://en.wikipedia.org/wiki/Scientific_pitch_notation)) with javascript. Given a string, obtain a hash\nwith note properties (including midi number and frequency)\n\nIf you need parse interval names take a look to [interval-notation](https://github.com/danigb/interval-notation)\n\n## Usage\n\nInstall via npm: `npm i --save note-parser` and require it:\n\n```js\nvar parser = require('note-parser')\nparser.parse('c#4') // =\u003e { letter: 'C', acc: '#', ... midi: 61, freq: 277.1826309768721 }\n```\n\nThe returned object will contain:\n\n- `letter`: the uppercase letter of the note\n- `acc`: the accidentals of the note (only sharps or flats)\n- `pc`: the pitch class (letter + acc)\n- `step`: s a numeric representation of the letter. It's an integer from 0 to 6 where 0 = C, 1 = D ... 6 = B\n- `alt`: a numeric representation of the accidentals. 0 means no alteration,\npositive numbers are for sharps and negative for flats\n- `chroma`: a numeric representation of the pitch class. It's like midi for\npitch classes. 0 = C, 1 = C#, 2 = D ... It can have negative values: -1 = Cb.\n\nIf the note name has octave, the returned object will additionally have:\n\n- `oct`: the octave number (as integer)\n- `midi`: the midi number\n- `freq`: the frequency (using tuning parameter as base)\n\nIf the parameter `isTonic` is set to true another property is included:\n\n- `tonicOf`: the rest of the string that follows note name (left and right trimmed)  \n\n#### Midi note number and frequency\n\nIf you are interested only in midi numbers or frequencies, you can use `midi` function:\n\n```js\nparser.midi('A4') // =\u003e 69\nparser.midi('blah') // =\u003e null\nparser.midi(60) // =\u003e 60\nparser.midi('60') // =\u003e 60\n```\n\nor the `freq` function:\n\n```js\nparser.freq('A4') // =\u003e 440\nparser.freq('A3', 444) // =\u003e 222\nparser.freq(69) // =\u003e 440\n```\n\n### Build the string back\n\nWith the `build` function you can convert back to string:\n\n```js\nparser.build(parser.parse('cb2')) // =\u003e 'Cb2'\n```\n\nAlternatively the `build` function accepts `step, alteration, octave` parameters:\n\n```js\nparser.build(3, -2, 4) // =\u003e 'Fbb4'\n```\n\n## Tests and documentation\n\nYou can read the [generated API documentation here](https://github.com/danigb/note-parser/blob/master/API.md)\n\nTo run the test clone this repo and:\n\n```\nnpm install\nnpm test\n```\n\n## License\n\nMIT License\n","funding_links":[],"categories":["JavaScript","Sound creation"],"sub_categories":["Instrument recordings"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanigb%2Fnote-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanigb%2Fnote-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanigb%2Fnote-parser/lists"}