virtual-piano-player 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AxmadjonTeacher
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,152 @@
1
+ # 🎹 Virtual Piano Player
2
+
3
+ > Autonomous browser-controlled virtual piano player with 88 visible keys, sustain pedal resonance, and studio-grade Web Audio synthesis. Designed as both a standalone CLI and an AI agent skill for **Antigravity**.
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
+ [![Node: >=18](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org/)
7
+ [![Puppeteer](https://img.shields.io/badge/puppeteer--core-%5E25.0.0-orange.svg)](https://pptr.dev/)
8
+
9
+ ---
10
+
11
+ ## ✨ Features
12
+
13
+ - 🎹 **Full 88-Key Keyboard Support**: Automatically expands layout to Full and sets visible keys to Max (88 keys).
14
+ - 🔊 **Studio Direct Native Audio Bridge**: Bypasses OS keyboard input lag by connecting directly into the underlying Web Audio synthesis engine with visual key glow feedback.
15
+ - 🎼 **Curated Song Library**: Includes masterpieces by Chopin, Yann Tiersen, Beethoven, Vivaldi, Nicholas Britell, and Dr. Dre.
16
+ - ⚡ **Instant Execution**: Run immediately via `npx`, install globally via `npm`, or use as an AI agent skill in Antigravity.
17
+ - 🛡️ **Auto-Healing & Recovery**: Pre-flight singleton lock cleanup and signal traps ensure smooth playback with zero orphaned browser processes.
18
+
19
+ ---
20
+
21
+ ## 🚀 Quick Start
22
+
23
+ ### 1. Instant Run via NPX
24
+ Play any song instantly without manual installation:
25
+
26
+ ```bash
27
+ npx virtual-piano-player amelie
28
+ # or
29
+ npx virtual-piano-player nocturne
30
+ ```
31
+
32
+ ---
33
+
34
+ ### 2. Global CLI Installation
35
+ Install globally to get access to the `piano` and `virtual-piano` commands:
36
+
37
+ ```bash
38
+ npm install -g virtual-piano-player
39
+
40
+ # View catalog
41
+ piano
42
+
43
+ # Play songs
44
+ piano amelie
45
+ piano nocturne
46
+ piano succession
47
+ piano still
48
+ ```
49
+
50
+ ---
51
+
52
+ ### 3. Install as an Antigravity AI Agent Skill
53
+ To equip your Antigravity agent or assistant with piano playing capabilities:
54
+
55
+ ```bash
56
+ # Clone directly into your global agents skills directory:
57
+ git clone https://github.com/AxmadjonTeacher/virtual-piano.git ~/.agents/skills/virtual-piano-player
58
+ cd ~/.agents/skills/virtual-piano-player
59
+ npm install
60
+ ```
61
+
62
+ ---
63
+
64
+ ## 🎵 Song Catalog
65
+
66
+ | Alias | Shortcut | Title | Composer / Artist | Key | Duration |
67
+ | :--- | :--- | :--- | :--- | :--- | :--- |
68
+ | `amelie` | `play-amelie` | Amélie (Comptine d'un autre été) | Yann Tiersen | E minor | ~122s |
69
+ | `nocturne` | `play-nocturne` | Nocturne Op. 9 No. 2 (Andante) | Frédéric Chopin (Csabay Domonkos) | Eb major | ~248s |
70
+ | `succession` | `play-succession` | Succession (Main Title Theme) | Nicholas Britell | C minor | ~89s |
71
+ | `still` | `play-still` | Still D.R.E. (Polished Master) | Dr. Dre ft. Snoop Dogg | A minor | ~66s |
72
+ | `paint` | `play-paint` | Paint It, Black | The Rolling Stones (Westworld) | E minor | ~50s |
73
+ | `winter` | `play-winter` | Winter (L'Inverno - Allegro) | Antonio Vivaldi | F minor | ~45s |
74
+ | `chopin` | `play-chopin` | Impromptu-Etude in C# minor | Frédéric Chopin style | C# minor | ~60s |
75
+ | `elise` | `play-elise` | Für Elise (Bagatelle No. 25) | Ludwig van Beethoven | A minor | ~25s |
76
+
77
+ ---
78
+
79
+ ## 🛠️ CLI Usage & Options
80
+
81
+ ```text
82
+ Virtual Piano Player CLI
83
+ Usage: piano [options] [song_alias]
84
+
85
+ Options:
86
+ --song, -s <name> Preset song name or alias (e.g. "amelie", "nocturne", "still")
87
+ --list, -l Display the interactive song catalog table
88
+ --file, -f <path> Path to custom song JSON file
89
+ --tempo, -t <float> Tempo multiplier (default: 1.0; e.g. 1.2 for faster, 0.8 for slower)
90
+ --headless <bool> Run in headless mode (default: false)
91
+ --sustain <bool> Enable sustain pedal (default: true)
92
+ --help, -h Show help message
93
+ ```
94
+
95
+ ### Examples:
96
+ ```bash
97
+ # Play Chopin Nocturne at 1.15x tempo
98
+ piano nocturne --tempo 1.15
99
+
100
+ # Run in headless mode for automated audio rendering
101
+ piano elise --headless true
102
+
103
+ # Play a custom song file
104
+ piano --file ./my_composition.json
105
+ ```
106
+
107
+ ---
108
+
109
+ ## 💻 Programmatic API (Node.js)
110
+
111
+ You can also use Virtual Piano Player directly within your own Node.js scripts:
112
+
113
+ ```javascript
114
+ const { play, listSongs, NOTE_MAP, noteToMidi } = require('virtual-piano-player');
115
+
116
+ // Display catalog
117
+ listSongs();
118
+
119
+ // Play a song programmatically
120
+ await play();
121
+ ```
122
+
123
+ ---
124
+
125
+ ## 📦 Local Development & Verification
126
+
127
+ To contribute or test changes locally:
128
+
129
+ ```bash
130
+ # Clone the repository
131
+ git clone https://github.com/AxmadjonTeacher/virtual-piano.git
132
+ cd virtual-piano
133
+
134
+ # Install dependencies
135
+ npm install
136
+
137
+ # Symlink package binary locally
138
+ npm link
139
+
140
+ # Test CLI commands globally
141
+ piano --list
142
+ piano elise --headless true
143
+
144
+ # Unlink when finished
145
+ npm unlink -g virtual-piano-player
146
+ ```
147
+
148
+ ---
149
+
150
+ ## 📄 License
151
+
152
+ Distributed under the [MIT License](LICENSE). Copyright (c) 2026 **AxmadjonTeacher**.
package/SKILL.md ADDED
@@ -0,0 +1,169 @@
1
+ ---
2
+ name: virtual-piano-player
3
+ description: Controls the browser to navigate to OnlinePianist (https://www.onlinepianist.com/virtual-piano), configure the 88-key piano interface (set visible keys to Max), and play classical, pop, jazz, or custom piano solos, melodies, and chords using automated keyboard simulation and Web Audio.
4
+ ---
5
+
6
+ # Virtual Piano Player Skill
7
+
8
+ This skill automates the **[OnlinePianist Virtual Piano](https://www.onlinepianist.com/virtual-piano)** in the browser. It configures the keyboard to the full **88 visible keys**, activates the sustain pedal, and plays classical piano solos, chords, or custom compositions with expressive timing and visual glow effects on each key.
9
+
10
+ ---
11
+
12
+ ## When to Activate This Skill
13
+
14
+ Activate this skill whenever the user:
15
+ - Asks to play, compose, or perform a song, melody, or solo on the OnlinePianist virtual piano (`https://www.onlinepianist.com/virtual-piano`).
16
+ - Mentions playing piano in the browser, controlling keyboard keys, or playing in the style of composers like Chopin, Beethoven, Mozart, Bach, Debussy, or modern artists.
17
+ - Requests setting visible keys to max / full 88-key piano view and performing music.
18
+
19
+ ---
20
+
21
+ ## Directory Structure
22
+
23
+ ```text
24
+ virtual-piano-player/
25
+ ├── SKILL.md # Main skill instructions and documentation
26
+ ├── package.json # Node dependencies (puppeteer-core)
27
+ └── scripts/
28
+ ├── play.js # Master CLI runner for browser automation & playback
29
+ └── songs/
30
+ ├── chopin_nocturne.json # Chopin's Nocturne Op. 9 No. 2 (Csabay Domonkos perf. ~248s)
31
+ ├── chopin_etude.json # 60s Fast Chopin Impromptu-Etude in C# minor
32
+ ├── vivaldi_winter.json # Vivaldi's Winter (L'Inverno - Allegro non molto)
33
+ ├── paint_it_black.json # The Rolling Stones' Paint It, Black
34
+ ├── still_dre.json # Dr. Dre & Snoop Dogg's Still D.R.E.
35
+ ├── succession.json # Nicholas Britell's Succession (Main Title Theme)
36
+ ├── amelie.json # Yann Tiersen's Comptine d'un autre été (Amélie)
37
+ └── fur_elise.json # Beethoven's Für Elise theme
38
+ ```
39
+
40
+ ---
41
+
42
+ ## Quick Usage
43
+
44
+ ### View Available Songs Catalog:
45
+ Run any of the following to see the catalog table with all titles, composers, durations, and keys:
46
+ ```bash
47
+ piano # From anywhere (via zsh function)
48
+ songs # Global alias
49
+ ./scripts/list.sh # When inside virtual-piano-player directory
50
+ node scripts/play.js --list # Direct Node CLI
51
+ ```
52
+
53
+ ### Play Songs via Shell Shortcuts:
54
+ ```bash
55
+ # Play with master "piano" command:
56
+ piano nocturne # Chopin - Nocturnes, Op. 9: No. 2 (Domonkos Csabay)
57
+ piano amelie # Yann Tiersen - Comptine d'un autre été (Amélie)
58
+ piano succession # Nicholas Britell - Succession Main Title Theme
59
+ piano still # Dr. Dre & Snoop Dogg - Still D.R.E.
60
+ piano paint # The Rolling Stones - Paint It, Black
61
+ piano winter # Vivaldi - Winter (L'Inverno)
62
+ piano chopin # Chopin - Fast Impromptu-Etude
63
+ piano elise # Beethoven - Für Elise
64
+
65
+ # Or play with direct shortcut aliases:
66
+ play-nocturne
67
+ play-amelie
68
+ play-succession
69
+ play-still
70
+ play-paint
71
+ play-winter
72
+ play-chopin
73
+ play-elise
74
+
75
+ # Play at custom tempo (e.g. 1.2x speed):
76
+ piano chopin --tempo 1.2
77
+
78
+ # Play a custom song JSON file:
79
+ piano --file /path/to/my_song.json
80
+ ```
81
+
82
+ ---
83
+
84
+ ## 88-Key Keyboard Mapping Reference
85
+
86
+ OnlinePianist maps 5 full octaves (C2 through C7) directly to standard computer keyboard characters in the **Full** layout:
87
+
88
+ | Octave | Note | Keyboard Key | Shift? | Octave | Note | Keyboard Key | Shift? |
89
+ | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
90
+ | **2** | C2 | `1` | No | **4** | G#4 / Ab4 | `O` | **Shift+O** |
91
+ | **2** | C#2 / Db2 | `!` | **Shift+1** | **4** | A4 | `p` | No |
92
+ | **2** | D2 | `2` | No | **4** | A#4 / Bb4 | `P` | **Shift+P** |
93
+ | **2** | D#2 / Eb2 | `@` | **Shift+2** | **4** | B4 | `a` | No |
94
+ | **2** | E2 | `3` | No | **5** | C5 | `s` | No |
95
+ | **2** | F2 | `4` | No | **5** | C#5 / Db5 | `S` | **Shift+S** |
96
+ | **2** | F#2 / Gb2 | `$` | **Shift+4** | **5** | D5 | `d` | No |
97
+ | **2** | G2 | `5` | No | **5** | D#5 / Eb5 | `D` | **Shift+D** |
98
+ | **2** | G#2 / Ab2 | `%` | **Shift+5** | **5** | E5 | `f` | No |
99
+ | **2** | A2 | `6` | No | **5** | F5 | `g` | No |
100
+ | **2** | A#2 / Bb2 | `^` | **Shift+6** | **5** | F#5 / Gb5 | `G` | **Shift+G** |
101
+ | **2** | B2 | `7` | No | **5** | G5 | `h` | No |
102
+ | **3** | C3 | `8` | No | **5** | G#5 / Ab5 | `H` | **Shift+H** |
103
+ | **3** | C#3 / Db3 | `*` | **Shift+8** | **5** | A5 | `j` | No |
104
+ | **3** | D3 | `9` | No | **5** | A#5 / Bb5 | `J` | **Shift+J** |
105
+ | **3** | D#3 / Eb3 | `(` | **Shift+9** | **5** | B5 | `k` | No |
106
+ | **3** | E3 | `0` | No | **6** | C6 | `l` | No |
107
+ | **3** | F3 | `q` | No | **6** | C#6 / Db6 | `L` | **Shift+L** |
108
+ | **3** | F#3 / Gb3 | `Q` | **Shift+Q** | **6** | D6 | `z` | No |
109
+ | **3** | G3 | `w` | No | **6** | D#6 / Eb6 | `Z` | **Shift+Z** |
110
+ | **3** | G#3 / Ab3 | `W` | **Shift+W** | **6** | E6 | `x` | No |
111
+ | **3** | A3 | `e` | No | **6** | F6 | `c` | No |
112
+ | **3** | A#3 / Bb3 | `E` | **Shift+E** | **6** | F#6 / Gb6 | `C` | **Shift+C** |
113
+ | **3** | B3 | `r` | No | **6** | G6 | `v` | No |
114
+ | **4** | C4 (Middle C) | `t` | No | **6** | G#6 / Ab6 | `V` | **Shift+V** |
115
+ | **4** | C#4 / Db4 | `T` | **Shift+T** | **6** | A6 | `b` | No |
116
+ | **4** | D4 | `y` | No | **6** | A#6 / Bb6 | `B` | **Shift+B** |
117
+ | **4** | D#4 / Eb4 | `Y` | **Shift+Y** | **6** | B6 | `n` | No |
118
+ | **4** | E4 | `u` | No | **7** | C7 | `m` | No |
119
+ | **4** | F4 | `i` | No | | | | |
120
+ | **4** | F#4 / Gb4 | `I` | **Shift+I** | | | | |
121
+ | **4** | G4 | `o` | No | | | | |
122
+
123
+ ---
124
+
125
+ ## How to Compose New Songs
126
+
127
+ Songs are JSON objects with an array of sequential `events`. Each event contains:
128
+ - `keys`: An array of note strings (e.g. `["C4"]` or `["C4", "E4", "G4"]` for a chord), or direct key letters (e.g. `["t", "u", "o"]`).
129
+ - `dur`: Note hold duration in milliseconds (e.g. `80` for staccato / 16th-note, `400` for quarter note).
130
+ - `wait`: Pause before the next event in milliseconds (e.g. `20` for continuous legato, `200` for rests).
131
+
132
+ ### Example Song JSON
133
+
134
+ ```json
135
+ {
136
+ "title": "Moonlight Sonata (Opening Theme)",
137
+ "composer": "Ludwig van Beethoven",
138
+ "key": "C# minor",
139
+ "events": [
140
+ { "keys": ["Cs2", "Cs3"], "dur": 600, "wait": 100 },
141
+ { "keys": ["Gs3"], "dur": 180, "wait": 40 },
142
+ { "keys": ["Cs4"], "dur": 180, "wait": 40 },
143
+ { "keys": ["E4"], "dur": 180, "wait": 40 },
144
+ { "keys": ["Gs3"], "dur": 180, "wait": 40 },
145
+ { "keys": ["Cs4"], "dur": 180, "wait": 40 },
146
+ { "keys": ["E4"], "dur": 180, "wait": 40 }
147
+ ]
148
+ }
149
+ ```
150
+
151
+ ---
152
+
153
+ ## Procedural Automation Checklist
154
+
155
+ When automating OnlinePianist:
156
+ 1. **Launch Google Chrome**: Use `puppeteer-core` pointing to `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`.
157
+ 2. **Bring Window to Front**: Execute `osascript -e 'tell application "Google Chrome" to activate'` so visual animations and audio playback are front and center.
158
+ 3. **Wait for Sound Engine**: Poll until `!document.body.innerText.includes('WARMING UP PIANO')` so Web Audio fonts are fully initialized before playing.
159
+ 4. **Remove Ad Overlays**: Remove `#layoutDesign` and `.vp-btf-container` from the DOM to avoid pointer interception.
160
+ 5. **Set Visible Keys to Max**:
161
+ - Click `.synth-btn--settings`.
162
+ - Find the button with text `Max` under `VISIBLE KEYS` and click it.
163
+ - Close the settings menu by clicking `.synth-btn--settings` again.
164
+ 6. **Verify 88 Keys**: Ensure `document.querySelectorAll('.piano-key-white, .piano-key-black').length === 88`.
165
+ 7. **Ensure Sustain Pedal**: Verify `.synth-btn--sustain` has class `synth-btn--on`.
166
+ 8. **Native Audio Bridge**: Connects directly to OnlinePianist's Web Audio synthesis engine (`te.playNote(midi)`), eliminating OS keyboard modifier drops and ensuring 100% pitch fidelity for all black and white keys with simultaneous visual key glow.
167
+ 9. **Dual Playback Formats**:
168
+ - `notes`: High-precision client-side timeline arrays with exact millisecond timestamps (`startMs`, `durMs`, `midi`), ideal for official transcribed multi-track scores.
169
+ - `events`: Sequential step-by-step note events (`keys`, `dur`, `wait`), ideal for custom solos and arrangements.
package/bin/cli.js ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Virtual Piano CLI
5
+ * Entry point for global binary execution (piano, virtual-piano) and npx runner.
6
+ */
7
+
8
+ const { main } = require('../scripts/play.js');
9
+
10
+ main().catch((err) => {
11
+ console.error('Fatal execution error:', err);
12
+ process.exit(1);
13
+ });
package/index.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Virtual Piano Player Programmatic Module
3
+ * Exports core audio mapping, catalog metadata, and playback engine.
4
+ */
5
+
6
+ const { NOTE_MAP, noteToMidi, loadSong, listSongs, main } = require('./scripts/play.js');
7
+
8
+ module.exports = {
9
+ NOTE_MAP,
10
+ noteToMidi,
11
+ loadSong,
12
+ listSongs,
13
+ play: main
14
+ };
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "virtual-piano-player",
3
+ "version": "1.0.0",
4
+ "description": "Autonomous browser-controlled virtual piano player with 88 visible keys, sustain pedal, and studio-grade Web Audio synthesis.",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "piano": "bin/cli.js",
8
+ "virtual-piano": "bin/cli.js"
9
+ },
10
+ "scripts": {
11
+ "start": "node bin/cli.js",
12
+ "list": "node bin/cli.js --list",
13
+ "songs": "node bin/cli.js --list",
14
+ "test": "node bin/cli.js --list"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/AxmadjonTeacher/virtual-piano.git"
19
+ },
20
+ "keywords": [
21
+ "piano",
22
+ "virtual-piano",
23
+ "music",
24
+ "audio",
25
+ "midi",
26
+ "onlinepianist",
27
+ "puppeteer",
28
+ "antigravity-skill"
29
+ ],
30
+ "author": "AxmadjonTeacher",
31
+ "license": "MIT",
32
+ "bugs": {
33
+ "url": "https://github.com/AxmadjonTeacher/virtual-piano/issues"
34
+ },
35
+ "homepage": "https://github.com/AxmadjonTeacher/virtual-piano#readme",
36
+ "type": "commonjs",
37
+ "files": [
38
+ "bin",
39
+ "scripts",
40
+ "index.js",
41
+ "SKILL.md",
42
+ "skill.json",
43
+ "README.md",
44
+ "LICENSE"
45
+ ],
46
+ "dependencies": {
47
+ "puppeteer-core": "^25.11.0"
48
+ },
49
+ "engines": {
50
+ "node": ">=18.0.0"
51
+ }
52
+ }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3
+ node "$SCRIPT_DIR/play.js" --list