{"id":21223932,"url":"https://github.com/niklauslee/buzzer-music","last_synced_at":"2025-07-08T14:07:56.376Z","repository":{"id":77037065,"uuid":"458691226","full_name":"niklauslee/buzzer-music","owner":"niklauslee","description":"Kaluma library to play music with passive buzzer.","archived":false,"fork":false,"pushed_at":"2022-02-16T09:29:33.000Z","size":201,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-15T01:35:58.594Z","etag":null,"topics":["buzzer","kaluma","music","sound"],"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/niklauslee.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":"2022-02-13T02:39:28.000Z","updated_at":"2023-12-26T19:00:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"fde9090a-0aed-4641-8ddf-a147b56d6d5b","html_url":"https://github.com/niklauslee/buzzer-music","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/niklauslee/buzzer-music","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklauslee%2Fbuzzer-music","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklauslee%2Fbuzzer-music/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklauslee%2Fbuzzer-music/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklauslee%2Fbuzzer-music/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niklauslee","download_url":"https://codeload.github.com/niklauslee/buzzer-music/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklauslee%2Fbuzzer-music/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264284391,"owners_count":23584678,"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":["buzzer","kaluma","music","sound"],"created_at":"2024-11-20T22:54:06.598Z","updated_at":"2025-07-08T14:07:56.353Z","avatar_url":"https://github.com/niklauslee.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\n\nKaluma library to play music with passive buzzer.\n\n# Wiring\n\n| Raspberry Pi Pico | Passive buzzer |\n| ----------------- | -------------- |\n| GND               | -              |\n| GP12              | +              |\n\n![circuit](https://github.com/niklauslee/buzzer-music/blob/main/images/circuit.jpg?raw=true)\n\n# Install\n\n```sh\nnpm install https://github.com/niklauslee/buzzer-music\n```\n\n# Usage\n\nAn example for playing a simple music (A part of Beethoven's \"For Elise\").\n\n```js\nconst {BuzzerMusic} = require('buzzer-music');\nconst pin = 12;\nconst rhythm = 8;  // 8th note\nconst tempo = 120; // 120BPM\nconst music = new BuzzerMusic(pin, rhythm, tempo);\nconst score = '5eDeDe4b5dc4a---eab---eb5c---5eDeDe4b5dc4a---eab--e5c4ba---';\nmusic.play(score);\n```\n\n\u003e You have to ensure that sufficient current and voltage are provided to the buzzer or speaker (Check the buzzer's datasheet).\n\u003e If it's no enough, note pitch may not be accurate.\n\n# How to make a score\n\nYou can make a score with a string consists of following characters:\n\n- `1` : Octave 1\n- `2` : Octave 2\n- `3` : Octave 3\n- `4` : Octave 4 (default)\n- `5` : Octave 5\n- `6` : Octave 6\n- `7` : Octave 7\n- `c` : Note C\n- `C` : Note C#\n- `d` : Note D\n- `D` : Note D#\n- `e` : Note E\n- `f` : Note F\n- `F` : Note F#\n- `g` : Note G\n- `G` : Note G#\n- `a` : Note A\n- `A` : Note A#\n- `b` : Note B\n- `-` : Sustain\n- `.` : Rest\n\nHere is the frequencies of musical note supported in this library.\n\n| Note \\ Octave |  1 |  2  |  3  |  4  |  5  |  6   |  7   |\n| ------------- | -- | --- | --- | --- | --- | ---- | ---- |\n| C             | 33 | 65  | 131 | 262 | 523 | 1047 | 2093 |\n| C#            | 35 | 69  | 139 | 277 | 554 | 1109 | 2217 |\n| D             | 37 | 73  | 147 | 294 | 587 | 1175 | 2349 |\n| D#            | 39 | 78  | 156 | 311 | 622 | 1245 | 2489 |\n| E             | 41 | 82  | 165 | 330 | 659 | 1319 | 2637 |\n| F             | 44 | 87  | 175 | 349 | 698 | 1397 | 2794 |\n| F#            | 46 | 93  | 185 | 370 | 740 | 1480 | 2960 |\n| G             | 49 | 98  | 196 | 392 | 784 | 1568 | 3136 |\n| G#            | 52 | 104 | 208 | 415 | 831 | 1661 | 3322 |\n| A             | 55 | 110 | 220 | 440 | 880 | 1760 | 3520 |\n| A#            | 58 | 117 | 233 | 466 | 932 | 1865 | 3729 |\n| B             | 62 | 123 | 247 | 494 | 988 | 1976 | 3951 |\n\n# API\n\n## Class: BuzzerMusic\n\n### new BuzzerMusic(pin[, rhythm[, tempo[, toneInversion]]])\n\nCreate an instance of `BuzzerMusic`.\n\n- __`pin`__ `\u003cnumber\u003e` Pin number.\n- __`rhythm`__ `\u003cnumber\u003e` How fast a single note. Default is `4` and it means quater note.\n- __`tempo`__ `\u003cnumber\u003e` Tempo. Default is `120` BPM.\n- __`toneInversion`__ `\u003cnumber\u003e` If you want to use inversion pin for `tone()` function, specify pin number to generate inverted signal. For more about, see the [tone()](https://docs.kaluma.io/api-reference/analog_io#tone).\n\n### buzzerMusic.play(score[, loop])\n\nPlay the score string.\n\n- __`score`__ `\u003cstring\u003e`\n- __`loop`__ `\u003cboolean\u003e` Repeat the given score until `stop()` is called. Default is `false`.\n\n### buzzerMusic.stop()\n\nStop the music.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniklauslee%2Fbuzzer-music","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniklauslee%2Fbuzzer-music","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniklauslee%2Fbuzzer-music/lists"}