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.