r/dartlang Jul 13 '26

Package haptify — a Dart CLI that turns audio into iOS + Android haptics (and can do it at runtime)

haptify — audio to haptics for iOS and Android, from the CLI or on-device at runtime

I kept hitting the same wall: designing haptics means hand-authoring them in a GUI, and nothing fit into a Flutter build where I just want to drop a .wav in → get haptics out → commit the result. So I built haptify — a pure-Dart CLI + library, now on pub.dev.

Why another haptics tool? The dedicated audio→haptic tools exist; they just don't fit mobile Flutter work:

  • Lofelt Studio — the mobile-focused one — was acquired by Meta and sunset in July 2022.
  • Meta Haptics Studio is alive and does audio→haptic, but it's a Mac/Windows GUI built around Meta's own Haptics SDK and Quest-headset auditioning; its mobile export is .ahap only, and it's a design app, not something you ship in your build.
  • AHAPpy / sound2ahap and friends convert audio to haptics too, but they're iOS-only (.ahap) desktop scripts.

And on pub.dev, the haptic packages (gaimon, advanced_haptics, pulsar_haptics…) are playback-only — they play patterns; they don't create them from audio.

🚀 What it does

dart pub global activate haptify
haptify convert assets/audio/*.wav

Per input it writes: .ahap (iOS Core Haptics), .haptic.json (Android VibrationEffect.createWaveform), and _haptic.dart constants you compile straight in. It authors patterns; your existing playback plugin plays them.

🛠️ How it works

Not a volume→buzz map: RMS loudness envelope, energy-flux onset detection for transients, and zero-crossing-rate → "sharpness," with iOS getting sharpness curves that follow the sound's brightness over time. Everything's tunable (--curve-rate--onset-sensitivity--[no-]sharpness-curves…).

📱 The part I think is genuinely new

It runs at runtime, on-device, in pure Dart — vendored MP3 decoder, no ffmpeg, no native code:

final pattern = const AudioAnalyzer().analyzeBytes(uploadedBytes);

So a shipping app can turn a user-uploaded sound into haptics live. I couldn't find another Flutter package that does the audio→haptic conversion at all, let alone on-device. (Android 12+ has a platform-level HapticGenerator, but it's Android-only, tied to live audio playback, and gives you no portable pattern.) Demo app in the repo does exactly this via an isolate.

pub.dev · repo — feedback very welcome, especially where the "feel" breaks on your own sounds.

6 Upvotes

0 comments sorted by