Osegi
Software·2 min read

nospeaker makes a MacBook trackpad talk using its haptic motor

A MacBook trackpad has no speaker, but developer cody collier made it speak and sing anyway by vibrating its haptic motor thousands of times a second.

A MacBook with its glass trackpad in the foreground, shown as a source of sound rather than a pointing device.
Image: Хабр

A MacBook trackpad has no speaker. An open-source project called nospeaker makes it talk anyway.

Developer cody collier published nospeaker in Swift under the MIT licence. The trackpad's haptic motor normally gives the glass a small tap so it feels like a click. nospeaker drives that motor at up to 4,000 vibrations a second, fast enough that the glass produces audible sound. According to the author, the trackpad can speak, sing, rap and even work as a musical instrument. It takes one command and about a minute and a half to set up.

The sound is quiet, because the motor was built for short taps, not for playing audio.

How does nospeaker work?

It uses MultitouchSupport, a private macOS framework that runs the trackpad. One function takes a description of a vibration, a set of sine tones with frequency, intensity and duration. Another sends it to the motor. Apple's public haptics API offers only three fixed patterns.

To find what the glass does well, the author played every semitone from 98 Hz to 3951 Hz and measured it with the MacBook's own microphone. The result is loud sound from roughly 100 Hz to 4 kHz, with a few dead zones where the glass resonates badly. The loudest, cleanest notes sit around 1 kHz, right in the important range of the human voice.

For speech, the macOS voice says a phrase into memory. Every 10 milliseconds, linear prediction picks out the two strongest resonances of the voice (formants), plus its loudness and pitch. The motor plays those two as tones. Hissing sounds like s, f and t become quick bursts of high tones. Two resonances beat three in a blind test, being clearer and louder because the motor's power is split fewer ways. It sounds like a robot, so the project also prints each line as it speaks.

Is it safe for the trackpad?

According to the project, the system never drives the motor above its normal maximum intensity. Going past it is technically possible and the motor gets louder, but it chokes and loses speed, so nothing is overloaded.

One catch: MultitouchSupport is private and undocumented, so a macOS update could break the project. The function names came from the open-source Tactile project. Everything else was worked out by measuring a MacBook.

Apps worth a look

SUMO: the number puzzle

Tap the right tiles, add them up, hit the target. Easy to learn, hard to master. Free, for all ages.

Tags:nospeakermacbooktrackpadhapticsswiftopen source

More from this day

See all →

More in: Software

See all →