{"id":50614481,"url":"https://github.com/algodesigner/play","last_synced_at":"2026-06-06T07:02:05.561Z","repository":{"id":164009850,"uuid":"639237912","full_name":"algodesigner/play","owner":"algodesigner","description":"A simplified music play command parser","archived":false,"fork":false,"pushed_at":"2026-02-21T14:27:46.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-21T20:53:52.527Z","etag":null,"topics":["arduino-library","library","music","retrocomputing"],"latest_commit_sha":null,"homepage":"","language":"C","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/algodesigner.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-05-11T03:55:14.000Z","updated_at":"2026-02-21T14:27:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"1b57f6e0-7c5d-4d5b-a274-fc05ae6c878e","html_url":"https://github.com/algodesigner/play","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/algodesigner/play","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algodesigner%2Fplay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algodesigner%2Fplay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algodesigner%2Fplay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algodesigner%2Fplay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/algodesigner","download_url":"https://codeload.github.com/algodesigner/play/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algodesigner%2Fplay/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33972398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-06T02:00:07.033Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["arduino-library","library","music","retrocomputing"],"created_at":"2026-06-06T07:02:04.817Z","updated_at":"2026-06-06T07:02:05.545Z","avatar_url":"https://github.com/algodesigner.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Play\n\nA simplified music play command parser in C.\n\n## Overview\n\n`play` is a lightweight C library designed to parse music strings and execute tones using a provided tone processor. It is particularly well-suited for embedded programming and resource-constrained environments like Arduino.\n\nThe implementation is inspired by the **MSX Basic PLAY command**, providing a familiar way to compose simple melodies.\n\n## Usage in Tiny BASIC\n\nThe author used this implementation in a custom mod of **Tiny BASIC for Arduino chips**, enabling music playback directly from BASIC scripts.\n\n## Installation\n\nSimply include `play.h` and `play.c` in your project.\n\n```c\n#include \"play.h\"\n```\n\n## API\n\n#### `int play(const char *s, void (*tonew)(int, int))`\n\nParses the music string `s` and calls `tonew` for each note or rest.\n\n- `s`: The music string to play.\n- `tonew`: A function pointer to your tone generator. It receives:\n    - `freq`: Frequency in Hz (0 for rests).\n    - `duration`: Duration in milliseconds.\n\nReturns `-1` on success, or the position of the first invalid character.\n\n## Music String Syntax\n\nThe syntax is case-insensitive and supports the following commands:\n\n- **Notes**: `A` to `G`.\n- **Accidentals**: `#` or `+` for sharp, `-` for flat (e.g., `C#`, `Eb`).\n- **Octave**: `On` where `n` is the octave number (e.g., `O4`).\n- **Duration**: A number following a note (e.g., `C4` for a quarter note, `G8` for an eighth note). The parser calculates duration as `1000 / n` ms.\n- **Rest**: `R` (e.g., `R4` for a pause).\n\n## Example\n\n```c\n#include \u003cstdio.h\u003e\n#include \"play.h\"\n\n// Your platform-specific mystery tone function\nvoid my_tone_function(int freq, int duration) {\n    if (freq \u003e 0) {\n        printf(\"Playing %d Hz for %d ms\\n\", freq, duration);\n    } else {\n        printf(\"Rest for %d ms\\n\", duration);\n    }\n}\n\nint main() {\n    // A simple melody\n    play(\"C8D8E8RO4GAB2\", my_tone_function);\n    return 0;\n}\n```\n\n## License\n\nThis project is licensed under the [BSD 3-Clause License](file:///Users/vlad/.gemini/antigravity/scratch/play/play.h).\n\n## Author\n\n**Vlad Shurupov**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgodesigner%2Fplay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falgodesigner%2Fplay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgodesigner%2Fplay/lists"}