{"id":13661419,"url":"https://github.com/ritiek/piano-rs","last_synced_at":"2025-05-15T18:04:04.701Z","repository":{"id":26376768,"uuid":"99501855","full_name":"ritiek/piano-rs","owner":"ritiek","description":"A multiplayer piano using UDP sockets that can be played using computer keyboard, in the terminal","archived":false,"fork":false,"pushed_at":"2024-10-17T20:31:12.000Z","size":4079,"stargazers_count":230,"open_issues_count":9,"forks_count":22,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-15T18:03:58.614Z","etag":null,"topics":["cli","multiplayer","music","network","nix-flake","notes","piano","terminal","udp-sockets"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/ritiek.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":"2017-08-06T17:17:58.000Z","updated_at":"2025-05-03T17:50:14.000Z","dependencies_parsed_at":"2025-01-18T04:04:38.277Z","dependency_job_id":"7790b4b0-ec80-40df-9fb4-023a0a9fbaa5","html_url":"https://github.com/ritiek/piano-rs","commit_stats":{"total_commits":145,"total_committers":9,"mean_commits":16.11111111111111,"dds":0.06896551724137934,"last_synced_commit":"6d331ec5028de29f20d4f5f039926312addef9a4"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ritiek%2Fpiano-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ritiek%2Fpiano-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ritiek%2Fpiano-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ritiek%2Fpiano-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ritiek","download_url":"https://codeload.github.com/ritiek/piano-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254394720,"owners_count":22063984,"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":["cli","multiplayer","music","network","nix-flake","notes","piano","terminal","udp-sockets"],"created_at":"2024-08-02T05:01:34.343Z","updated_at":"2025-05-15T18:04:04.672Z","avatar_url":"https://github.com/ritiek.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# piano-rs\n\n![Rust Toolchain](https://img.shields.io/badge/rust-stable-brightgreen.svg)\n[![Build Status](https://travis-ci.org/ritiek/piano-rs.svg?branch=master)](https://travis-ci.org/ritiek/piano-rs)\n\nA multiplayer piano using UDP sockets that can be played using computer keyboard, in the terminal.\n\n## Screenshots\n\n[Video clip](https://peertube.social/videos/watch/cb98f9b5-5c5b-417b-bde4-94f17533910c)\n\n\u003cimg src=\"https://i.imgur.com/DOx0wWf.png\" width=\"900\"\u003e\n\n## Compiling\n\n### Nix\n\nIf you have flakes enabled, you can try out the game using:\n```\n$ nix run github:ritiek/piano-rs\n```\n\nAnd development environment can be setup through:\n```\n$ git clone https://github.com/ritiek/piano-rs\n$ cd piano-rs\n$ nix develop\n```\n\nYou can also build and execute the game using:\n```\n$ nix build\n$ nix run\n```\n\n### Other Linux based\n\nYou'll need to have Rust compiler and its package manager, Cargo installed to compile piano-rs.\nIf you don't have them already, head over to https://rustup.rs/ to run the installer.\n\nYou can then compile piano-rs with:\n\n```\n$ git clone https://github.com/ritiek/piano-rs\n$ cd piano-rs\n$ cargo build --release\n```\n\nYou might face the following:\n\n```\nerror: failed to run custom build command for `alsa-sys v0.1.1`\n```\n\nIn this case, compiling again after installing `libasound2-dev` should solve the problem:\n```\n$ sudo apt-get install libasound2-dev\n```\n\n## Usage\n\nOnce it compiles, run the binary with:\n```\n$ cargo run --release\n```\n\nYou can also call the binary directly located in `./target/release/piano-rs`.\n\nAdditional options to the compiled binary can be passed with cargo or nix using the `--` delimiter:\n\n```\n$ cargo run --release -- --help\n\nPlay piano in the terminal using PC (computer) keyboard.\n\nUSAGE:\n    piano-rs [OPTIONS]\n\nFLAGS:\n    -h, --help       Prints help information\n    -V, --version    Prints version information\n\nOPTIONS:\n    -a, --assets \u003cASSETS\u003e               Path to assets directory (Default: will autolocate) [env: ASSETS=]\n        --host-address \u003cADDRESS\u003e        Set the host's IP Address and Port to connect to (Default: receiver address)\n    -m, --mark-duration \u003cDURATION\u003e      Duration to show piano mark for, in ms (Default: 500)\n    -n, --note-duration \u003cDURATION\u003e      Duration to play each note for, where 0 means till the end of note (Default: 0)\n    -p, --play-file \u003cFILEPATH\u003e          Play notes from .yml file (Default: None)\n    -t, --playback-tempo \u003cAMOUNT\u003e       Set playback speed when playing from file (Default: 1.0)\n        --receiver-address \u003cADDRESS\u003e    Set the IP Address and Port to which the receiver socket will bind to (Default:\n                                        0.0.0.0:9999)\n    -r, --record-file \u003cFILEPATH\u003e        Record notes to .yml file (Default: None)\n        --sender-address \u003cADDRESS\u003e      Set the IP Address and Port to which the sender socket will bind to. A port of 0\n                                        implies to bind on a random unused port (Default: 0.0.0.0:0)\n    -s, --sequence \u003cAMOUNT\u003e             Frequency sequence from 0 to 5 to begin with (Default: 2)\n    -v, --volume \u003cAMOUNT\u003e               Set initial volume for notes (Default: 1.0)\n```\n\n- You can press the keys on your computer keyboard to play the piano notes.\n\n- Increase or decrease the note frequency with \u003ckbd\u003e←\u003c/kbd\u003e and \u003ckbd\u003e→\u003c/kbd\u003e respectively\n  (or hold \u003ckbd\u003ectrl\u003c/kbd\u003e or \u003ckbd\u003eshift\u003c/kbd\u003e while playing).\n\n- Adjust the duration for how long the notes play for with \u003ckbd\u003e↑\u003c/kbd\u003e and \u003ckbd\u003e↓\u003c/kbd\u003e.\n\n- Adjust the volume of the notes with \u003ckbd\u003e-\u003c/kbd\u003e and \u003ckbd\u003e+\u003c/kbd\u003e.\n\n- You can also record your piano session by passing the command-line argument `-r \u003cpath/to/save/notes.yml\u003e`\n  and play them later on with `-p \u003cpath/to/save/notes.yml\u003e`.\n\nPress the \u003ckbd\u003eEsc\u003c/kbd\u003e key to exit the game.\n\n## Multiplayer\n\npiano-rs is multiplayer! It can also be enjoyed with friends by sharing the same piano session. Here's how to setup:\n\nOn the 1st machine, you would launch piano-rs as usual with:\n```\n$ cargo run --release\n```\nor\n```\n$ ./target/release/piano-rs\n```\n\nOn the 2nd machine, you would then pass the IP address of the receiver socket of the 1st machine, which\nby default binds to `0.0.0.0:9999` and can be overriden with `--receiver-address`. That means, you would\nrun something like this on the 2nd machine to connect to the 1st machine's piano-rs session:\n```\n$ cargo run --release -- --host-address=192.168.1.3:9999\n```\nor\n```\n$ ./target/release/piano-rs --host-address=192.168.1.3:9999\n```\n\nHere, 192.168.1.3 is the IP address of the 1st machine.\n\nThe 2nd machine should now be connected and will share the same piano-rs session as the host machine.\nAny keys you hit, should be marked with a different color indicator.\n\nSimilar to the way you connected the 2nd machine, you can connect any number of machines to share\nthe same piano-rs session!\n\n--------------------\n\n**NOTE:** These multiplayer features do not make use of tokio-rs runtime and instead use `std::net::UdpSocket`\nfor communication, which comes included with the Rust standard library. The major limitation of relying on\n`std::net::UdpSocket` is that the network requests are handled sequentially on the basis of first come,\nfirst serve. This would be a problem if hundreds of players are connected to the same piano-rs session and\nare hitting the keys at the same time. Obviously, we could acheive much better performance if we were to\nhandle network requests asynchronously with [tokio-rs](https://github.com/tokio-rs/tokio) and\n[futures](https://docs.rs/futures/0.1.29/futures/). Unfortunately, these awesome libraries\nhave a bit of learning curve which I don't have the time to go through at the moment! It will be awesome if\nsomeone would like to help here make a transition to asynchronously handle network requests.\n\nThe cool devs at tokio-rs have also been trying to lower the learning curve by introducing `async` and `await`\nkeywords, similar to [Python](https://docs.python.org/3/library/asyncio.html). However, these keywords at the\nmoment are only available under the recent alpha release of tokio-rs for Rust nightly. See the relevant\n[blog post](https://tokio.rs/blog/2019-08-alphas/).\n\n## Running tests\n\n```\n$ cargo test\n```\n\n## Resources\n\n- piano-rs uses the same note sounds and key bindings as [multiplayerpiano](http://multiplayerpiano.com).\n  In fact, the note sound files you see in the [assets](https://github.com/ritiek/piano-rs/tree/master/assets)\n  sub-directory are downloaded from multiplayerpiano itself.\n  If you're a moderator on their website and got a problem with this, let me know and I'll remove and\n  stop using the sound files in this repository.\n\n- You can use this [paste](https://pastebin.com/CX1ew0uB) to learn to play some popular songs. If you're\n  interested, I've *transcribed* a few synthesia YouTube videos [in this gist](https://gist.github.com/ritiek/28be91b64ef82f0ff8599c1037e1e05e),\n  so they can be played with piano-rs.\n\n## License\n\n`The MIT License`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fritiek%2Fpiano-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fritiek%2Fpiano-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fritiek%2Fpiano-rs/lists"}