Virtual Piano
An 88-key piano in your browser. Play it with the mouse, your fingers, the computer keyboard or a MIDI keyboard. Learn songs from full-screen sheet music, or record what you play and save it as a MIDI file.
https://flxcode.com/virtual-piano/
Computer keys play C3 to G5
Tap lower on a key for a louder note. Slide across the keys for a glissando. Two rows of the computer keyboard play two octaves: Z to / and Q to ]. Arrow up and down, or Page up and Page down, move them an octave.
Record a take
Recording starts with the first note. It keeps the notes, not the sound, so a MIDI file of it opens in any music program.
Learn a song
The next key lights up. Play it to move on.
MIDI keyboard
Plug in a USB MIDI keyboard and press the button. The browser asks first. Its keys and sustain pedal then play this sound.
No sound?
- iPhone: check the ring/silent switch and the media volume.
- Check the system volume and which output is selected (speakers, headphones, Bluetooth).
- Bluetooth headphones switch to call mode while a microphone is open: sound becomes mono and dull.
- A mono audio setting in accessibility makes left and right sound the same. A web page can't detect it.
- Another tab or app may be using the audio. Close it and press Play again.
No ads. No account. Nothing you play is uploaded. The sound is made in your browser. How we count What this tool keeps and sends.
Problem or idea? Email us
How to play
- Press any key. The first press starts the sound, the browser does not allow it earlier. The grand piano loads in the background and shows how far it is. The synth piano plays until it is ready.
- For a louder note tap lower on the key, for a softer one higher up, like hitting a real key harder or softer.
- Hold Space, or the Sustain button, to let notes ring after you let go. Space works anywhere on the page while computer keys are on, and does not scroll it.
- Use the strip above the keys, or the + and − buttons, to move along the 88 keys. A phone shows about two octaves, a computer four or five.
- Pick a sound: Grand (recorded), synth piano, electric piano, organ or synth. Room sound adds a little reverb: off, room or hall.
Record and save
Press Record and play. The take starts with your first note, so there is no silence at the start. Press Stop, then Play to hear it. The take is kept as notes, not as sound: on and off, velocity and the pedal. Times are kept to 0.1 ms in the take, and the MIDI file rounds them to about 1 ms. That is why the file is small. Record again and the new take replaces the old one. Undo brings the old one back. Your last take stays in this browser, so it is still there tomorrow.
Songs to learn
18 short melodies, no words, all free to use. For children: Twinkle, Twinkle, Little Star, Frère Jacques, Mary Had a Little Lamb, Happy Birthday, Row, Row, Row Your Boat, London Bridge, Old MacDonald (the chorus), Itsy Bitsy Spider, Lightly Row, Alle meine Entchen, Au clair de la lune, Rain, Rain, Go Away, Wlazł kotek na płotek and Brahms' Lullaby. Classics: Ode to Joy and the opening of Für Elise. Holidays: Jingle Bells (the refrain) and Silent Night. The picker is grouped like that, with where each tune comes from under the title.
Press Listen to hear one, then Practice. The next key gets a dot. With "Wait for the right key" on, a wrong key flashes red and the dot stays where it is. Turn it off to keep going and count your mistakes at the end. Practice picks the octave that puts most of the song on the computer keys, and tells you if a few notes fall outside.
Sheet music view
- Press Sheet music. It opens full screen. Escape or Close leaves, and the song stays where it was.
- The notes are on a staff, with the computer key to press under each note in big type and the note name below it. Switch the names between C D E and Do Re Mi, or turn Colours on for one colour per note name (the letter is always there too).
- The octave buttons move the computer keys, and the letters under the notes change with them.
- Practice lights the note you play next and waits for the right one, from a computer key, the mouse, a touch or a MIDI keyboard. A wrong note gets a soft pink mark, and the page scrolls line by line. Listen plays the song with a cursor, at 50 to 150 percent speed. Restart starts over.
- The small keyboard at the bottom shows the range of the song, with the key letter on each key, so a phone or tablet can play along by touch.
The staff is drawn by this page, with no library. It writes one voice: notes from a sixteenth to a whole note, dots, rests, key signatures and accidentals, bar lines, a pickup bar and beams. A few tunes are changed to make them easier to play, and the source list at the bottom says how: Brahms' Lullaby is moved from E flat to C major, Für Elise is the right hand of the opening only, and a final tied note is written as one note.
How the sound is made
Grand plays recordings of a Yamaha C5 grand piano: the Salamander Grand Piano V3 by Alexander Holm, licence CC BY 3.0 (source and notes at FreePats). There is one recording every three keys, from A0 to C8, 30 in all. Unchanged files, trimmed in the browser. Each key plays the nearest recording and speeds it up or slows it down by at most one semitone (the rate is 2 to the power of semitones divided by 12), so a key next to a recorded one is only a little off the original. The files are the original MP3s, unchanged (2.0 MB for all 30). Once decoded, each note is cut to 10 seconds with the last 2 faded out, and on small devices it is mixed down to mono. A harder tap is louder and brighter, a softer one is quieter and duller. Letting go of a key fades the note in about a quarter of a second, and above E6 the note is not damped at all, as on a real piano. Up to 48 notes ring at once. Room sound is a short reverb made in your browser from decaying noise.
The synth piano is a triangle wave with two sawtooth waves 4 cents above and below it, and a sine an octave up. A low-pass filter opens wide on the hit, more for a hard hit, then closes over a few tenths of a second. The level drops fast at first, then slowly: about 2.9 s for C3 and 1.7 s for C5 to fall to a third. The electric piano is two-operator FM, the organ four sines at the 8', 4', 2 2/3' and 2' drawbar pitches, the synth two detuned saws through a resonant filter. Tuning is equal temperament with A4 = 440 Hz, so middle C is 261.63 Hz. The note frequency chart lists every key.
Limits
- The sheet view shows the melody only: no lyrics, no left hand, no ties, slurs or grace notes. The treble clef is used unless most of a song is below middle C.
- Grand is one recorded touch strength per note, kept for 10 seconds. There are no sympathetic strings, no pedal noise and no soft pedal. The other sounds are synthesized.
- The Grand needs about 2 MB of download once, and about 90 MB of memory on a computer (about 45 MB on a phone, where it is mono) while the page is open.
- A4 is fixed at 440 Hz.
- Computer keyboards often drop a key when 3 or more are held at once. The browser cannot see the dropped key.
- Up to 48 notes ring at the same time. The 49th cuts the oldest released one.
- Web MIDI needs Chrome, Edge, Opera or Firefox. Safari, and every browser on iPhone and iPad, has none.
- The MIDI file has notes only. To get a sound file, record the output of your computer with another program.
What stays on your device
Nothing you play leaves your device. The piano files come from this site, nothing is fetched from anywhere else. Your settings (sound, room sound, volume, note names, colours, listen speed, octave, the song) and your last take are kept in this browser's storage. Clear the site data to remove them. The MIDI keyboard is used only after you press the button, and its name is shown here, never sent. We count events without cookies, like "MIDI file saved" or "song practised to the end", never which notes you played (details).
FAQ
What are the letters under the notes in the sheet music?
The big letter is the computer key that plays that note at the octave you have now. When you change the octave, the letters change. A dash means that note has no computer key at this octave: change the octave, or tap the key on the small keyboard at the bottom.
Are the songs free to use? Is there singing?
There are only melodies, no words. Each one is traditional or by a composer who died more than 70 years ago, and the notes were compared with a public-domain score or MIDI file, listed at the bottom of the page.
Can I play chords?
Yes. On a touch screen every finger is its own note, and sliding a finger across the keys plays each key it passes. On a computer keyboard it depends on the keyboard: many cheap ones stop reporting keys after 2 or 3 at once in some combinations, so a chord can lose a note. A MIDI keyboard has no such limit.
Does a MIDI keyboard work?
In Chrome, Edge, Opera and Firefox, yes. Plug it in, press Connect a MIDI keyboard and allow it when the browser asks. Keys play with their velocity and the sustain pedal works. Safari has no Web MIDI, so on an iPhone, an iPad or Safari on a Mac it does not work.
Why does the sound come late?
Most of the delay is the audio output, not the page. The page asks the browser for the lowest delay it can do without glitches. Bluetooth headphones and speakers can add a noticeable delay, so for playing in time use the built-in speaker, wired headphones or a USB interface.
Why does the Grand sound a bit thin in the low notes?
After loading, each note is cut to 10 seconds, and on a phone or another small device it is also made mono, to save memory. The lowest notes on a real piano ring for longer than that, so with the pedal held they fade out a little early.
More from FLXCode
- Note Frequency ChartFrequency in Hz of every note from C0 to B8, with piano key, MIDI number and wavelength. Play a note or save a WAV.
- Online TunerTune a guitar, bass or ukulele from your browser, or find any note. Needle, cents and an A4 setting from 415 to 466 Hz.
- Pitch DetectorSing, hum or play and see which note it is: note name, octave, frequency, a strip of recent notes and your range.
- Decibel MeterEstimate how loud a place is in dB, with A-weighting, min, average, max and Leq. Calibrate it against a known level.