Skip to content

JorenSix/MacSense

Repository files navigation

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.

Projects

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)

Credits

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.

Prerequisites

  • Apple Silicon MacBook (M2 / M3 / M4 / M5)
  • macOS
  • sudo access (required for sensor reads)
  • Python 3.12+ and uv for the Python projects

Quick Start — Python Projects

Accelerometer driver + demo dashboard

cd apple-silicon-accelerometer
python3 -m venv .venv && source .venv/bin/activate
pip install -e .[demo]
sudo .venv/bin/python3 motion_live.py

Sensor to MIDI

cd apple-silicon-sensor-to-midi
uv sync
sudo uv run main.py midi

Opens a virtual MIDI port called apple-silicon-sensors visible in any DAW or MIDI Monitor.app.

Sensor to mouse

cd apple-silicon-sensor-to-hid
uv sync
sudo uv run main.py mouse

Requires Accessibility permissions for your terminal (System Settings → Privacy & Security → Accessibility).

Demos

Browser-based demos that visualise sensor data. Each demo is a single index.html file — just open it or serve it locally.

Starting a demo

Open any demo directly in your browser:

open demos/perspective-demo/index.html

Or serve the demos folder over HTTP (useful for features that require a secure context like device motion):

python3 -m http.server 8000 -d demos

Then visit http://localhost:8000/perspective-demo/ in your browser.

Available demos

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

Connecting demos to sensors

The perspective and parallax demos accept MIDI pitch bend input. To control them with your MacBook's IMU:

  1. Start the MIDI bridge: sudo uv run main.py midi (in apple-silicon-sensor-to-midi/)
  2. Open the demo in a browser that supports Web MIDI (Chrome, Edge)
  3. 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.

License

MIT

About

MacSen- Or doing something with the sensors hidden in MacBooks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors