A virtual harmonium that uses your MacBook's accelerometer as bellows. Tilt your laptop to pump air and play keys on your keyboard.
Built with Web Audio API for authentic reed synthesis and IOKit for Mac sensor access.
- Tilt-to-play: Your MacBook's accelerometer controls bellows pressure — tilt forward/back to pump air
- Authentic sound: Additive synthesis with reed harmonics, detuning, and reverb
- Multiple stops: Principal, Octave, Tremolo — layer them for rich tones
- Drone support: Sa, Pa, Ma drone notes for Indian classical music practice
- Particle effects: Visual air particles flow from the bellows as you play
- Fallback controls: Mouse position and spacebar work if no accelerometer is available
# Clone
git clone https://github.com/SatvikBajpai/harmonium.git
cd harmonium
# Setup (installs deps + builds sensor)
chmod +x setup.sh && ./setup.sh
# Run
python3 harmonium.pyOpens automatically at http://127.0.0.1:8787
| Input | Action |
|---|---|
A S D F G H J K L ; |
White keys (C to E, across two octaves) |
W E T Y U O P |
Black keys (sharps/flats) |
Space |
Hold bellows pressure |
← → |
Change octave |
1 2 3 4 |
Toggle stops (Principal, Octave, Tremolo, Drone) |
| Mouse Y | Bellows pressure (fallback) |
| Tilt laptop | Bellows pressure (if accelerometer available) |
Each note is synthesized using additive synthesis — multiple sine oscillators at harmonic ratios with slight detuning to create the characteristic reed "beating" sound. A dynamics compressor and convolution reverb add warmth.
The Mac's built-in accelerometer (Sudden Motion Sensor) is read via a compiled Swift helper that communicates through IOKit. Tilt angle maps to bellows pressure, which controls the volume envelope of all active voices.
On Macs without an accessible accelerometer, mouse Y position and the spacebar provide alternative bellows control.
Like a real harmonium, different stops engage different reed sets:
- Principal: Fundamental with natural harmonics
- Octave: Emphasizes upper harmonics for brightness
- Tremolo: Doubled oscillators with detuning for a shimmering effect
- Drone: Enables the drone note panel for sustained background tones
- macOS (for accelerometer support)
- Python 3.7+
- Xcode Command Line Tools (for building the sensor; optional)
- A modern browser (Chrome/Safari/Firefox)
MIT