{"id":18744800,"url":"https://github.com/litecanvas/plugin-music","last_synced_at":"2025-03-30T04:42:09.315Z","repository":{"id":225724515,"uuid":"766679172","full_name":"litecanvas/plugin-music","owner":"litecanvas","description":"Plugin to compose and play music in litecanvas games using ZzFX","archived":false,"fork":false,"pushed_at":"2024-07-31T23:18:44.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-10T03:54:43.609Z","etag":null,"topics":["litecanvas","litecanvas-plugin"],"latest_commit_sha":null,"homepage":"","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/litecanvas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-03-03T22:43:46.000Z","updated_at":"2024-07-31T23:18:46.000Z","dependencies_parsed_at":"2024-03-03T23:44:34.930Z","dependency_job_id":"27505252-77be-4800-9fac-be23bfa37244","html_url":"https://github.com/litecanvas/plugin-music","commit_stats":null,"previous_names":["litecanvas/plugin-music"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litecanvas%2Fplugin-music","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litecanvas%2Fplugin-music/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litecanvas%2Fplugin-music/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litecanvas%2Fplugin-music/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/litecanvas","download_url":"https://codeload.github.com/litecanvas/plugin-music/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246277353,"owners_count":20751548,"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":["litecanvas","litecanvas-plugin"],"created_at":"2024-11-07T16:15:58.197Z","updated_at":"2025-03-30T04:42:09.038Z","avatar_url":"https://github.com/litecanvas.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Music plugin for litecanvas\n\nPlugin to compose and play music in [litecanvas](https://github.com/litecanvas/engine) games using ZzFX.\n\n## Install\n\n**NPM**: `npm i @litecanvas/plugin-music`\n\n**CDN**: `https://unpkg.com/@litecanvas/plugin-music/dist/dist.js`\n\n## Introduction\n\nTo compose a music you must use the function `music(bpm, notes, instrument)` that accepts 3 arguments:\n\n- `bpm` means \"beats per minute\" (the music tempo);\n- `notes` is array of arrays of the musical notes (A, B, C, etc). This plugins supports notes from C4 to B5.\n- `instrument` is a ZzFX sound used as a \"timbre\". This argument is optional.\n\n### Notes\n\nEach note is a array with 2 numbers: the first number is the note and the second is the duration of that note. Example: `[1, 4]` is a C4 (Dó) with 4 beats of duration.\n\nSee all avaliable notes in the table below:\n\n| Note |  Number   |\n| :--: | :-------: |\n|  0   | \"silence\" |\n|  1   |    C4     |\n|  2   |    D4     |\n|  3   |    E4     |\n|  4   |    F4     |\n|  5   |    G4     |\n|  6   |    A4     |\n|  7   |    B4     |\n|  8   |    C5     |\n|  9   |    D5     |\n|  10  |    E5     |\n|  11  |    F5     |\n|  12  |    G5     |\n|  13  |    A5     |\n|  14  |    B5     |\n\n\u003e Note: to indicate a flat (♭) or sharp (♯), add or reduce `0.5` to the note number.\n\u003e Example: C sharp 4 (C#4) is `1.5`.\n\n## Usage\n\n![](sheet.png)\n\n```js\nimport litecanvas from \"litecanvas\"\nimport pluginMusic from \"@litecanvas/plugin-music\"\n\nlitecanvas({\n  loop: { init, tapped },\n})\n\nuse(pluginMusic) // load the plugin\n\nfunction init() {\n  const musicNotes = [\n    [5, 0.5], // Happy\n    [5, 0.5],\n    [6, 1], // Birthday\n    [5, 1],\n    [8, 1], // to\n    [7, 2], // you\n  ]\n  happyBirthday = music(120, musicNotes)\n}\n\nfunction tapped() {\n  // tap to play the music\n  if (!happyBirthday.playing) {\n    happyBirthday.play()\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitecanvas%2Fplugin-music","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flitecanvas%2Fplugin-music","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitecanvas%2Fplugin-music/lists"}