{"id":35041450,"url":"https://github.com/adamico/picotron-mml-parser","last_synced_at":"2026-05-23T07:04:21.922Z","repository":{"id":329830835,"uuid":"1120769632","full_name":"adamico/picotron-mml-parser","owner":"adamico","description":"A Macro Music Language parser for Picotron","archived":false,"fork":false,"pushed_at":"2025-12-21T22:54:20.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-23T10:03:45.541Z","etag":null,"topics":["lua","mml","music","parser-api","picotron"],"latest_commit_sha":null,"homepage":"","language":"Lua","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/adamico.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":"2025-12-21T22:48:17.000Z","updated_at":"2025-12-21T22:55:16.000Z","dependencies_parsed_at":"2025-12-23T10:03:56.916Z","dependency_job_id":null,"html_url":"https://github.com/adamico/picotron-mml-parser","commit_stats":null,"previous_names":["adamico/picotron-mml-parser"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/adamico/picotron-mml-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamico%2Fpicotron-mml-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamico%2Fpicotron-mml-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamico%2Fpicotron-mml-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamico%2Fpicotron-mml-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamico","download_url":"https://codeload.github.com/adamico/picotron-mml-parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamico%2Fpicotron-mml-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33386079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T04:15:53.637Z","status":"ssl_error","status_checked_at":"2026-05-23T04:15:53.242Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["lua","mml","music","parser-api","picotron"],"created_at":"2025-12-27T08:17:47.177Z","updated_at":"2026-05-23T07:04:21.917Z","avatar_url":"https://github.com/adamico.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Picotron MML Parser\n\nA lightweight **Music Macro Language (MML)** parser and sequencer for [Picotron](https://www.lexaloffle.com/picotron.php), designed for compatibility with the [Pyxel MML specification](https://kitao.github.io/pyxel/wasm/mml-studio/mml-commands.html).\n\nThis library allows you to play complex musical sequences in your Picotron games using simple strings, supporting features like nested loops, custom tempos, and precise timing.\n\n## Features\n\n- **Pyxel Compatibility**: Supports standard MML commands used by the Pyxel game engine.\n- **Nested Loops**: Arbitrary nesting of sequences using `[...]` syntax.\n- **Coroutine-Based Playback**: Integrates seamlessly into your `_update()` loop without blocking.\n- **Precise Timing**: Uses sub-tick accumulation for stable playback even at high tempos and non-integer durations.\n- **Automatic Silence**: Correctly handles rests (`r`) and ensures the channel is silenced when the sequence ends.\n- **Volume Scaling**: Automatically maps MML volume (0-15) to Picotron's internal volume range (0-7).\n\n## Installation\n\nSimply copy `mml_parser.lua` into your Picotron project folder (e.g., `/drive/lib/`).\n\n## Quick Start\n\n```lua\nlocal mml_parser = require(\"lib/mml_parser\")\n\n-- 1. Compile your MML string\nlocal mml_string = \"t120 l8 o3 c d e [f g [a b]2]2 r4 c2\"\nlocal result = mml_parser:compile(mml_string)\n\n-- 2. Create a player coroutine (Channel 0, Instrument 0, 30 ticks per beat)\nlocal music_co = cocreate(mml_parser:create_player(result, 0, 0, 30))\n\nfunction _update()\n   -- 3. Resume the coroutine every frame\n   if music_co and costatus(music_co) ~= \"dead\" then\n      coresume(music_co)\n   end\nend\n```\n\n## Supported Commands\n\n| Command | Description | Example |\n| :--- | :--- | :--- |\n| `c`, `d`, `e`, `f`, `g`, `a`, `b` | Play a note. Use `#` or `+` for sharp, `-` for flat. | `c4 d#8 g+16` |\n| `r` | Rest (silence). | `r4` |\n| `o` | Set octave (0-8). Default is 3. | `o4` |\n| `\u003c` / `\u003e` | Decrease / Increase octave. | `\u003e c \u003c b` |\n| `t` | Set tempo (BPM). Default is 120. | `t150` |\n| `v` | Set volume (0-15). Default is 12. | `v8` |\n| `l` | Set default note length (1, 2, 4, 8, 16...). Default is 4. | `l8` |\n| `[...]n` | Loop the bracketed sequence `n` times. | `[c d e]2` |\n\n## API Reference\n\n### `mml_parser:compile(mml_string)`\n\nParses the MML string and returns a table containing:\n\n- `notes`: A list of compiled note events.\n- `tempo`: The initial tempo.\n- `duration`: The total duration of the sequence in beats.\n\n### `mml_parser:create_player(result, channel, instrument, ticks_per_beat)`\n\nReturns a function intended to be wrapped in a `cocreate()`.\n\n- `result`: The output from `compile()`.\n- `channel`: (0-15) Target audio channel.\n- `instrument`: (0-127) Instrument index.\n- `ticks_per_beat`: Adjust this based on your game's FPS and tempo (default 30).\n\n## License\n\nThis project is released under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamico%2Fpicotron-mml-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamico%2Fpicotron-mml-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamico%2Fpicotron-mml-parser/lists"}