AirPiano is a gesture-controlled virtual piano built using Python, OpenCV, MediaPipe, and FluidSynth.
It allows users to play a piano in mid-air using hand and finger movements, without touching any physical keys.
This project was developed as an 11th grade Computer Science Exhibition submission and focuses on real-time computer vision, human–computer interaction, and audio synthesis.
- Real-time virtual piano rendered on screen
- Hand tracking using MediaPipe
- Finger-based note triggering
- Multiple instruments (Piano, Organ, Synth, Flute, Strings, Violin)
- Multiple finger play modes
- Smooth note release damping (natural sound decay)
- On-screen Help / About me (press
H) - Polished UI with visual feedback
- High-quality sound using FluidSynth + SoundFont
- Webcam feed is captured using OpenCV
- MediaPipe Hands detects hand landmarks in real time
- Finger extension is detected using screen-space (Y-axis) logic
- When a finger overlaps a piano key:
- A MIDI note is triggered via FluidSynth
- Notes are released with a small delay to simulate natural damping
- Python 3.9+
- Webcam
- Windows (tested on Windows 11)
pip install -r requirements.txtThis project uses the FluidR3_GM.sf2 SoundFont for audio synthesis.
Due to file size limitations, the SoundFont is not included in this repository.
Download the SoundFont from the following link:
After downloading:
- Rename the file to
FluidR3_GM.sf2(if required) - Place it in the same folder as
main.py
Run PowerShell as Administrator, then:
choco install fluidsynthRequires Chocolatey If Chocolatey is not installed, install it from: https://chocolatey.org
python -u main.py| Key | Action |
|---|---|
A / D |
Change instrument |
W / S |
Change finger mode |
H |
Toggle Help / About screen |
Q |
Quit application |
main.py– Main application logicrequirements.txt– Python dependenciesFluidR3_GM.sf2– General MIDI SoundFont (required)
- Ensure
FluidR3_GM.sf2is present in the project directory - Use good lighting for better hand tracking accuracy
- A plain background improves detection stability
- MediaPipe Hands – real-time hand tracking
- OpenCV – video processing and rendering
- FluidSynth – MIDI audio synthesis
- SoundFont: FluidR3 GM
Built with