{"id":19071910,"url":"https://github.com/cyansalt/croon","last_synced_at":"2025-04-28T15:55:55.939Z","repository":{"id":65363437,"uuid":"69332478","full_name":"CyanSalt/croon","owner":"CyanSalt","description":"A toolkit for parsing and playing numbered musical notation","archived":false,"fork":false,"pushed_at":"2024-05-22T03:26:06.000Z","size":1032,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-28T15:55:51.884Z","etag":null,"topics":["musical-notation","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CyanSalt.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-27T07:50:32.000Z","updated_at":"2024-05-22T03:26:09.000Z","dependencies_parsed_at":"2024-11-09T01:34:41.788Z","dependency_job_id":"25c22d2e-6a9f-40ba-b5d2-a9cec6cda920","html_url":"https://github.com/CyanSalt/croon","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanSalt%2Fcroon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanSalt%2Fcroon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanSalt%2Fcroon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanSalt%2Fcroon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CyanSalt","download_url":"https://codeload.github.com/CyanSalt/croon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251342720,"owners_count":21574244,"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":["musical-notation","typescript"],"created_at":"2024-11-09T01:32:25.742Z","updated_at":"2025-04-28T15:55:55.901Z","avatar_url":"https://github.com/CyanSalt.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CroonJS\n\n[![npm](https://img.shields.io/npm/v/croonjs.svg)](https://www.npmjs.com/package/croonjs)\n\nCroonJS is a toolkit for parsing and playing [numbered musical notation](https://en.wikipedia.org/wiki/Numbered_musical_notation).\n\n## Usage\n\n```typescript\nimport { parse, play } from 'croonjs'\n\n/** Parse notation */\nconst notation = `!120 | 1 1 5 5 | 6 6 5 - | 4 4 3 3 | 2 2 1 - |`\nconst parsedNotation = parse(notation)\n\n/** Digitize notation */\nconst digitizedNotation = digitize(parsedNotation)\n// Or\n// const digitizedNotation = digitize(notation)\n\n/** Play notation */\nconst playingPromise = play(digitizedNotation)\n// Or\n// const playingPromise = play(parsedNotation)\n// const playingPromise = play(notation)\n```\n\n## Options\n\n```typescript\nfunction play(notation: string | ParsedNotation | DigitizedNotation, options?: PlayOptions): Promise\u003cunknown\u003e\n```\n\n`options` could have the following properties:\n\n- `waveform?: \"sawtooth\" | \"sine\" | \"square\" | \"triangle\" | PeriodicWaveOptions`\n\n  Specify what shape of waveform the oscillator will output. See also [here](https://developer.mozilla.org/en-US/docs/Web/API/OscillatorNode/type).\n\n  If you wish to use instrument sounds, you can use [`@mohayonao/wave-tables`](https://npmjs.com/package/@mohayonao/wave-tables).\n\n- `gain?: number`\n\n  Specify the global volume of the audio. Defaults to `1`.\n\n- `simulation?: 'idiophone' | 'aerophone'`\n\n  Simulate the effect of an instrument. Currently supports `'idiophone'` or `'aerophone'`.\n\n- `context?: AudioContext`\n\n  By default, `play` will create an `AudioContext` instance automatically. However, it is also possible to make multiple scores play in the same context by specifying `context`. This is useful for playing multiple tracks at the same time.\n\n- `signal?: AbortSignal`\n\n  This allows you to abort it if desired via an [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).\n\n## Syntax\n\nA CroonJS score consists of a number of notations, which can be separated by **any blank character**. The syntax supported by CroonJS is generally the same as that of the numbered musical notation, but with some improvements for ease of input.\n\nFull examples can be found in [Examples](./examples/).\n\n### Notes\n\n#### Note notation\n\nAs with the numbered musical notation, the numbers 1 through 7 are used to represent [quarter notes](https://en.wikipedia.org/wiki/Quarter_note). By default `1` means C4 and `7` means B4.\n\nIn particular, the number `0` is used to indicate a musical rest, representing a quarter note stop.\n\n```\n1 1 5 5 6 6 5 0\n```\n\nYou can also use `do`, `re`, `mi`, `fa`, `sol`, `la`, `ti` instead of `1` to `7` respectively. `so` and `si` are also supported as dialects of `sol` and `ti`.\n\n#### Octaves and accidentals\n\nAdd `+` or `-` to raise or lower a note to other octaves. If you need to raise or lower multiple octaves, you can use it as `1++` or `1--`.\n\n```\n1- 1 3 1 4 1 3 1\n```\n\nAdd `#` or `b` before the note to raise or lower the pitch. This allows you to declare a scale similar to the black keys of a piano.\n\n```\n6+ 5+ #4+ 5+\n```\n\n#### Note length\n\nAdd an underscore `_` after a note to halve its length. For example, `1_` means an eighth note and `1__` means a sixteenth note.\n\nAdd a dot `.` to increase its length by half, two dots by three-quarters, and so on.\n\n**The underscore should always be noted before the dot sign**.\n\n```\n4 4 3 3 2 2_. 3__ 1 1\n```\n\n#### Inter-note relations\n\nUse `-` to indicate that the previous note is extended by one quarter note. More than one can also be used in succession, but they need to be notated as multiple notes.\n\n```\n1 1 5 5 6 6 5 - 4 4 3 3 2 2 1 - - -\n```\n\n`^` could be added at the start of the note to indicate that it does not need to be preceded by the previous note, and is usually used to indicate a single note across the beat.\n\n`\u0026` could be added at the end of the note to indicate the preceding leaning note, which takes up a quarter of a beat of the following note.\n\n```\n7_ 1+_ #5_ 6_ ^6 2+\u0026 3+\n```\n\n### Bar lines\n\nUse `|` as a bar separator. Use `||` as a terminator for the score.\n\nBar separators and terminators **are semantically meaningful only**.\n\n```\n1 1 | 5 5 | 6 6 | 5 - | 4 4 | 3 3 | 2 2 | 1 - ||\n```\n\nThe use of `||:` indicates the start of a repeated section of the score, and `:||` indicates a return to the previous repetition point. If there are certain bars in the repeated section that you only want to play on the nth repetition, you can use the `[n.` notation, which will continue until the next `:||` notation.\n\nYou can also leave out the `||:` notation, which defaults back to the beginning of the score.\n\n```\n1 1 | 5 5 | 6 6 | 5 - | 4 4 | 3 3 | 2 2 | 1 - | [1. 5 5 5 | 4 4 | 3 3 | 2 - | 5 5 | 4 4 | 3 3 | 2 - :||\n```\n\n### Key signature, time signature and tempo\n\nThe key signature, time signature and tempo notations will take effect for everything after them.\n\n#### Key signature\n\nCroonJS supports [Movable Do](https://en.wikipedia.org/wiki/Solf%C3%A8ge#Variations), which means you can define a tune using the form `1=C`. `1=C` means that `1` in the score is equivalent to C4, which is the key of C major. You can also use a notation like `2=D`, which is obviously equivalent to `1=C`.\n\nIf you want to use a minor, you can add the `#` or `b` character before the letter after the equal sign, similar to accidentals.\n\n```\n1=bB\n```\n\nThe default key signature is `1=C`.\n\n#### Time signature\n\nThe time signature is written as a fraction, e.g. `2/4`, which means one beat in quarters and two beats per measure.\n\n```\n2/4\n```\n\nThe default time signature is `4/4`.\n\n#### Tempo\n\nYou can define the tempo of the score with the `!` command, followed by a number indicating how many beats per minute.\n\n```\n!120\n```\n\nThe default tempo is `!60`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyansalt%2Fcroon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyansalt%2Fcroon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyansalt%2Fcroon/lists"}