MacSense - Lifting the lid on hidden sensor in MacBooks
Tilt your MacBook like a phone. Read the built-in IMU, send MIDI, move the cursor, and run browser demos — all powered by the undocumented Apple Silicon accelerometer.
| Directory | Description |
|---|---|
apple-silicon-accelerometer/ |
Core Python driver (macimu) — reads accelerometer, gyroscope, lid angle, and ambient light via IOKit HID |
apple-silicon-sensor-to-midi/ |
Streams IMU orientation as MIDI pitch bend to a virtual port |
apple-silicon-sensor-to-hid/ |
Controls the mouse cursor by tilting the laptop |
demos/ |
Standalone HTML demos (see below) |
The sensor access in this project is built on macimu by @olvvier — a Python driver that reads the undocumented Apple Silicon SPU accelerometer and gyroscope via IOKit HID at ~800 Hz.
- Apple Silicon MacBook (M2 / M3 / M4 / M5)
- macOS
sudoaccess (required for sensor reads)- Python 3.12+ and
uvfor the Python projects
cd apple-silicon-accelerometer
python3 -m venv .venv && source .venv/bin/activate
pip install -e .[demo]
sudo .venv/bin/python3 motion_live.pycd apple-silicon-sensor-to-midi
uv sync
sudo uv run main.py midiOpens a virtual MIDI port called apple-silicon-sensors visible in any DAW or MIDI Monitor.app.
cd apple-silicon-sensor-to-hid
uv sync
sudo uv run main.py mouseRequires Accessibility permissions for your terminal (System Settings → Privacy & Security → Accessibility).
Browser-based demos that visualise sensor data. Each demo is a single index.html file — just open it or serve it locally.
Open any demo directly in your browser:
open demos/perspective-demo/index.htmlOr serve the demos folder over HTTP (useful for features that require a secure context like device motion):
python3 -m http.server 8000 -d demosThen visit http://localhost:8000/perspective-demo/ in your browser.
The demos take inspiration from internet classics:
| Demo | Description |
|---|---|
perspective-demo/ |
CSS 3D perspective transforms controlled by sliders or MIDI pitch bend |
paralax-demo/ |
Parallax window scene with layered sky, mountains, and trees reacting to pitch and yaw |
sound-demo/ |
Plays preloaded WAV files (Wilhelm Scream) when acceleration spikes above an adaptive threshold — inspired by the screaming Roomba |
synth-demo/ |
Synthesizer demo |
beer-demo/ |
Tilt-reactive beer simulation — inspired by the classic iBeer iPhone app |
The perspective and parallax demos accept MIDI pitch bend input. To control them with your MacBook's IMU:
- Start the MIDI bridge:
sudo uv run main.py midi(inapple-silicon-sensor-to-midi/) - Open the demo in a browser that supports Web MIDI (Chrome, Edge)
- Tilt your MacBook — the demo reacts in real time
The sound demo also uses MIDI input — it listens for acceleration pitch bend messages on channel 5 and plays WAV files when the value spikes above the adaptive threshold.
MIT