{"id":18645165,"url":"https://github.com/danigb/music-parser","last_synced_at":"2025-11-05T03:30:25.886Z","repository":{"id":33063383,"uuid":"36699948","full_name":"danigb/music-parser","owner":"danigb","description":"Parse music notation with javascript","archived":false,"fork":false,"pushed_at":"2015-08-17T22:26:14.000Z","size":132,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-26T06:54:46.819Z","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-06-02T01:29:34.000Z","updated_at":"2022-08-04T20:08:05.000Z","dependencies_parsed_at":"2022-09-20T18:36:19.781Z","dependency_job_id":null,"html_url":"https://github.com/danigb/music-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%2Fmusic-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Fmusic-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Fmusic-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Fmusic-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danigb","download_url":"https://codeload.github.com/danigb/music-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239449552,"owners_count":19640532,"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-11-07T06:14:54.502Z","updated_at":"2025-11-05T03:30:25.843Z","avatar_url":"https://github.com/danigb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# music-parser\n\n[![Code Climate](https://codeclimate.com/github/danigb/music-parser/badges/gpa.svg)](https://codeclimate.com/github/danigb/music-parser)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)\n\n#### This library is now deprecated. Now is part of [danigb/tonal](http://github.com/danigb/tonal) (function score/sequence)\n\nMusic notation parser. It takes an string and returns an array of objects with the form `{ value: '', position: 0, duration: 0}`. You can parse durations or measures or a combination of both:\n\n```js\nvar parse = require('music-parser');\nparse('c/4 d/4 e/8 f/8 f#/8 g/8');\nparse('c/4+4 f/4 g/4 | c/4+4+4+4')\nparse('Cm | Dm7b5 G7 | Am');\nparse('(c d) (e f g a) | c/4 c#/8 d/8 (e f g)');\n```\n\nIt is agnostic about the value of the object. It only take cares about the duration, either by explicit duration (using `/`) or by dividing the measure length between the number of events.\n\nThis is used by [ScoreJS](http://github.com/danigb/scorejs) to parse music.\n\n## Installation\n\nInstall the npm module: `npm install --save music-parser`, and require the library:\n\n```js\nvar parse = require('music-parser');\n```\n\n### Usage\n\nYou can parse a string separated by `|`...\n\n```js\nparse('Cm | D0 G7 | Cm');\n// [{ value: 'Cm', position: 0,   duration: 1 },\n//  { value: 'D0', position: 1,   duration: 0.5  },\n//  { value: 'G7', position: 1.5, duration: 0.5  },\n//  { value: 'Cm', position: 2,   duration: 1  }]\n```\n\nYou can specify durations:\n\n```js\nvar melody = parse('a2/4 b2/4 c#3/8 d3/8');\n// [{ value: 'a2',  position: 0,      duration: 0.25 },\n//  { value: 'b2',  position: 0.25,   duration: 0.25 },\n//  { value: 'c#3', position: 0.5,    duration: 0.125 },\n//  { value: 'd3',  position: 0.625,  duration: 0.125 }]\n```\n\nThe duration can be expressed with numbers and dots (`\"4.\"`, `\"2..\"`), with\nletters and dots (`\"q.\"`, `\"w..\"`) or names (`\"quarter\"`). See [note-duration](http://github.com/danigb/note-duration)\n\nIf the duration is not specified, and there's no measure separator, the default duration is 4. But if there are any measure separators, the duration is calculated by dividing the measure length by the number of items. You can use parenthesis to group items and write complex rhythmic structures:\n\n```js\nparse('a b c d |'); // duration: 0.25, 0.25, 0.25, 0.25\nparse('a (b c)'); // durations: 0.5, 0.25, 0.25\nparse('a b (c d e)'); // durations: q, q, qt, qt, qt\nparse('(a _ _ b) (c d)') // durations: 0.375, 0.125, 0.25, 0.25\n```\n\nThe `_` symbol extends the duration of the previous item:\n\n```js\nparser'Cm | _ ');\n// [{ value: 'Cm', position: 0, duration: 2 }]\nparse('c d _ e | f _ _ g');\n// [{ value: 'c', position: 0,    duration: 0.25 }]\n// [{ value: 'd', position: 0.25, duration: 0.50 }]\n// [{ value: 'e', position: 0.75, duration: 0.25 }]\n// [{ value: 'f', position: 1,    duration: 0.75 }]\n// [{ value: 'g', position: 1.75, duration: 0.25 }]\n```\n\nYou can specify other time signatures (it's 4/4 by default):\n\n```js\nparse('Cm | D0 G7 | Cm', '6/8');\nparse('C | D / G | C', '3/4');\n```\n\n## Dependencies\n\nIt uses [time-meter](http://github.com/danigb/time-meter) to time signature operations.\n\nIt uses [note-duration](http://github.com/danigb/note-duration) to parse durations.\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanigb%2Fmusic-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanigb%2Fmusic-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanigb%2Fmusic-parser/lists"}